Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(637)

Side by Side Diff: google_apis/gaia/gaia_urls.cc

Issue 11786006: Added flags to override hosts for LSO URLs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « google_apis/gaia/gaia_urls.h ('k') | net/url_request/url_fetcher_core.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "google_apis/gaia/gaia_urls.h" 5 #include "google_apis/gaia/gaia_urls.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "google_apis/gaia/gaia_switches.h" 8 #include "google_apis/gaia/gaia_switches.h"
9 #include "google_apis/google_api_keys.h" 9 #include "google_apis/google_api_keys.h"
10 10
11 namespace { 11 namespace {
12 12
13 // Gaia service constants 13 // Gaia service constants
14 const char kDefaultGaiaBaseUrl[] = "accounts.google.com"; 14 const char kDefaultGaiaBaseUrl[] = "accounts.google.com";
15 const char kDefaultGoogleApisBaseUrl[] = "www.googleapis.com";
15 const char kCaptchaUrlPrefixSuffix[] = "/"; 16 const char kCaptchaUrlPrefixSuffix[] = "/";
17
18 // API calls from accounts.google.com
16 const char kClientLoginUrlSuffix[] = "/ClientLogin"; 19 const char kClientLoginUrlSuffix[] = "/ClientLogin";
17 const char kServiceLoginUrlSuffix[] = "/ServiceLogin"; 20 const char kServiceLoginUrlSuffix[] = "/ServiceLogin";
18 const char kIssueAuthTokenUrlSuffix[] = "/IssueAuthToken"; 21 const char kIssueAuthTokenUrlSuffix[] = "/IssueAuthToken";
19 const char kGetUserInfoUrlSuffix[] = "/GetUserInfo"; 22 const char kGetUserInfoUrlSuffix[] = "/GetUserInfo";
20 const char kTokenAuthUrlSuffix[] = "/TokenAuth"; 23 const char kTokenAuthUrlSuffix[] = "/TokenAuth";
21 const char kMergeSessionUrlSuffix[] = "/MergeSession"; 24 const char kMergeSessionUrlSuffix[] = "/MergeSession";
22
23 const char kOAuthGetAccessTokenUrlSuffix[] = "/OAuthGetAccessToken"; 25 const char kOAuthGetAccessTokenUrlSuffix[] = "/OAuthGetAccessToken";
24 const char kOAuthWrapBridgeUrlSuffix[] = "/OAuthWrapBridge"; 26 const char kOAuthWrapBridgeUrlSuffix[] = "/OAuthWrapBridge";
25 const char kOAuth1LoginUrlSuffix[] = "/OAuthLogin"; 27 const char kOAuth1LoginUrlSuffix[] = "/OAuthLogin";
26 const char kOAuthRevokeTokenUrlSuffix[] = "/AuthSubRevokeToken"; 28 const char kOAuthRevokeTokenUrlSuffix[] = "/AuthSubRevokeToken";
27 29
28 // Federated login constants 30 // API calls from accounts.google.com (LSO)
29 const char kDefaultFederatedLoginHost[] = "www.google.com";
30 const char kDefaultFederatedLoginPath[] = "/accounts";
31 const char kGetOAuthTokenUrlSuffix[] = "/o/oauth/GetOAuthToken/"; 31 const char kGetOAuthTokenUrlSuffix[] = "/o/oauth/GetOAuthToken/";
32 const char kClientLoginToOAuth2UrlSuffix[] = "/o/oauth2/programmatic_auth";
33 const char kOAuth2TokenUrlSuffix[] = "/o/oauth2/token";
34 const char kClientOAuthUrlSuffix[] = "/ClientOAuth";
32 35
33 const char kClientLoginToOAuth2Url[] = 36 // API calls from www.googleapis.com
34 "https://accounts.google.com/o/oauth2/programmatic_auth"; 37 const char kOAuth2IssueTokenUrlSuffix[] = "/oauth2/v2/IssueToken";
35 const char kOAuth2TokenUrl[] = 38 const char kOAuthUserInfoUrlSuffix[] = "/oauth2/v1/userinfo";
36 "https://accounts.google.com/o/oauth2/token"; 39 const char kOAuthWrapBridgeUserInfoScopeUrlSuffix[] = "/auth/userinfo.email";
37 const char kOAuth2IssueTokenUrl[] = 40
38 "https://www.googleapis.com/oauth2/v2/IssueToken";
39 const char kOAuth1LoginScope[] = 41 const char kOAuth1LoginScope[] =
40 "https://www.google.com/accounts/OAuthLogin"; 42 "https://www.google.com/accounts/OAuthLogin";
41 const char kOAuthUserInfoUrl[] =
42 "https://www.googleapis.com/oauth2/v1/userinfo";
43
44 43
45 void GetSwitchValueWithDefault(const char* switch_value, 44 void GetSwitchValueWithDefault(const char* switch_value,
46 const char* default_value, 45 const char* default_value,
47 std::string* output_value) { 46 std::string* output_value) {
48 CommandLine* command_line = CommandLine::ForCurrentProcess(); 47 CommandLine* command_line = CommandLine::ForCurrentProcess();
49 if (command_line->HasSwitch(switch_value)) { 48 if (command_line->HasSwitch(switch_value)) {
50 *output_value = command_line->GetSwitchValueASCII(switch_value); 49 *output_value = command_line->GetSwitchValueASCII(switch_value);
51 } else { 50 } else {
52 *output_value = default_value; 51 *output_value = default_value;
53 } 52 }
54 } 53 }
55 54
56 } // namespace 55 } // namespace
57 56
58 GaiaUrls* GaiaUrls::GetInstance() { 57 GaiaUrls* GaiaUrls::GetInstance() {
59 return Singleton<GaiaUrls>::get(); 58 return Singleton<GaiaUrls>::get();
60 } 59 }
61 60
62 GaiaUrls::GaiaUrls() { 61 GaiaUrls::GaiaUrls() {
63 CommandLine* command_line = CommandLine::ForCurrentProcess(); 62 CommandLine* command_line = CommandLine::ForCurrentProcess();
64 std::string host_base; 63 std::string host_base;
65 GetSwitchValueWithDefault(switches::kGaiaHost, kDefaultGaiaBaseUrl, 64 GetSwitchValueWithDefault(switches::kGaiaHost, kDefaultGaiaBaseUrl,
66 &host_base); 65 &host_base);
67 66
67 std::string lso_base;
68 GetSwitchValueWithDefault(switches::kLsoHost, kDefaultGaiaBaseUrl,
69 &lso_base);
70
71 std::string google_apis_base;
72 GetSwitchValueWithDefault(switches::kGoogleApisHost,
73 kDefaultGoogleApisBaseUrl,
74 &google_apis_base);
75
68 captcha_url_prefix_ = "http://" + host_base + kCaptchaUrlPrefixSuffix; 76 captcha_url_prefix_ = "http://" + host_base + kCaptchaUrlPrefixSuffix;
69 gaia_origin_url_ = "https://" + host_base; 77 gaia_origin_url_ = "https://" + host_base;
78 lso_origin_url_ = "https://" + lso_base;
79 google_apis_origin_url_ = "https://" + google_apis_base;
70 std::string gaia_url_base = gaia_origin_url_; 80 std::string gaia_url_base = gaia_origin_url_;
71 if (command_line->HasSwitch(switches::kGaiaUrlPath)) { 81 if (command_line->HasSwitch(switches::kGaiaUrlPath)) {
72 std::string path = 82 std::string path =
73 command_line->GetSwitchValueASCII(switches::kGaiaUrlPath); 83 command_line->GetSwitchValueASCII(switches::kGaiaUrlPath);
74 if (!path.empty()) { 84 if (!path.empty()) {
75 if (path[0] != '/') 85 if (path[0] != '/')
76 gaia_url_base.append("/"); 86 gaia_url_base.append("/");
77 87
78 gaia_url_base.append(path); 88 gaia_url_base.append(path);
79 } 89 }
80 } 90 }
81 91
92
93 oauth2_chrome_client_id_ =
94 google_apis::GetOAuth2ClientID(google_apis::CLIENT_MAIN);
95 oauth2_chrome_client_secret_ =
96 google_apis::GetOAuth2ClientSecret(google_apis::CLIENT_MAIN);
97
98 // URLs from accounts.google.com.
99 gaia_login_form_realm_ = gaia_url_base + "/";
82 client_login_url_ = gaia_url_base + kClientLoginUrlSuffix; 100 client_login_url_ = gaia_url_base + kClientLoginUrlSuffix;
83 service_login_url_ = gaia_url_base + kServiceLoginUrlSuffix; 101 service_login_url_ = gaia_url_base + kServiceLoginUrlSuffix;
84 issue_auth_token_url_ = gaia_url_base + kIssueAuthTokenUrlSuffix; 102 issue_auth_token_url_ = gaia_url_base + kIssueAuthTokenUrlSuffix;
85 get_user_info_url_ = gaia_url_base + kGetUserInfoUrlSuffix; 103 get_user_info_url_ = gaia_url_base + kGetUserInfoUrlSuffix;
86 token_auth_url_ = gaia_url_base + kTokenAuthUrlSuffix; 104 token_auth_url_ = gaia_url_base + kTokenAuthUrlSuffix;
87 merge_session_url_ = gaia_url_base + kMergeSessionUrlSuffix; 105 merge_session_url_ = gaia_url_base + kMergeSessionUrlSuffix;
88 get_oauth_token_url_ = gaia_url_base + kGetOAuthTokenUrlSuffix;
89 oauth_get_access_token_url_ = gaia_url_base + 106 oauth_get_access_token_url_ = gaia_url_base +
90 kOAuthGetAccessTokenUrlSuffix; 107 kOAuthGetAccessTokenUrlSuffix;
91 oauth_wrap_bridge_url_ = gaia_url_base + kOAuthWrapBridgeUrlSuffix; 108 oauth_wrap_bridge_url_ = gaia_url_base + kOAuthWrapBridgeUrlSuffix;
92 oauth_revoke_token_url_ = gaia_url_base + kOAuthRevokeTokenUrlSuffix; 109 oauth_revoke_token_url_ = gaia_url_base + kOAuthRevokeTokenUrlSuffix;
93 oauth1_login_url_ = gaia_url_base + kOAuth1LoginUrlSuffix; 110 oauth1_login_url_ = gaia_url_base + kOAuth1LoginUrlSuffix;
111 client_oauth_url_ = gaia_url_base + kClientOAuthUrlSuffix;
94 112
113 // URLs from accounts.google.com (LSO).
114 get_oauth_token_url_ = lso_origin_url_ + kGetOAuthTokenUrlSuffix;
115 std::string client_login_to_oauth2_url = lso_origin_url_ +
116 kClientLoginToOAuth2UrlSuffix;
117 std::string oauth2_token_url = lso_origin_url_ + kOAuth2TokenUrlSuffix;
118
119 // URLs from www.googleapis.com.
120 oauth_wrap_bridge_user_info_scope_ = google_apis_origin_url_ +
121 kOAuthWrapBridgeUserInfoScopeUrlSuffix;
122 std::string oauth2_issue_token_url = google_apis_origin_url_ +
123 kOAuth2IssueTokenUrlSuffix;
124 std::string oauth_user_info_url = google_apis_origin_url_ +
125 kOAuthUserInfoUrlSuffix;
126
127 // TODO(zelidrag): Get rid of all these switches since all URLs should be
128 // controlled only with --gaia-host, --lso-host and --google-apis-host.
95 GetSwitchValueWithDefault(switches::kOAuth1LoginScope, 129 GetSwitchValueWithDefault(switches::kOAuth1LoginScope,
96 kOAuth1LoginScope, 130 kOAuth1LoginScope,
97 &oauth1_login_scope_); 131 &oauth1_login_scope_);
98
99 // TODO(joaodasilva): these aren't configurable for now, but are managed here
100 // so that users of Gaia URLs don't have to use static constants.
101 // http://crbug.com/97126
102 oauth_wrap_bridge_user_info_scope_ =
103 "https://www.googleapis.com/auth/userinfo.email";
104 client_oauth_url_ = "https://accounts.google.com/ClientOAuth";
105
106 oauth2_chrome_client_id_ =
107 google_apis::GetOAuth2ClientID(google_apis::CLIENT_MAIN);
108 oauth2_chrome_client_secret_ =
109 google_apis::GetOAuth2ClientSecret(google_apis::CLIENT_MAIN);
110
111 GetSwitchValueWithDefault(switches::kClientLoginToOAuth2Url, 132 GetSwitchValueWithDefault(switches::kClientLoginToOAuth2Url,
112 kClientLoginToOAuth2Url, 133 client_login_to_oauth2_url.c_str(),
113 &client_login_to_oauth2_url_); 134 &client_login_to_oauth2_url_);
114 GetSwitchValueWithDefault(switches::kOAuth2TokenUrl, 135 GetSwitchValueWithDefault(switches::kOAuth2TokenUrl,
115 kOAuth2TokenUrl, 136 oauth2_token_url.c_str(),
116 &oauth2_token_url_); 137 &oauth2_token_url_);
117 GetSwitchValueWithDefault(switches::kOAuth2IssueTokenUrl, 138 GetSwitchValueWithDefault(switches::kOAuth2IssueTokenUrl,
118 kOAuth2IssueTokenUrl, 139 oauth2_issue_token_url.c_str(),
119 &oauth2_issue_token_url_); 140 &oauth2_issue_token_url_);
120 GetSwitchValueWithDefault(switches::kOAuthUserInfoUrl, 141 GetSwitchValueWithDefault(switches::kOAuthUserInfoUrl,
121 kOAuthUserInfoUrl, 142 oauth_user_info_url.c_str(),
122 &oauth_user_info_url_); 143 &oauth_user_info_url_);
123
124 gaia_login_form_realm_ = "https://accounts.google.com/";
125 } 144 }
126 145
127 GaiaUrls::~GaiaUrls() { 146 GaiaUrls::~GaiaUrls() {
128 } 147 }
129 148
130 const std::string& GaiaUrls::captcha_url_prefix() { 149 const std::string& GaiaUrls::captcha_url_prefix() {
131 return captcha_url_prefix_; 150 return captcha_url_prefix_;
132 } 151 }
133 152
134 const std::string& GaiaUrls::gaia_origin_url() { 153 const std::string& GaiaUrls::gaia_origin_url() {
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 } 231 }
213 232
214 const std::string& GaiaUrls::oauth2_issue_token_url() { 233 const std::string& GaiaUrls::oauth2_issue_token_url() {
215 return oauth2_issue_token_url_; 234 return oauth2_issue_token_url_;
216 } 235 }
217 236
218 237
219 const std::string& GaiaUrls::gaia_login_form_realm() { 238 const std::string& GaiaUrls::gaia_login_form_realm() {
220 return gaia_login_form_realm_; 239 return gaia_login_form_realm_;
221 } 240 }
OLDNEW
« no previous file with comments | « google_apis/gaia/gaia_urls.h ('k') | net/url_request/url_fetcher_core.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698