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

Side by Side Diff: chrome/common/net/gaia/gaia_urls.cc

Issue 10928017: Moving google_apis and GaiaClient to src/google_apis. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to head Created 8 years, 3 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 | « chrome/common/net/gaia/gaia_urls.h ('k') | chrome/common/net/gaia/google_service_auth_error.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/common/net/gaia/gaia_urls.h"
6
7 #include "base/command_line.h"
8 #include "chrome/common/net/gaia/gaia_switches.h"
9 #include "chrome/common/net/google_apis/google_api_keys.h"
10
11 namespace {
12
13 // Gaia service constants
14 const char kDefaultGaiaBaseUrl[] = "accounts.google.com";
15
16 // Gaia service constants
17 const char kDefaultGaiaOAuthBaseUrl[] = "www.google.com";
18
19 const char kCaptchaUrlPrefixSuffix[] = "/";
20 const char kClientLoginUrlSuffix[] = "/ClientLogin";
21 const char kServiceLoginUrlSuffix[] = "/ServiceLogin";
22 const char kIssueAuthTokenUrlSuffix[] = "/IssueAuthToken";
23 const char kGetUserInfoUrlSuffix[] = "/GetUserInfo";
24 const char kTokenAuthUrlSuffix[] = "/TokenAuth";
25 const char kMergeSessionUrlSuffix[] = "/MergeSession";
26
27 const char kOAuthGetAccessTokenUrlSuffix[] = "/OAuthGetAccessToken";
28 const char kOAuthWrapBridgeUrlSuffix[] = "/OAuthWrapBridge";
29 const char kOAuth1LoginUrlSuffix[] = "/OAuthLogin";
30 const char kOAuthRevokeTokenUrlSuffix[] = "/AuthSubRevokeToken";
31
32 // Federated login constants
33 const char kDefaultFederatedLoginHost[] = "www.google.com";
34 const char kDefaultFederatedLoginPath[] = "/accounts";
35 const char kGetOAuthTokenUrlSuffix[] = "/o8/GetOAuthToken";
36
37 const char kClientLoginToOAuth2Url[] =
38 "https://accounts.google.com/o/oauth2/programmatic_auth";
39 const char kOAuth2TokenUrl[] =
40 "https://accounts.google.com/o/oauth2/token";
41 const char kOAuth2IssueTokenUrl[] =
42 "https://www.googleapis.com/oauth2/v2/IssueToken";
43 const char kOAuth1LoginScope[] =
44 "https://www.google.com/accounts/OAuthLogin";
45
46 void GetSwitchValueWithDefault(const char* switch_value,
47 const char* default_value,
48 std::string* output_value) {
49 CommandLine* command_line = CommandLine::ForCurrentProcess();
50 if (command_line->HasSwitch(switch_value)) {
51 *output_value = command_line->GetSwitchValueASCII(switch_value);
52 } else {
53 *output_value = default_value;
54 }
55 }
56
57 } // namespace
58
59 GaiaUrls* GaiaUrls::GetInstance() {
60 return Singleton<GaiaUrls>::get();
61 }
62
63 GaiaUrls::GaiaUrls() {
64 CommandLine* command_line = CommandLine::ForCurrentProcess();
65 std::string host_base;
66 GetSwitchValueWithDefault(switches::kGaiaHost, kDefaultGaiaBaseUrl,
67 &host_base);
68
69 captcha_url_prefix_ = "http://" + host_base + kCaptchaUrlPrefixSuffix;
70 gaia_origin_url_ = "https://" + host_base;
71 std::string gaia_url_base = gaia_origin_url_;
72 if (command_line->HasSwitch(switches::kGaiaUrlPath)) {
73 std::string path =
74 command_line->GetSwitchValueASCII(switches::kGaiaUrlPath);
75 if (!path.empty()) {
76 if (path[0] != '/')
77 gaia_url_base.append("/");
78
79 gaia_url_base.append(path);
80 }
81 }
82
83 client_login_url_ = gaia_url_base + kClientLoginUrlSuffix;
84 service_login_url_ = gaia_url_base + kServiceLoginUrlSuffix;
85 issue_auth_token_url_ = gaia_url_base + kIssueAuthTokenUrlSuffix;
86 get_user_info_url_ = gaia_url_base + kGetUserInfoUrlSuffix;
87 token_auth_url_ = gaia_url_base + kTokenAuthUrlSuffix;
88 merge_session_url_ = gaia_url_base + kMergeSessionUrlSuffix;
89
90 // Federated login is not part of Gaia and has its own endpoints.
91 std::string oauth_host_base;
92 GetSwitchValueWithDefault(switches::kGaiaOAuthHost,
93 kDefaultFederatedLoginHost,
94 &oauth_host_base);
95
96 std::string gaia_oauth_url_base = "https://"+oauth_host_base;
97 if (command_line->HasSwitch(switches::kGaiaOAuthUrlPath)) {
98 std::string path =
99 command_line->GetSwitchValueASCII(switches::kGaiaOAuthUrlPath);
100 if (!path.empty()) {
101 if (path[0] != '/')
102 gaia_oauth_url_base.append("/");
103
104 gaia_oauth_url_base.append(path);
105 }
106 } else {
107 gaia_oauth_url_base.append(kDefaultFederatedLoginPath);
108 }
109 get_oauth_token_url_ = gaia_oauth_url_base +
110 kGetOAuthTokenUrlSuffix;
111
112 oauth_get_access_token_url_ = gaia_url_base +
113 kOAuthGetAccessTokenUrlSuffix;
114 oauth_wrap_bridge_url_ = gaia_url_base + kOAuthWrapBridgeUrlSuffix;
115 oauth_revoke_token_url_ = gaia_url_base + kOAuthRevokeTokenUrlSuffix;
116 oauth1_login_url_ = gaia_url_base + kOAuth1LoginUrlSuffix;
117
118 GetSwitchValueWithDefault(switches::kOAuth1LoginScope,
119 kOAuth1LoginScope,
120 &oauth1_login_scope_);
121
122 // TODO(joaodasilva): these aren't configurable for now, but are managed here
123 // so that users of Gaia URLs don't have to use static constants.
124 // http://crbug.com/97126
125 oauth_user_info_url_ = "https://www.googleapis.com/oauth2/v1/userinfo";
126 oauth_wrap_bridge_user_info_scope_ =
127 "https://www.googleapis.com/auth/userinfo.email";
128 client_oauth_url_ = "https://accounts.google.com/ClientOAuth";
129
130 oauth2_chrome_client_id_ =
131 google_apis::GetOAuth2ClientID(google_apis::CLIENT_MAIN);
132 oauth2_chrome_client_secret_ =
133 google_apis::GetOAuth2ClientSecret(google_apis::CLIENT_MAIN);
134
135 GetSwitchValueWithDefault(switches::kClientLoginToOAuth2Url,
136 kClientLoginToOAuth2Url,
137 &client_login_to_oauth2_url_);
138 GetSwitchValueWithDefault(switches::kOAuth2TokenUrl,
139 kOAuth2TokenUrl,
140 &oauth2_token_url_);
141 GetSwitchValueWithDefault(switches::kOAuth2IssueTokenUrl,
142 kOAuth2IssueTokenUrl,
143 &oauth2_issue_token_url_);
144
145 gaia_login_form_realm_ = "https://accounts.google.com/";
146 }
147
148 GaiaUrls::~GaiaUrls() {
149 }
150
151 const std::string& GaiaUrls::captcha_url_prefix() {
152 return captcha_url_prefix_;
153 }
154
155 const std::string& GaiaUrls::gaia_origin_url() {
156 return gaia_origin_url_;
157 }
158
159 const std::string& GaiaUrls::client_login_url() {
160 return client_login_url_;
161 }
162
163 const std::string& GaiaUrls::service_login_url() {
164 return service_login_url_;
165 }
166
167 const std::string& GaiaUrls::issue_auth_token_url() {
168 return issue_auth_token_url_;
169 }
170
171 const std::string& GaiaUrls::get_user_info_url() {
172 return get_user_info_url_;
173 }
174
175 const std::string& GaiaUrls::token_auth_url() {
176 return token_auth_url_;
177 }
178
179 const std::string& GaiaUrls::merge_session_url() {
180 return merge_session_url_;
181 }
182
183 const std::string& GaiaUrls::get_oauth_token_url() {
184 return get_oauth_token_url_;
185 }
186
187 const std::string& GaiaUrls::oauth_get_access_token_url() {
188 return oauth_get_access_token_url_;
189 }
190
191 const std::string& GaiaUrls::oauth_wrap_bridge_url() {
192 return oauth_wrap_bridge_url_;
193 }
194
195 const std::string& GaiaUrls::oauth_user_info_url() {
196 return oauth_user_info_url_;
197 }
198
199 const std::string& GaiaUrls::oauth_revoke_token_url() {
200 return oauth_revoke_token_url_;
201 }
202
203 const std::string& GaiaUrls::oauth1_login_url() {
204 return oauth1_login_url_;
205 }
206
207 const std::string& GaiaUrls::oauth1_login_scope() {
208 return oauth1_login_scope_;
209 }
210
211 const std::string& GaiaUrls::oauth_wrap_bridge_user_info_scope() {
212 return oauth_wrap_bridge_user_info_scope_;
213 }
214
215 const std::string& GaiaUrls::client_oauth_url() {
216 return client_oauth_url_;
217 }
218
219 const std::string& GaiaUrls::oauth2_chrome_client_id() {
220 return oauth2_chrome_client_id_;
221 }
222
223 const std::string& GaiaUrls::oauth2_chrome_client_secret() {
224 return oauth2_chrome_client_secret_;
225 }
226
227 const std::string& GaiaUrls::client_login_to_oauth2_url() {
228 return client_login_to_oauth2_url_;
229 }
230
231 const std::string& GaiaUrls::oauth2_token_url() {
232 return oauth2_token_url_;
233 }
234
235 const std::string& GaiaUrls::oauth2_issue_token_url() {
236 return oauth2_issue_token_url_;
237 }
238
239
240 const std::string& GaiaUrls::gaia_login_form_realm() {
241 return gaia_login_form_realm_;
242 }
OLDNEW
« no previous file with comments | « chrome/common/net/gaia/gaia_urls.h ('k') | chrome/common/net/gaia/google_service_auth_error.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698