OLD | NEW |
1 // Copyright (c) 2011 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"; |
| 46 |
41 } // namespacce | 47 } // namespacce |
42 | 48 |
43 GaiaUrls* GaiaUrls::GetInstance() { | 49 GaiaUrls* GaiaUrls::GetInstance() { |
44 return Singleton<GaiaUrls>::get(); | 50 return Singleton<GaiaUrls>::get(); |
45 } | 51 } |
46 | 52 |
47 GaiaUrls::GaiaUrls() { | 53 GaiaUrls::GaiaUrls() { |
48 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 54 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
49 std::string host_base; | 55 std::string host_base; |
50 if (command_line->HasSwitch(switches::kGaiaHost)) { | 56 if (command_line->HasSwitch(switches::kGaiaHost)) { |
51 host_base = command_line->GetSwitchValueASCII(switches::kGaiaHost); | 57 host_base = command_line->GetSwitchValueASCII(switches::kGaiaHost); |
52 } else { | 58 } else { |
53 host_base = kDefaultGaiaBaseUrl; | 59 host_base = kDefaultGaiaBaseUrl; |
54 } | 60 } |
55 | 61 |
56 captcha_url_prefix_ = "http://" + host_base + kCaptchaUrlPrefixSuffix; | 62 captcha_url_prefix_ = "http://" + host_base + kCaptchaUrlPrefixSuffix; |
57 gaia_origin_url_ = "https://" + host_base; | 63 gaia_origin_url_ = "https://" + host_base; |
58 client_login_url_ = gaia_origin_url_ + kClientLoginUrlSuffix; | 64 client_login_url_ = gaia_origin_url_ + kClientLoginUrlSuffix; |
| 65 service_login_url_ = gaia_origin_url_ + kServiceLoginUrlSuffix; |
59 issue_auth_token_url_ = gaia_origin_url_ + kIssueAuthTokenUrlSuffix; | 66 issue_auth_token_url_ = gaia_origin_url_ + kIssueAuthTokenUrlSuffix; |
60 get_user_info_url_ = gaia_origin_url_ + kGetUserInfoUrlSuffix; | 67 get_user_info_url_ = gaia_origin_url_ + kGetUserInfoUrlSuffix; |
61 token_auth_url_ = gaia_origin_url_ + kTokenAuthUrlSuffix; | 68 token_auth_url_ = gaia_origin_url_ + kTokenAuthUrlSuffix; |
62 merge_session_url_ = gaia_origin_url_ + kMergeSessionUrlSuffix; | 69 merge_session_url_ = gaia_origin_url_ + kMergeSessionUrlSuffix; |
63 | 70 |
64 get_oauth_token_url_ = gaia_origin_url_ + kGetOAuthTokenUrlSuffix; | 71 // Federated login is not part of Gaia and has its own endpoints. |
| 72 get_oauth_token_url_ = std::string(kDefaultFederatedLoginBaseUrl) + |
| 73 kGetOAuthTokenUrlSuffix; |
| 74 |
65 oauth_get_access_token_url_ = gaia_origin_url_ + | 75 oauth_get_access_token_url_ = gaia_origin_url_ + |
66 kOAuthGetAccessTokenUrlSuffix; | 76 kOAuthGetAccessTokenUrlSuffix; |
67 oauth_wrap_bridge_url_ = gaia_origin_url_ + kOAuthWrapBridgeUrlSuffix; | 77 oauth_wrap_bridge_url_ = gaia_origin_url_ + kOAuthWrapBridgeUrlSuffix; |
68 oauth_revoke_token_url_ = gaia_origin_url_ + kOAuthRevokeTokenUrlSuffix; | 78 oauth_revoke_token_url_ = gaia_origin_url_ + kOAuthRevokeTokenUrlSuffix; |
69 oauth1_login_url_ = gaia_origin_url_ + kOAuth1LoginUrlSuffix; | 79 oauth1_login_url_ = gaia_origin_url_ + kOAuth1LoginUrlSuffix; |
70 | 80 |
71 // TODO(joaodasilva): these aren't configurable for now, but are managed here | 81 // TODO(joaodasilva): these aren't configurable for now, but are managed here |
72 // so that users of Gaia URLs don't have to use static constants. | 82 // so that users of Gaia URLs don't have to use static constants. |
73 // http://crbug.com/97126 | 83 // http://crbug.com/97126 |
74 oauth1_login_scope_ = "https://www.google.com/accounts/OAuthLogin"; | 84 oauth1_login_scope_ = "https://www.google.com/accounts/OAuthLogin"; |
(...skipping 15 matching lines...) Expand all Loading... |
90 } | 100 } |
91 | 101 |
92 const std::string& GaiaUrls::gaia_origin_url() { | 102 const std::string& GaiaUrls::gaia_origin_url() { |
93 return gaia_origin_url_; | 103 return gaia_origin_url_; |
94 } | 104 } |
95 | 105 |
96 const std::string& GaiaUrls::client_login_url() { | 106 const std::string& GaiaUrls::client_login_url() { |
97 return client_login_url_; | 107 return client_login_url_; |
98 } | 108 } |
99 | 109 |
| 110 const std::string& GaiaUrls::service_login_url() { |
| 111 return service_login_url_; |
| 112 } |
| 113 |
100 const std::string& GaiaUrls::issue_auth_token_url() { | 114 const std::string& GaiaUrls::issue_auth_token_url() { |
101 return issue_auth_token_url_; | 115 return issue_auth_token_url_; |
102 } | 116 } |
103 | 117 |
104 const std::string& GaiaUrls::get_user_info_url() { | 118 const std::string& GaiaUrls::get_user_info_url() { |
105 return get_user_info_url_; | 119 return get_user_info_url_; |
106 } | 120 } |
107 | 121 |
108 const std::string& GaiaUrls::token_auth_url() { | 122 const std::string& GaiaUrls::token_auth_url() { |
109 return token_auth_url_; | 123 return token_auth_url_; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 return oauth2_chrome_client_secret_; | 167 return oauth2_chrome_client_secret_; |
154 } | 168 } |
155 | 169 |
156 const std::string& GaiaUrls::client_login_to_oauth2_url() { | 170 const std::string& GaiaUrls::client_login_to_oauth2_url() { |
157 return client_login_to_oauth2_url_; | 171 return client_login_to_oauth2_url_; |
158 } | 172 } |
159 | 173 |
160 const std::string& GaiaUrls::oauth2_token_url() { | 174 const std::string& GaiaUrls::oauth2_token_url() { |
161 return oauth2_token_url_; | 175 return oauth2_token_url_; |
162 } | 176 } |
OLD | NEW |