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

Side by Side Diff: content/browser/service_worker/service_worker_utils.cc

Issue 1172183002: Move StartsWith[ASCII] to base namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@string_util3
Patch Set: merger Created 5 years, 6 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "content/browser/service_worker/service_worker_utils.h" 5 #include "content/browser/service_worker/service_worker_utils.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 18 matching lines...) Expand all
29 } 29 }
30 return false; 30 return false;
31 } 31 }
32 32
33 } // namespace 33 } // namespace
34 34
35 // static 35 // static
36 bool ServiceWorkerUtils::ScopeMatches(const GURL& scope, const GURL& url) { 36 bool ServiceWorkerUtils::ScopeMatches(const GURL& scope, const GURL& url) {
37 DCHECK(!scope.has_ref()); 37 DCHECK(!scope.has_ref());
38 DCHECK(!url.has_ref()); 38 DCHECK(!url.has_ref());
39 return StartsWithASCII(url.spec(), scope.spec(), true); 39 return base::StartsWithASCII(url.spec(), scope.spec(), true);
40 } 40 }
41 41
42 // static 42 // static
43 bool ServiceWorkerUtils::IsPathRestrictionSatisfied( 43 bool ServiceWorkerUtils::IsPathRestrictionSatisfied(
44 const GURL& scope, 44 const GURL& scope,
45 const GURL& script_url, 45 const GURL& script_url,
46 const std::string* service_worker_allowed_header_value, 46 const std::string* service_worker_allowed_header_value,
47 std::string* error_message) { 47 std::string* error_message) {
48 DCHECK(scope.is_valid()); 48 DCHECK(scope.is_valid());
49 DCHECK(!scope.has_ref()); 49 DCHECK(!scope.has_ref());
(...skipping 12 matching lines...) Expand all
62 error_message->append(*service_worker_allowed_header_value); 62 error_message->append(*service_worker_allowed_header_value);
63 error_message->append("') was received when fetching the script."); 63 error_message->append("') was received when fetching the script.");
64 return false; 64 return false;
65 } 65 }
66 max_scope_string = max_scope.path(); 66 max_scope_string = max_scope.path();
67 } else { 67 } else {
68 max_scope_string = script_url.Resolve(".").path(); 68 max_scope_string = script_url.Resolve(".").path();
69 } 69 }
70 70
71 std::string scope_string = scope.path(); 71 std::string scope_string = scope.path();
72 if (!StartsWithASCII(scope_string, max_scope_string, true)) { 72 if (!base::StartsWithASCII(scope_string, max_scope_string, true)) {
73 *error_message = "The path of the provided scope ('"; 73 *error_message = "The path of the provided scope ('";
74 error_message->append(scope_string); 74 error_message->append(scope_string);
75 error_message->append("') is not under the max scope allowed ("); 75 error_message->append("') is not under the max scope allowed (");
76 if (service_worker_allowed_header_value) 76 if (service_worker_allowed_header_value)
77 error_message->append("set by Service-Worker-Allowed: "); 77 error_message->append("set by Service-Worker-Allowed: ");
78 error_message->append("'"); 78 error_message->append("'");
79 error_message->append(max_scope_string); 79 error_message->append(max_scope_string);
80 error_message->append( 80 error_message->append(
81 "'). Adjust the scope, move the Service Worker script, or use the " 81 "'). Adjust the scope, move the Service Worker script, or use the "
82 "Service-Worker-Allowed HTTP header to allow the scope."); 82 "Service-Worker-Allowed HTTP header to allow the scope.");
(...skipping 23 matching lines...) Expand all
106 if (!ServiceWorkerUtils::ScopeMatches(scope, url_)) 106 if (!ServiceWorkerUtils::ScopeMatches(scope, url_))
107 return false; 107 return false;
108 if (match_.is_empty() || match_.spec().size() < scope.spec().size()) { 108 if (match_.is_empty() || match_.spec().size() < scope.spec().size()) {
109 match_ = scope; 109 match_ = scope;
110 return true; 110 return true;
111 } 111 }
112 return false; 112 return false;
113 } 113 }
114 114
115 } // namespace content 115 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/service_worker/service_worker_database.cc ('k') | content/browser/session_history_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698