| 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 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 | 215 |
| 216 const Extension* extension = extensions_.GetByID(extension_id); | 216 const Extension* extension = extensions_.GetByID(extension_id); |
| 217 if (!extension) | 217 if (!extension) |
| 218 return; | 218 return; |
| 219 | 219 |
| 220 if (is_webkit_initialized_) | 220 if (is_webkit_initialized_) |
| 221 InitHostPermissions(extension); | 221 InitHostPermissions(extension); |
| 222 } | 222 } |
| 223 | 223 |
| 224 void ExtensionDispatcher::InitHostPermissions(const Extension* extension) { | 224 void ExtensionDispatcher::InitHostPermissions(const Extension* extension) { |
| 225 if (extension->HasApiPermission(Extension::kManagementPermission)) { | 225 if (extension->HasApiPermission(ExtensionAPIPermission::kManagement)) { |
| 226 WebSecurityPolicy::addOriginAccessWhitelistEntry( | 226 WebSecurityPolicy::addOriginAccessWhitelistEntry( |
| 227 extension->url(), | 227 extension->url(), |
| 228 WebString::fromUTF8(chrome::kChromeUIScheme), | 228 WebString::fromUTF8(chrome::kChromeUIScheme), |
| 229 WebString::fromUTF8(chrome::kChromeUIExtensionIconHost), | 229 WebString::fromUTF8(chrome::kChromeUIExtensionIconHost), |
| 230 false); | 230 false); |
| 231 } | 231 } |
| 232 | 232 |
| 233 const URLPatternList& permissions = extension->host_permissions(); | 233 const URLPatternList& permissions = |
| 234 extension->permission_set()->explicit_hosts().patterns(); |
| 234 for (size_t i = 0; i < permissions.size(); ++i) { | 235 for (size_t i = 0; i < permissions.size(); ++i) { |
| 235 const char* schemes[] = { | 236 const char* schemes[] = { |
| 236 chrome::kHttpScheme, | 237 chrome::kHttpScheme, |
| 237 chrome::kHttpsScheme, | 238 chrome::kHttpsScheme, |
| 238 chrome::kFileScheme, | 239 chrome::kFileScheme, |
| 239 chrome::kChromeUIScheme, | 240 chrome::kChromeUIScheme, |
| 240 }; | 241 }; |
| 241 for (size_t j = 0; j < arraysize(schemes); ++j) { | 242 for (size_t j = 0; j < arraysize(schemes); ++j) { |
| 242 if (permissions[i].MatchesScheme(schemes[j])) { | 243 if (permissions[i].MatchesScheme(schemes[j])) { |
| 243 WebSecurityPolicy::addOriginAccessWhitelistEntry( | 244 WebSecurityPolicy::addOriginAccessWhitelistEntry( |
| (...skipping 23 matching lines...) Expand all Loading... |
| 267 child_process_logging::SetActiveExtensions(active_extensions); | 268 child_process_logging::SetActiveExtensions(active_extensions); |
| 268 } | 269 } |
| 269 | 270 |
| 270 void ExtensionDispatcher::RegisterExtension(v8::Extension* extension, | 271 void ExtensionDispatcher::RegisterExtension(v8::Extension* extension, |
| 271 bool restrict_to_extensions) { | 272 bool restrict_to_extensions) { |
| 272 if (restrict_to_extensions) | 273 if (restrict_to_extensions) |
| 273 restricted_v8_extensions_.insert(extension->name()); | 274 restricted_v8_extensions_.insert(extension->name()); |
| 274 | 275 |
| 275 RenderThread::current()->RegisterExtension(extension); | 276 RenderThread::current()->RegisterExtension(extension); |
| 276 } | 277 } |
| OLD | NEW |