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

Side by Side Diff: chrome/renderer/extensions/user_script_slave.cc

Issue 7347011: Update URLPatternSet to contain a std::set instead of std::vector. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix windows compile errors. Created 9 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 | Annotate | Revision Log
« no previous file with comments | « chrome/renderer/extensions/extension_dispatcher.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 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/renderer/extensions/user_script_slave.h" 5 #include "chrome/renderer/extensions/user_script_slave.h"
6 6
7 #include <map> 7 #include <map>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 frame->setIsolatedWorldSecurityOrigin( 77 frame->setIsolatedWorldSecurityOrigin(
78 new_id, 78 new_id,
79 WebSecurityOrigin::create(extension->url())); 79 WebSecurityOrigin::create(extension->url()));
80 return new_id; 80 return new_id;
81 } 81 }
82 82
83 // static 83 // static
84 void UserScriptSlave::InitializeIsolatedWorld( 84 void UserScriptSlave::InitializeIsolatedWorld(
85 int isolated_world_id, 85 int isolated_world_id,
86 const Extension* extension) { 86 const Extension* extension) {
87 const URLPatternList& permissions = 87 const URLPatternSet& permissions =
88 extension->GetEffectiveHostPermissions().patterns(); 88 extension->GetEffectiveHostPermissions();
89 for (size_t i = 0; i < permissions.size(); ++i) { 89 for (URLPatternSet::const_iterator i = permissions.begin();
90 i != permissions.end(); ++i) {
90 const char* schemes[] = { 91 const char* schemes[] = {
91 chrome::kHttpScheme, 92 chrome::kHttpScheme,
92 chrome::kHttpsScheme, 93 chrome::kHttpsScheme,
93 chrome::kFileScheme, 94 chrome::kFileScheme,
94 chrome::kChromeUIScheme, 95 chrome::kChromeUIScheme,
95 }; 96 };
96 for (size_t j = 0; j < arraysize(schemes); ++j) { 97 for (size_t j = 0; j < arraysize(schemes); ++j) {
97 if (permissions[i].MatchesScheme(schemes[j])) { 98 if (i->MatchesScheme(schemes[j])) {
98 WebSecurityPolicy::addOriginAccessWhitelistEntry( 99 WebSecurityPolicy::addOriginAccessWhitelistEntry(
99 extension->url(), 100 extension->url(),
100 WebString::fromUTF8(schemes[j]), 101 WebString::fromUTF8(schemes[j]),
101 WebString::fromUTF8(permissions[i].host()), 102 WebString::fromUTF8(i->host()),
102 permissions[i].match_subdomains()); 103 i->match_subdomains());
103 } 104 }
104 } 105 }
105 } 106 }
106 } 107 }
107 108
108 // static 109 // static
109 void UserScriptSlave::RemoveIsolatedWorld(const std::string& extension_id) { 110 void UserScriptSlave::RemoveIsolatedWorld(const std::string& extension_id) {
110 isolated_world_ids_.erase(extension_id); 111 isolated_world_ids_.erase(extension_id);
111 } 112 }
112 113
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 192
192 // Push user styles down into WebCore 193 // Push user styles down into WebCore
193 WebView::removeAllUserContent(); 194 WebView::removeAllUserContent();
194 for (size_t i = 0; i < scripts_.size(); ++i) { 195 for (size_t i = 0; i < scripts_.size(); ++i) {
195 UserScript* script = scripts_[i]; 196 UserScript* script = scripts_[i];
196 if (script->css_scripts().empty()) 197 if (script->css_scripts().empty())
197 continue; 198 continue;
198 199
199 WebVector<WebString> patterns; 200 WebVector<WebString> patterns;
200 std::vector<WebString> temp_patterns; 201 std::vector<WebString> temp_patterns;
201 for (size_t k = 0; k < script->url_patterns().size(); ++k) { 202 const URLPatternSet& url_patterns = script->url_patterns();
202 URLPatternList explicit_patterns = 203 for (URLPatternSet::const_iterator k = url_patterns.begin();
203 script->url_patterns()[k].ConvertToExplicitSchemes(); 204 k != url_patterns.end(); ++k) {
205 URLPatternList explicit_patterns = k->ConvertToExplicitSchemes();
204 for (size_t m = 0; m < explicit_patterns.size(); ++m) { 206 for (size_t m = 0; m < explicit_patterns.size(); ++m) {
205 temp_patterns.push_back(WebString::fromUTF8( 207 temp_patterns.push_back(WebString::fromUTF8(
206 explicit_patterns[m].GetAsString())); 208 explicit_patterns[m].GetAsString()));
207 } 209 }
208 } 210 }
209 patterns.assign(temp_patterns); 211 patterns.assign(temp_patterns);
210 212
211 for (size_t j = 0; j < script->css_scripts().size(); ++j) { 213 for (size_t j = 0; j < script->css_scripts().size(); ++j) {
212 const UserScript::File& file = scripts_[i]->css_scripts()[j]; 214 const UserScript::File& file = scripts_[i]->css_scripts()[j];
213 std::string content = file.GetContent().as_string(); 215 std::string content = file.GetContent().as_string();
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 if (num_scripts) 335 if (num_scripts)
334 UMA_HISTOGRAM_TIMES("Extensions.InjectEnd_Time", timer.Elapsed()); 336 UMA_HISTOGRAM_TIMES("Extensions.InjectEnd_Time", timer.Elapsed());
335 } else if (location == UserScript::DOCUMENT_IDLE) { 337 } else if (location == UserScript::DOCUMENT_IDLE) {
336 UMA_HISTOGRAM_COUNTS_100("Extensions.InjectIdle_ScriptCount", num_scripts); 338 UMA_HISTOGRAM_COUNTS_100("Extensions.InjectIdle_ScriptCount", num_scripts);
337 if (num_scripts) 339 if (num_scripts)
338 UMA_HISTOGRAM_TIMES("Extensions.InjectIdle_Time", timer.Elapsed()); 340 UMA_HISTOGRAM_TIMES("Extensions.InjectIdle_Time", timer.Elapsed());
339 } else { 341 } else {
340 NOTREACHED(); 342 NOTREACHED();
341 } 343 }
342 } 344 }
OLDNEW
« no previous file with comments | « chrome/renderer/extensions/extension_dispatcher.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698