OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // Gaia service constants | 12 const char kDefaultGaiaBaseUrl[] = "www.google.com"; |
13 const char kDefaultGaiaBaseUrl[] = "accounts.google.com"; | |
14 | 13 |
15 const char kCaptchaUrlPrefixSuffix[] = "/"; | 14 const char kCaptchaUrlPrefixSuffix[] = "/accounts/"; |
16 const char kClientLoginUrlSuffix[] = "/ClientLogin"; | 15 const char kClientLoginUrlSuffix[] = "/accounts/ClientLogin"; |
17 const char kServiceLoginUrlSuffix[] = "/ServiceLogin"; | 16 const char kIssueAuthTokenUrlSuffix[] = "/accounts/IssueAuthToken"; |
18 const char kIssueAuthTokenUrlSuffix[] = "/IssueAuthToken"; | 17 const char kGetUserInfoUrlSuffix[] = "/accounts/GetUserInfo"; |
19 const char kGetUserInfoUrlSuffix[] = "/GetUserInfo"; | 18 const char kTokenAuthUrlSuffix[] = "/accounts/TokenAuth"; |
20 const char kTokenAuthUrlSuffix[] = "/TokenAuth"; | 19 const char kMergeSessionUrlSuffix[] = "/accounts/MergeSession"; |
21 const char kMergeSessionUrlSuffix[] = "/MergeSession"; | |
22 | 20 |
23 const char kOAuthGetAccessTokenUrlSuffix[] = "/OAuthGetAccessToken"; | 21 const char kGetOAuthTokenUrlSuffix[] = "/accounts/o8/GetOAuthToken"; |
24 const char kOAuthWrapBridgeUrlSuffix[] = "/OAuthWrapBridge"; | 22 const char kOAuthGetAccessTokenUrlSuffix[] = "/accounts/OAuthGetAccessToken"; |
25 const char kOAuth1LoginUrlSuffix[] = "/OAuthLogin"; | 23 const char kOAuthWrapBridgeUrlSuffix[] = "/accounts/OAuthWrapBridge"; |
26 const char kOAuthRevokeTokenUrlSuffix[] = "/AuthSubRevokeToken"; | 24 const char kOAuth1LoginUrlSuffix[] = "/accounts/OAuthLogin"; |
27 | 25 const char kOAuthRevokeTokenUrlSuffix[] = "/accounts/AuthSubRevokeToken"; |
28 // Federated login constants | |
29 const char kDefaultFederatedLoginBaseUrl[] = "https://www.google.com/accounts"; | |
30 const char kGetOAuthTokenUrlSuffix[] = "/o8/GetOAuthToken"; | |
31 | 26 |
32 // OAuth2 client id for Google Chrome which is registered as an | 27 // OAuth2 client id for Google Chrome which is registered as an |
33 // installed application. | 28 // installed application. |
34 static const char kOAuth2ChromeClientId[] = | 29 static const char kOAuth2ChromeClientId[] = |
35 "77185425430.apps.googleusercontent.com"; | 30 "77185425430.apps.googleusercontent.com"; |
36 // For an installed application, client secret is not really a secret since | 31 // For an installed application, client secret is not really a secret since |
37 // it is expected to be embeeded in the application. | 32 // it is expected to be embeeded in the application. |
38 // See documentation at | 33 // See documentation at |
39 // http://code.google.com/apis/accounts/docs/OAuth2InstalledApp.html | 34 // http://code.google.com/apis/accounts/docs/OAuth2InstalledApp.html |
40 static const char kOAuth2ChromeClientSecret[] = | 35 static const char kOAuth2ChromeClientSecret[] = |
41 "OTJgUOQcT7lO7GsGZq2G4IlT"; | 36 "OTJgUOQcT7lO7GsGZq2G4IlT"; |
42 const char kClientLoginToOAuth2Url[] = | 37 const char kClientLoginToOAuth2Url[] = |
43 "https://accounts.google.com/o/oauth2/programmatic_auth"; | 38 "https://accounts.google.com/o/oauth2/programmatic_auth"; |
44 const char kOAuth2TokenUrl[] = | 39 const char kOAuth2TokenUrl[] = |
45 "https://accounts.google.com/o/oauth2/token"; | 40 "https://accounts.google.com/o/oauth2/token"; |
46 | |
47 } // namespacce | 41 } // namespacce |
48 | 42 |
49 GaiaUrls* GaiaUrls::GetInstance() { | 43 GaiaUrls* GaiaUrls::GetInstance() { |
50 return Singleton<GaiaUrls>::get(); | 44 return Singleton<GaiaUrls>::get(); |
51 } | 45 } |
52 | 46 |
53 GaiaUrls::GaiaUrls() { | 47 GaiaUrls::GaiaUrls() { |
54 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 48 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
55 std::string host_base; | 49 std::string host_base; |
56 if (command_line->HasSwitch(switches::kGaiaHost)) { | 50 if (command_line->HasSwitch(switches::kGaiaHost)) { |
57 host_base = command_line->GetSwitchValueASCII(switches::kGaiaHost); | 51 host_base = command_line->GetSwitchValueASCII(switches::kGaiaHost); |
58 } else { | 52 } else { |
59 host_base = kDefaultGaiaBaseUrl; | 53 host_base = kDefaultGaiaBaseUrl; |
60 } | 54 } |
61 | 55 |
62 captcha_url_prefix_ = "http://" + host_base + kCaptchaUrlPrefixSuffix; | 56 captcha_url_prefix_ = "http://" + host_base + kCaptchaUrlPrefixSuffix; |
63 gaia_origin_url_ = "https://" + host_base; | 57 gaia_origin_url_ = "https://" + host_base; |
64 client_login_url_ = gaia_origin_url_ + kClientLoginUrlSuffix; | 58 client_login_url_ = gaia_origin_url_ + kClientLoginUrlSuffix; |
65 service_login_url_ = gaia_origin_url_ + kServiceLoginUrlSuffix; | |
66 issue_auth_token_url_ = gaia_origin_url_ + kIssueAuthTokenUrlSuffix; | 59 issue_auth_token_url_ = gaia_origin_url_ + kIssueAuthTokenUrlSuffix; |
67 get_user_info_url_ = gaia_origin_url_ + kGetUserInfoUrlSuffix; | 60 get_user_info_url_ = gaia_origin_url_ + kGetUserInfoUrlSuffix; |
68 token_auth_url_ = gaia_origin_url_ + kTokenAuthUrlSuffix; | 61 token_auth_url_ = gaia_origin_url_ + kTokenAuthUrlSuffix; |
69 merge_session_url_ = gaia_origin_url_ + kMergeSessionUrlSuffix; | 62 merge_session_url_ = gaia_origin_url_ + kMergeSessionUrlSuffix; |
70 | 63 |
71 // Federated login is not part of Gaia and has its own endpoints. | 64 get_oauth_token_url_ = gaia_origin_url_ + kGetOAuthTokenUrlSuffix; |
72 get_oauth_token_url_ = std::string(kDefaultFederatedLoginBaseUrl) + | |
73 kGetOAuthTokenUrlSuffix; | |
74 | |
75 oauth_get_access_token_url_ = gaia_origin_url_ + | 65 oauth_get_access_token_url_ = gaia_origin_url_ + |
76 kOAuthGetAccessTokenUrlSuffix; | 66 kOAuthGetAccessTokenUrlSuffix; |
77 oauth_wrap_bridge_url_ = gaia_origin_url_ + kOAuthWrapBridgeUrlSuffix; | 67 oauth_wrap_bridge_url_ = gaia_origin_url_ + kOAuthWrapBridgeUrlSuffix; |
78 oauth_revoke_token_url_ = gaia_origin_url_ + kOAuthRevokeTokenUrlSuffix; | 68 oauth_revoke_token_url_ = gaia_origin_url_ + kOAuthRevokeTokenUrlSuffix; |
79 oauth1_login_url_ = gaia_origin_url_ + kOAuth1LoginUrlSuffix; | 69 oauth1_login_url_ = gaia_origin_url_ + kOAuth1LoginUrlSuffix; |
80 | 70 |
81 // TODO(joaodasilva): these aren't configurable for now, but are managed here | 71 // TODO(joaodasilva): these aren't configurable for now, but are managed here |
82 // so that users of Gaia URLs don't have to use static constants. | 72 // so that users of Gaia URLs don't have to use static constants. |
83 // http://crbug.com/97126 | 73 // http://crbug.com/97126 |
84 oauth1_login_scope_ = "https://www.google.com/accounts/OAuthLogin"; | 74 oauth1_login_scope_ = "https://www.google.com/accounts/OAuthLogin"; |
(...skipping 15 matching lines...) Expand all Loading... |
100 } | 90 } |
101 | 91 |
102 const std::string& GaiaUrls::gaia_origin_url() { | 92 const std::string& GaiaUrls::gaia_origin_url() { |
103 return gaia_origin_url_; | 93 return gaia_origin_url_; |
104 } | 94 } |
105 | 95 |
106 const std::string& GaiaUrls::client_login_url() { | 96 const std::string& GaiaUrls::client_login_url() { |
107 return client_login_url_; | 97 return client_login_url_; |
108 } | 98 } |
109 | 99 |
110 const std::string& GaiaUrls::service_login_url() { | |
111 return service_login_url_; | |
112 } | |
113 | |
114 const std::string& GaiaUrls::issue_auth_token_url() { | 100 const std::string& GaiaUrls::issue_auth_token_url() { |
115 return issue_auth_token_url_; | 101 return issue_auth_token_url_; |
116 } | 102 } |
117 | 103 |
118 const std::string& GaiaUrls::get_user_info_url() { | 104 const std::string& GaiaUrls::get_user_info_url() { |
119 return get_user_info_url_; | 105 return get_user_info_url_; |
120 } | 106 } |
121 | 107 |
122 const std::string& GaiaUrls::token_auth_url() { | 108 const std::string& GaiaUrls::token_auth_url() { |
123 return token_auth_url_; | 109 return token_auth_url_; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 return oauth2_chrome_client_secret_; | 153 return oauth2_chrome_client_secret_; |
168 } | 154 } |
169 | 155 |
170 const std::string& GaiaUrls::client_login_to_oauth2_url() { | 156 const std::string& GaiaUrls::client_login_to_oauth2_url() { |
171 return client_login_to_oauth2_url_; | 157 return client_login_to_oauth2_url_; |
172 } | 158 } |
173 | 159 |
174 const std::string& GaiaUrls::oauth2_token_url() { | 160 const std::string& GaiaUrls::oauth2_token_url() { |
175 return oauth2_token_url_; | 161 return oauth2_token_url_; |
176 } | 162 } |
OLD | NEW |