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

Side by Side Diff: chrome/renderer/extensions/extension_dispatcher.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
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/extension_dispatcher.h" 5 #include "chrome/renderer/extensions/extension_dispatcher.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "chrome/common/child_process_logging.h" 8 #include "chrome/common/child_process_logging.h"
9 #include "chrome/common/chrome_switches.h" 9 #include "chrome/common/chrome_switches.h"
10 #include "chrome/common/extensions/extension.h" 10 #include "chrome/common/extensions/extension.h"
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 236
237 void ExtensionDispatcher::InitHostPermissions(const Extension* extension) { 237 void ExtensionDispatcher::InitHostPermissions(const Extension* extension) {
238 if (extension->HasAPIPermission(ExtensionAPIPermission::kManagement)) { 238 if (extension->HasAPIPermission(ExtensionAPIPermission::kManagement)) {
239 WebSecurityPolicy::addOriginAccessWhitelistEntry( 239 WebSecurityPolicy::addOriginAccessWhitelistEntry(
240 extension->url(), 240 extension->url(),
241 WebString::fromUTF8(chrome::kChromeUIScheme), 241 WebString::fromUTF8(chrome::kChromeUIScheme),
242 WebString::fromUTF8(chrome::kChromeUIExtensionIconHost), 242 WebString::fromUTF8(chrome::kChromeUIExtensionIconHost),
243 false); 243 false);
244 } 244 }
245 245
246 const URLPatternList& permissions = 246 const URLPatternSet& permissions =
247 extension->permission_set()->explicit_hosts().patterns(); 247 extension->permission_set()->explicit_hosts();
248 for (size_t i = 0; i < permissions.size(); ++i) { 248 for (URLPatternSet::const_iterator i = permissions.begin();
249 i != permissions.end(); ++i) {
249 const char* schemes[] = { 250 const char* schemes[] = {
250 chrome::kHttpScheme, 251 chrome::kHttpScheme,
251 chrome::kHttpsScheme, 252 chrome::kHttpsScheme,
252 chrome::kFileScheme, 253 chrome::kFileScheme,
253 chrome::kChromeUIScheme, 254 chrome::kChromeUIScheme,
254 }; 255 };
255 for (size_t j = 0; j < arraysize(schemes); ++j) { 256 for (size_t j = 0; j < arraysize(schemes); ++j) {
256 if (permissions[i].MatchesScheme(schemes[j])) { 257 if (i->MatchesScheme(schemes[j])) {
257 WebSecurityPolicy::addOriginAccessWhitelistEntry( 258 WebSecurityPolicy::addOriginAccessWhitelistEntry(
258 extension->url(), 259 extension->url(),
259 WebString::fromUTF8(schemes[j]), 260 WebString::fromUTF8(schemes[j]),
260 WebString::fromUTF8(permissions[i].host()), 261 WebString::fromUTF8(i->host()),
261 permissions[i].match_subdomains()); 262 i->match_subdomains());
262 } 263 }
263 } 264 }
264 } 265 }
265 } 266 }
266 267
267 void ExtensionDispatcher::OnUpdateUserScripts( 268 void ExtensionDispatcher::OnUpdateUserScripts(
268 base::SharedMemoryHandle scripts) { 269 base::SharedMemoryHandle scripts) {
269 DCHECK(base::SharedMemory::IsHandleValid(scripts)) << "Bad scripts handle"; 270 DCHECK(base::SharedMemory::IsHandleValid(scripts)) << "Bad scripts handle";
270 user_script_slave_->UpdateScripts(scripts); 271 user_script_slave_->UpdateScripts(scripts);
271 UpdateActiveExtensions(); 272 UpdateActiveExtensions();
272 } 273 }
273 274
274 void ExtensionDispatcher::UpdateActiveExtensions() { 275 void ExtensionDispatcher::UpdateActiveExtensions() {
275 // In single-process mode, the browser process reports the active extensions. 276 // In single-process mode, the browser process reports the active extensions.
276 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess)) 277 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess))
277 return; 278 return;
278 279
279 std::set<std::string> active_extensions = active_extension_ids_; 280 std::set<std::string> active_extensions = active_extension_ids_;
280 user_script_slave_->GetActiveExtensions(&active_extensions); 281 user_script_slave_->GetActiveExtensions(&active_extensions);
281 child_process_logging::SetActiveExtensions(active_extensions); 282 child_process_logging::SetActiveExtensions(active_extensions);
282 } 283 }
283 284
284 void ExtensionDispatcher::RegisterExtension(v8::Extension* extension, 285 void ExtensionDispatcher::RegisterExtension(v8::Extension* extension,
285 bool restrict_to_extensions) { 286 bool restrict_to_extensions) {
286 if (restrict_to_extensions) 287 if (restrict_to_extensions)
287 restricted_v8_extensions_.insert(extension->name()); 288 restricted_v8_extensions_.insert(extension->name());
288 289
289 RenderThread::current()->RegisterExtension(extension); 290 RenderThread::current()->RegisterExtension(extension);
290 } 291 }
OLDNEW
« no previous file with comments | « chrome/common/extensions/user_script_unittest.cc ('k') | chrome/renderer/extensions/user_script_slave.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698