blob: 3c10c0c0888c15962076fb0be0c728d74948f71d [file] [log] [blame]
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_SIGNIN_SIGNIN_HEADER_HELPER_H_
#define CHROME_BROWSER_SIGNIN_SIGNIN_HEADER_HELPER_H_
namespace net {
class URLRequest;
}
class GURL;
class ProfileIOData;
// Utility functions for handling Chrome/Gaia headers during signin process.
// In the Mirror world, Chrome identity should always stay in sync with Gaia
// identity. Therefore Chrome needs to send Gaia special header for requests
// from a connected profile, so that Gaia can modify its response accordingly
// and let Chrome handles signin with native UI.
namespace signin {
// Profile mode flags.
enum ProfileMode {
PROFILE_MODE_DEFAULT = 0,
// Incognito mode disabled by enterprise policy or by parental controls.
PROFILE_MODE_INCOGNITO_DISABLED = 1 << 0,
// Adding account disabled in the Android-for-EDU mode.
PROFILE_MODE_ADD_ACCOUNT_DISABLED = 1 << 1
};
// The ServiceType specified by GAIA in the response header accompanying the 204
// response. This indicates the action Chrome is supposed to lead the user to
// perform.
enum GAIAServiceType {
GAIA_SERVICE_TYPE_NONE = 0, // No GAIA response header.
GAIA_SERVICE_TYPE_SIGNOUT, // Logout all existing sessions.
GAIA_SERVICE_TYPE_SIGNOUTOPTIONS_INCOGNITO, // Open an incognito tab.
GAIA_SERVICE_TYPE_ADDSESSION, // Add a secondary account.
GAIA_SERVICE_TYPE_REAUTH, // Re-authenticate an account.
GAIA_SERVICE_TYPE_DEFAULT, // All other cases.
};
// Add X-Chrome-Connected header to all Gaia requests from a connected profile,
// with the exception of requests from gaia webview. Must be called on IO
// thread.
void AppendMirrorRequestHeaderIfPossible(
net::URLRequest* request,
const GURL& redirect_url,
ProfileIOData* io_data,
int child_id,
int route_id);
// Looks for the X-Chrome-Manage-Accounts response header, and if found,
// tries to show the avatar bubble in the browser identified by the
// child/route id. Must be called on IO thread.
void ProcessMirrorResponseHeaderIfExists(
net::URLRequest* request,
ProfileIOData* io_data,
int child_id,
int route_id);
}; // namespace signin
#endif // CHROME_BROWSER_SIGNIN_SIGNIN_HEADER_HELPER_H_