| OLD | NEW |
| 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 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 | 228 |
| 229 const Extension* extension = extensions_.GetByID(extension_id); | 229 const Extension* extension = extensions_.GetByID(extension_id); |
| 230 if (!extension) | 230 if (!extension) |
| 231 return; | 231 return; |
| 232 | 232 |
| 233 if (is_webkit_initialized_) | 233 if (is_webkit_initialized_) |
| 234 InitHostPermissions(extension); | 234 InitHostPermissions(extension); |
| 235 } | 235 } |
| 236 | 236 |
| 237 void ExtensionDispatcher::InitHostPermissions(const Extension* extension) { | 237 void ExtensionDispatcher::InitHostPermissions(const Extension* extension) { |
| 238 if (extension->HasApiPermission(Extension::kManagementPermission)) { | 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 = extension->host_permissions(); | 246 const URLPatternList& permissions = |
| 247 extension->permission_set()->explicit_hosts().patterns(); |
| 247 for (size_t i = 0; i < permissions.size(); ++i) { | 248 for (size_t i = 0; i < permissions.size(); ++i) { |
| 248 const char* schemes[] = { | 249 const char* schemes[] = { |
| 249 chrome::kHttpScheme, | 250 chrome::kHttpScheme, |
| 250 chrome::kHttpsScheme, | 251 chrome::kHttpsScheme, |
| 251 chrome::kFileScheme, | 252 chrome::kFileScheme, |
| 252 chrome::kChromeUIScheme, | 253 chrome::kChromeUIScheme, |
| 253 }; | 254 }; |
| 254 for (size_t j = 0; j < arraysize(schemes); ++j) { | 255 for (size_t j = 0; j < arraysize(schemes); ++j) { |
| 255 if (permissions[i].MatchesScheme(schemes[j])) { | 256 if (permissions[i].MatchesScheme(schemes[j])) { |
| 256 WebSecurityPolicy::addOriginAccessWhitelistEntry( | 257 WebSecurityPolicy::addOriginAccessWhitelistEntry( |
| (...skipping 23 matching lines...) Expand all Loading... |
| 280 child_process_logging::SetActiveExtensions(active_extensions); | 281 child_process_logging::SetActiveExtensions(active_extensions); |
| 281 } | 282 } |
| 282 | 283 |
| 283 void ExtensionDispatcher::RegisterExtension(v8::Extension* extension, | 284 void ExtensionDispatcher::RegisterExtension(v8::Extension* extension, |
| 284 bool restrict_to_extensions) { | 285 bool restrict_to_extensions) { |
| 285 if (restrict_to_extensions) | 286 if (restrict_to_extensions) |
| 286 restricted_v8_extensions_.insert(extension->name()); | 287 restricted_v8_extensions_.insert(extension->name()); |
| 287 | 288 |
| 288 RenderThread::current()->RegisterExtension(extension); | 289 RenderThread::current()->RegisterExtension(extension); |
| 289 } | 290 } |
| OLD | NEW |