OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/browser/extensions/api/identity/gaia_web_auth_flow.h" | 5 #include "chrome/browser/extensions/api/identity/gaia_web_auth_flow.h" |
6 | 6 |
7 #include "base/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
8 #include "base/strings/string_split.h" | 8 #include "base/strings/string_split.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 const char kOAuth2RedirectErrorKey[] = "error"; | 106 const char kOAuth2RedirectErrorKey[] = "error"; |
107 const char kOAuth2ExpiresInKey[] = "expires_in"; | 107 const char kOAuth2ExpiresInKey[] = "expires_in"; |
108 | 108 |
109 // The format of the target URL is: | 109 // The format of the target URL is: |
110 // reversed.oauth.client.id:/extensionid#access_token=TOKEN | 110 // reversed.oauth.client.id:/extensionid#access_token=TOKEN |
111 // | 111 // |
112 // Because there is no double slash, everything after the scheme is | 112 // Because there is no double slash, everything after the scheme is |
113 // interpreted as a path, including the fragment. | 113 // interpreted as a path, including the fragment. |
114 | 114 |
115 if (url.scheme() == redirect_scheme_ && !url.has_host() && !url.has_port() && | 115 if (url.scheme() == redirect_scheme_ && !url.has_host() && !url.has_port() && |
116 StartsWithASCII(url.path(), redirect_path_prefix_, true)) { | 116 StartsWithASCII(url.GetContent(), redirect_path_prefix_, true)) { |
117 web_flow_.release()->DetachDelegateAndDelete(); | 117 web_flow_.release()->DetachDelegateAndDelete(); |
118 | 118 |
119 std::string fragment = | 119 std::string fragment = url.GetContent().substr( |
120 url.path().substr(redirect_path_prefix_.length(), std::string::npos); | 120 redirect_path_prefix_.length(), std::string::npos); |
121 std::vector<std::pair<std::string, std::string> > pairs; | 121 std::vector<std::pair<std::string, std::string> > pairs; |
122 base::SplitStringIntoKeyValuePairs(fragment, '=', '&', &pairs); | 122 base::SplitStringIntoKeyValuePairs(fragment, '=', '&', &pairs); |
123 std::string access_token; | 123 std::string access_token; |
124 std::string error; | 124 std::string error; |
125 std::string expiration; | 125 std::string expiration; |
126 | 126 |
127 for (std::vector<std::pair<std::string, std::string> >::iterator | 127 for (std::vector<std::pair<std::string, std::string> >::iterator |
128 it = pairs.begin(); | 128 it = pairs.begin(); |
129 it != pairs.end(); | 129 it != pairs.end(); |
130 ++it) { | 130 ++it) { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 } | 165 } |
166 } | 166 } |
167 | 167 |
168 scoped_ptr<WebAuthFlow> GaiaWebAuthFlow::CreateWebAuthFlow(GURL url) { | 168 scoped_ptr<WebAuthFlow> GaiaWebAuthFlow::CreateWebAuthFlow(GURL url) { |
169 return scoped_ptr<WebAuthFlow>(new WebAuthFlow(this, | 169 return scoped_ptr<WebAuthFlow>(new WebAuthFlow(this, |
170 profile_, | 170 profile_, |
171 url, | 171 url, |
172 WebAuthFlow::INTERACTIVE)); | 172 WebAuthFlow::INTERACTIVE)); |
173 } | 173 } |
174 | 174 |
175 } // extensions | 175 } // namespace extensions |
OLD | NEW |