OLD | NEW |
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 "chrome/common/net/gaia/gaia_urls.h" | 5 #include "chrome/common/net/gaia/gaia_urls.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "chrome/common/chrome_switches.h" | 8 #include "chrome/common/chrome_switches.h" |
9 | 9 |
10 namespace { | 10 namespace { |
11 | 11 |
12 const char kDefaultGaiaBaseUrl[] = "www.google.com"; | 12 // Gaia service constants |
| 13 const char kDefaultGaiaBaseUrl[] = "accounts.google.com"; |
13 | 14 |
14 const char kCaptchaUrlPrefixSuffix[] = "/accounts/"; | 15 const char kCaptchaUrlPrefixSuffix[] = "/"; |
15 const char kClientLoginUrlSuffix[] = "/accounts/ClientLogin"; | 16 const char kClientLoginUrlSuffix[] = "/ClientLogin"; |
16 const char kIssueAuthTokenUrlSuffix[] = "/accounts/IssueAuthToken"; | 17 const char kServiceLoginUrlSuffix[] = "/ServiceLogin"; |
17 const char kGetUserInfoUrlSuffix[] = "/accounts/GetUserInfo"; | 18 const char kIssueAuthTokenUrlSuffix[] = "/IssueAuthToken"; |
18 const char kTokenAuthUrlSuffix[] = "/accounts/TokenAuth"; | 19 const char kGetUserInfoUrlSuffix[] = "/GetUserInfo"; |
19 const char kMergeSessionUrlSuffix[] = "/accounts/MergeSession"; | 20 const char kTokenAuthUrlSuffix[] = "/TokenAuth"; |
| 21 const char kMergeSessionUrlSuffix[] = "/MergeSession"; |
20 | 22 |
21 const char kGetOAuthTokenUrlSuffix[] = "/accounts/o8/GetOAuthToken"; | 23 const char kOAuthGetAccessTokenUrlSuffix[] = "/OAuthGetAccessToken"; |
22 const char kOAuthGetAccessTokenUrlSuffix[] = "/accounts/OAuthGetAccessToken"; | 24 const char kOAuthWrapBridgeUrlSuffix[] = "/OAuthWrapBridge"; |
23 const char kOAuthWrapBridgeUrlSuffix[] = "/accounts/OAuthWrapBridge"; | 25 const char kOAuth1LoginUrlSuffix[] = "/OAuthLogin"; |
24 const char kOAuth1LoginUrlSuffix[] = "/accounts/OAuthLogin"; | 26 const char kOAuthRevokeTokenUrlSuffix[] = "/AuthSubRevokeToken"; |
25 const char kOAuthRevokeTokenUrlSuffix[] = "/accounts/AuthSubRevokeToken"; | 27 |
| 28 // Federated login constants |
| 29 const char kDefaultFederatedLoginBaseUrl[] = "https://www.google.com/accounts"; |
| 30 const char kGetOAuthTokenUrlSuffix[] = "/o8/GetOAuthToken"; |
26 | 31 |
27 // OAuth2 client id for Google Chrome which is registered as an | 32 // OAuth2 client id for Google Chrome which is registered as an |
28 // installed application. | 33 // installed application. |
29 static const char kOAuth2ChromeClientId[] = | 34 static const char kOAuth2ChromeClientId[] = |
30 "77185425430.apps.googleusercontent.com"; | 35 "77185425430.apps.googleusercontent.com"; |
31 // For an installed application, client secret is not really a secret since | 36 // For an installed application, client secret is not really a secret since |
32 // it is expected to be embeeded in the application. | 37 // it is expected to be embeeded in the application. |
33 // See documentation at | 38 // See documentation at |
34 // http://code.google.com/apis/accounts/docs/OAuth2InstalledApp.html | 39 // http://code.google.com/apis/accounts/docs/OAuth2InstalledApp.html |
35 static const char kOAuth2ChromeClientSecret[] = | 40 static const char kOAuth2ChromeClientSecret[] = |
36 "OTJgUOQcT7lO7GsGZq2G4IlT"; | 41 "OTJgUOQcT7lO7GsGZq2G4IlT"; |
37 const char kClientLoginToOAuth2Url[] = | 42 const char kClientLoginToOAuth2Url[] = |
38 "https://accounts.google.com/o/oauth2/programmatic_auth"; | 43 "https://accounts.google.com/o/oauth2/programmatic_auth"; |
39 const char kOAuth2TokenUrl[] = | 44 const char kOAuth2TokenUrl[] = |
40 "https://accounts.google.com/o/oauth2/token"; | 45 "https://accounts.google.com/o/oauth2/token"; |
41 const char kOAuth2IssueTokenUrl[] = | 46 const char kOAuth2IssueTokenUrl[] = |
42 "https://www.googleapis.com/oauth2/v2/IssueToken"; | 47 "https://www.googleapis.com/oauth2/v2/IssueToken"; |
| 48 |
43 } // namespacce | 49 } // namespacce |
44 | 50 |
45 GaiaUrls* GaiaUrls::GetInstance() { | 51 GaiaUrls* GaiaUrls::GetInstance() { |
46 return Singleton<GaiaUrls>::get(); | 52 return Singleton<GaiaUrls>::get(); |
47 } | 53 } |
48 | 54 |
49 GaiaUrls::GaiaUrls() { | 55 GaiaUrls::GaiaUrls() { |
50 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 56 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
51 std::string host_base; | 57 std::string host_base; |
52 if (command_line->HasSwitch(switches::kGaiaHost)) { | 58 if (command_line->HasSwitch(switches::kGaiaHost)) { |
53 host_base = command_line->GetSwitchValueASCII(switches::kGaiaHost); | 59 host_base = command_line->GetSwitchValueASCII(switches::kGaiaHost); |
54 } else { | 60 } else { |
55 host_base = kDefaultGaiaBaseUrl; | 61 host_base = kDefaultGaiaBaseUrl; |
56 } | 62 } |
57 | 63 |
58 captcha_url_prefix_ = "http://" + host_base + kCaptchaUrlPrefixSuffix; | 64 captcha_url_prefix_ = "http://" + host_base + kCaptchaUrlPrefixSuffix; |
59 gaia_origin_url_ = "https://" + host_base; | 65 gaia_origin_url_ = "https://" + host_base; |
60 client_login_url_ = gaia_origin_url_ + kClientLoginUrlSuffix; | 66 client_login_url_ = gaia_origin_url_ + kClientLoginUrlSuffix; |
| 67 service_login_url_ = gaia_origin_url_ + kServiceLoginUrlSuffix; |
61 issue_auth_token_url_ = gaia_origin_url_ + kIssueAuthTokenUrlSuffix; | 68 issue_auth_token_url_ = gaia_origin_url_ + kIssueAuthTokenUrlSuffix; |
62 get_user_info_url_ = gaia_origin_url_ + kGetUserInfoUrlSuffix; | 69 get_user_info_url_ = gaia_origin_url_ + kGetUserInfoUrlSuffix; |
63 token_auth_url_ = gaia_origin_url_ + kTokenAuthUrlSuffix; | 70 token_auth_url_ = gaia_origin_url_ + kTokenAuthUrlSuffix; |
64 merge_session_url_ = gaia_origin_url_ + kMergeSessionUrlSuffix; | 71 merge_session_url_ = gaia_origin_url_ + kMergeSessionUrlSuffix; |
65 | 72 |
66 get_oauth_token_url_ = gaia_origin_url_ + kGetOAuthTokenUrlSuffix; | 73 // Federated login is not part of Gaia and has its own endpoints. |
| 74 get_oauth_token_url_ = std::string(kDefaultFederatedLoginBaseUrl) + |
| 75 kGetOAuthTokenUrlSuffix; |
| 76 |
67 oauth_get_access_token_url_ = gaia_origin_url_ + | 77 oauth_get_access_token_url_ = gaia_origin_url_ + |
68 kOAuthGetAccessTokenUrlSuffix; | 78 kOAuthGetAccessTokenUrlSuffix; |
69 oauth_wrap_bridge_url_ = gaia_origin_url_ + kOAuthWrapBridgeUrlSuffix; | 79 oauth_wrap_bridge_url_ = gaia_origin_url_ + kOAuthWrapBridgeUrlSuffix; |
70 oauth_revoke_token_url_ = gaia_origin_url_ + kOAuthRevokeTokenUrlSuffix; | 80 oauth_revoke_token_url_ = gaia_origin_url_ + kOAuthRevokeTokenUrlSuffix; |
71 oauth1_login_url_ = gaia_origin_url_ + kOAuth1LoginUrlSuffix; | 81 oauth1_login_url_ = gaia_origin_url_ + kOAuth1LoginUrlSuffix; |
72 | 82 |
73 // TODO(joaodasilva): these aren't configurable for now, but are managed here | 83 // TODO(joaodasilva): these aren't configurable for now, but are managed here |
74 // so that users of Gaia URLs don't have to use static constants. | 84 // so that users of Gaia URLs don't have to use static constants. |
75 // http://crbug.com/97126 | 85 // http://crbug.com/97126 |
76 oauth1_login_scope_ = "https://www.google.com/accounts/OAuthLogin"; | 86 oauth1_login_scope_ = "https://www.google.com/accounts/OAuthLogin"; |
(...skipping 20 matching lines...) Expand all Loading... |
97 } | 107 } |
98 | 108 |
99 const std::string& GaiaUrls::gaia_origin_url() { | 109 const std::string& GaiaUrls::gaia_origin_url() { |
100 return gaia_origin_url_; | 110 return gaia_origin_url_; |
101 } | 111 } |
102 | 112 |
103 const std::string& GaiaUrls::client_login_url() { | 113 const std::string& GaiaUrls::client_login_url() { |
104 return client_login_url_; | 114 return client_login_url_; |
105 } | 115 } |
106 | 116 |
| 117 const std::string& GaiaUrls::service_login_url() { |
| 118 return service_login_url_; |
| 119 } |
| 120 |
107 const std::string& GaiaUrls::issue_auth_token_url() { | 121 const std::string& GaiaUrls::issue_auth_token_url() { |
108 return issue_auth_token_url_; | 122 return issue_auth_token_url_; |
109 } | 123 } |
110 | 124 |
111 const std::string& GaiaUrls::get_user_info_url() { | 125 const std::string& GaiaUrls::get_user_info_url() { |
112 return get_user_info_url_; | 126 return get_user_info_url_; |
113 } | 127 } |
114 | 128 |
115 const std::string& GaiaUrls::token_auth_url() { | 129 const std::string& GaiaUrls::token_auth_url() { |
116 return token_auth_url_; | 130 return token_auth_url_; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 } | 187 } |
174 | 188 |
175 const std::string& GaiaUrls::oauth2_issue_token_url() { | 189 const std::string& GaiaUrls::oauth2_issue_token_url() { |
176 return oauth2_issue_token_url_; | 190 return oauth2_issue_token_url_; |
177 } | 191 } |
178 | 192 |
179 | 193 |
180 const std::string& GaiaUrls::gaia_login_form_realm() { | 194 const std::string& GaiaUrls::gaia_login_form_realm() { |
181 return gaia_login_form_realm_; | 195 return gaia_login_form_realm_; |
182 } | 196 } |
OLD | NEW |