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

Side by Side Diff: chrome/browser/extensions/api/identity/gaia_web_auth_flow.cc

Issue 1220963005: Update base::StartsWith calls to new form (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@starts_with
Patch Set: Created 5 years, 5 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
OLDNEW
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 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 const char kOAuth2RedirectErrorKey[] = "error"; 172 const char kOAuth2RedirectErrorKey[] = "error";
173 const char kOAuth2ExpiresInKey[] = "expires_in"; 173 const char kOAuth2ExpiresInKey[] = "expires_in";
174 174
175 // The format of the target URL is: 175 // The format of the target URL is:
176 // reversed.oauth.client.id:/extensionid#access_token=TOKEN 176 // reversed.oauth.client.id:/extensionid#access_token=TOKEN
177 // 177 //
178 // Because there is no double slash, everything after the scheme is 178 // Because there is no double slash, everything after the scheme is
179 // interpreted as a path, including the fragment. 179 // interpreted as a path, including the fragment.
180 180
181 if (url.scheme() == redirect_scheme_ && !url.has_host() && !url.has_port() && 181 if (url.scheme() == redirect_scheme_ && !url.has_host() && !url.has_port() &&
182 base::StartsWithASCII(url.GetContent(), redirect_path_prefix_, true)) { 182 base::StartsWith(url.GetContent(), redirect_path_prefix_,
183 base::CompareCase::SENSITIVE)) {
183 web_flow_.release()->DetachDelegateAndDelete(); 184 web_flow_.release()->DetachDelegateAndDelete();
184 185
185 std::string fragment = url.GetContent().substr( 186 std::string fragment = url.GetContent().substr(
186 redirect_path_prefix_.length(), std::string::npos); 187 redirect_path_prefix_.length(), std::string::npos);
187 base::StringPairs pairs; 188 base::StringPairs pairs;
188 base::SplitStringIntoKeyValuePairs(fragment, '=', '&', &pairs); 189 base::SplitStringIntoKeyValuePairs(fragment, '=', '&', &pairs);
189 std::string access_token; 190 std::string access_token;
190 std::string error; 191 std::string error;
191 std::string expiration; 192 std::string expiration;
192 193
(...skipping 23 matching lines...) Expand all
216 } 217 }
217 } 218 }
218 } 219 }
219 220
220 void GaiaWebAuthFlow::OnAuthFlowTitleChange(const std::string& title) { 221 void GaiaWebAuthFlow::OnAuthFlowTitleChange(const std::string& title) {
221 // On the final page the title will be "Loading <redirect-url>". 222 // On the final page the title will be "Loading <redirect-url>".
222 // Treat it as though we'd really been redirected to <redirect-url>. 223 // Treat it as though we'd really been redirected to <redirect-url>.
223 const char kRedirectPrefix[] = "Loading "; 224 const char kRedirectPrefix[] = "Loading ";
224 std::string prefix(kRedirectPrefix); 225 std::string prefix(kRedirectPrefix);
225 226
226 if (base::StartsWithASCII(title, prefix, true)) { 227 if (base::StartsWith(title, prefix, base::CompareCase::SENSITIVE)) {
227 GURL url(title.substr(prefix.length(), std::string::npos)); 228 GURL url(title.substr(prefix.length(), std::string::npos));
228 if (url.is_valid()) 229 if (url.is_valid())
229 OnAuthFlowURLChange(url); 230 OnAuthFlowURLChange(url);
230 } 231 }
231 } 232 }
232 233
233 scoped_ptr<WebAuthFlow> GaiaWebAuthFlow::CreateWebAuthFlow(GURL url) { 234 scoped_ptr<WebAuthFlow> GaiaWebAuthFlow::CreateWebAuthFlow(GURL url) {
234 return scoped_ptr<WebAuthFlow>(new WebAuthFlow(this, 235 return scoped_ptr<WebAuthFlow>(new WebAuthFlow(this,
235 profile_, 236 profile_,
236 url, 237 url,
237 WebAuthFlow::INTERACTIVE)); 238 WebAuthFlow::INTERACTIVE));
238 } 239 }
239 240
240 } // namespace extensions 241 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698