| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/renderer_permissions_policy_delegate.h" | 5 #include "chrome/renderer/extensions/renderer_permissions_policy_delegate.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "chrome/common/chrome_switches.h" | 8 #include "chrome/common/chrome_switches.h" |
| 9 #include "chrome/common/extensions/extension_constants.h" | 9 #include "chrome/common/extensions/extension_constants.h" |
| 10 #include "extensions/common/extensions_client.h" | 10 #include "extensions/common/extensions_client.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 } | 22 } |
| 23 RendererPermissionsPolicyDelegate::~RendererPermissionsPolicyDelegate() { | 23 RendererPermissionsPolicyDelegate::~RendererPermissionsPolicyDelegate() { |
| 24 PermissionsData::SetPolicyDelegate(NULL); | 24 PermissionsData::SetPolicyDelegate(NULL); |
| 25 } | 25 } |
| 26 | 26 |
| 27 bool RendererPermissionsPolicyDelegate::CanExecuteScriptOnPage( | 27 bool RendererPermissionsPolicyDelegate::CanExecuteScriptOnPage( |
| 28 const Extension* extension, | 28 const Extension* extension, |
| 29 const GURL& document_url, | 29 const GURL& document_url, |
| 30 const GURL& top_document_url, | 30 const GURL& top_document_url, |
| 31 int tab_id, | 31 int tab_id, |
| 32 const UserScript* script, | |
| 33 int process_id, | 32 int process_id, |
| 34 std::string* error) { | 33 std::string* error) { |
| 35 const ExtensionsClient::ScriptingWhitelist& whitelist = | 34 const ExtensionsClient::ScriptingWhitelist& whitelist = |
| 36 ExtensionsClient::Get()->GetScriptingWhitelist(); | 35 ExtensionsClient::Get()->GetScriptingWhitelist(); |
| 37 if (std::find(whitelist.begin(), whitelist.end(), extension->id()) != | 36 if (std::find(whitelist.begin(), whitelist.end(), extension->id()) != |
| 38 whitelist.end()) { | 37 whitelist.end()) { |
| 39 return true; | 38 return true; |
| 40 } | 39 } |
| 41 | 40 |
| 42 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 41 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 43 if (command_line->HasSwitch(::switches::kSigninProcess)) { | 42 if (command_line->HasSwitch(::switches::kSigninProcess)) { |
| 44 if (error) | 43 if (error) |
| 45 *error = errors::kCannotScriptSigninPage; | 44 *error = errors::kCannotScriptSigninPage; |
| 46 return false; | 45 return false; |
| 47 } | 46 } |
| 48 | 47 |
| 49 if (dispatcher_->IsExtensionActive(extension_misc::kWebStoreAppId)) { | 48 if (dispatcher_->IsExtensionActive(extension_misc::kWebStoreAppId)) { |
| 50 if (error) | 49 if (error) |
| 51 *error = errors::kCannotScriptGallery; | 50 *error = errors::kCannotScriptGallery; |
| 52 return false; | 51 return false; |
| 53 } | 52 } |
| 54 | 53 |
| 55 return true; | 54 return true; |
| 56 } | 55 } |
| 57 | 56 |
| 58 } // namespace extensions | 57 } // namespace extensions |
| OLD | NEW |