OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "extensions/renderer/extension_injection_host.h" | 5 #include "extensions/renderer/extension_injection_host.h" |
6 | 6 |
7 #include "content/public/renderer/render_frame.h" | 7 #include "content/public/renderer/render_frame.h" |
8 #include "extensions/common/constants.h" | 8 #include "extensions/common/constants.h" |
9 #include "extensions/common/manifest_handlers/csp_info.h" | 9 #include "extensions/common/manifest_handlers/csp_info.h" |
10 #include "extensions/renderer/renderer_extension_registry.h" | 10 #include "extensions/renderer/renderer_extension_registry.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 const std::string& ExtensionInjectionHost::name() const { | 44 const std::string& ExtensionInjectionHost::name() const { |
45 return extension_->name(); | 45 return extension_->name(); |
46 } | 46 } |
47 | 47 |
48 PermissionsData::AccessType ExtensionInjectionHost::CanExecuteOnFrame( | 48 PermissionsData::AccessType ExtensionInjectionHost::CanExecuteOnFrame( |
49 const GURL& document_url, | 49 const GURL& document_url, |
50 content::RenderFrame* render_frame, | 50 content::RenderFrame* render_frame, |
51 int tab_id, | 51 int tab_id, |
52 bool is_declarative) const { | 52 bool is_declarative) const { |
53 blink::WebSecurityOrigin top_frame_security_origin = | 53 blink::WebSecurityOrigin top_frame_security_origin = |
54 render_frame->GetWebFrame()->top()->securityOrigin(); | 54 render_frame->GetWebFrame()->top()->getSecurityOrigin(); |
55 // Only whitelisted extensions may run scripts on another extension's page. | 55 // Only whitelisted extensions may run scripts on another extension's page. |
56 if (top_frame_security_origin.protocol().utf8() == kExtensionScheme && | 56 if (top_frame_security_origin.protocol().utf8() == kExtensionScheme && |
57 top_frame_security_origin.host().utf8() != extension_->id() && | 57 top_frame_security_origin.host().utf8() != extension_->id() && |
58 !PermissionsData::CanExecuteScriptEverywhere(extension_)) | 58 !PermissionsData::CanExecuteScriptEverywhere(extension_)) |
59 return PermissionsData::ACCESS_DENIED; | 59 return PermissionsData::ACCESS_DENIED; |
60 | 60 |
61 // Declarative user scripts use "page access" (from "permissions" section in | 61 // Declarative user scripts use "page access" (from "permissions" section in |
62 // manifest) whereas non-declarative user scripts use custom | 62 // manifest) whereas non-declarative user scripts use custom |
63 // "content script access" logic. | 63 // "content script access" logic. |
64 PermissionsData::AccessType access = PermissionsData::ACCESS_ALLOWED; | 64 PermissionsData::AccessType access = PermissionsData::ACCESS_ALLOWED; |
(...skipping 14 matching lines...) Expand all Loading... |
79 (tab_id == -1 || render_frame->GetWebFrame()->parent())) { | 79 (tab_id == -1 || render_frame->GetWebFrame()->parent())) { |
80 // Note: we don't consider ACCESS_WITHHELD for child frames or for frames | 80 // Note: we don't consider ACCESS_WITHHELD for child frames or for frames |
81 // outside of tabs because there is nowhere to surface a request. | 81 // outside of tabs because there is nowhere to surface a request. |
82 // TODO(devlin): We should ask for permission somehow. crbug.com/491402. | 82 // TODO(devlin): We should ask for permission somehow. crbug.com/491402. |
83 access = PermissionsData::ACCESS_DENIED; | 83 access = PermissionsData::ACCESS_DENIED; |
84 } | 84 } |
85 return access; | 85 return access; |
86 } | 86 } |
87 | 87 |
88 } // namespace extensions | 88 } // namespace extensions |
OLD | NEW |