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

Unified Diff: extensions/renderer/script_context.cc

Issue 498513002: Respect the clipboardRead and clipboardWrite permissions in content scripts. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address more comments Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « extensions/renderer/script_context.h ('k') | extensions/renderer/script_context_set_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/renderer/script_context.cc
diff --git a/extensions/renderer/script_context.cc b/extensions/renderer/script_context.cc
index a1af29591c3b6f497d9222a6e68e21d8995d9366..0eb4222f711b93b95694d35bcf8a3d503730498e 100644
--- a/extensions/renderer/script_context.cc
+++ b/extensions/renderer/script_context.cc
@@ -30,27 +30,62 @@ using content::V8ValueConverter;
namespace extensions {
+namespace {
+
+std::string GetContextTypeDescriptionString(Feature::Context context_type) {
+ switch (context_type) {
+ case Feature::UNSPECIFIED_CONTEXT:
+ return "UNSPECIFIED";
+ case Feature::BLESSED_EXTENSION_CONTEXT:
+ return "BLESSED_EXTENSION";
+ case Feature::UNBLESSED_EXTENSION_CONTEXT:
+ return "UNBLESSED_EXTENSION";
+ case Feature::CONTENT_SCRIPT_CONTEXT:
+ return "CONTENT_SCRIPT";
+ case Feature::WEB_PAGE_CONTEXT:
+ return "WEB_PAGE";
+ case Feature::BLESSED_WEB_PAGE_CONTEXT:
+ return "BLESSED_WEB_PAGE";
+ case Feature::WEBUI_CONTEXT:
+ return "WEBUI";
+ }
+ NOTREACHED();
+ return std::string();
+}
+
+} // namespace
+
ScriptContext::ScriptContext(const v8::Handle<v8::Context>& v8_context,
blink::WebFrame* web_frame,
const Extension* extension,
- Feature::Context context_type)
+ Feature::Context context_type,
+ const Extension* effective_extension,
+ Feature::Context effective_context_type)
: v8_context_(v8_context),
web_frame_(web_frame),
extension_(extension),
context_type_(context_type),
+ effective_extension_(effective_extension),
+ effective_context_type_(effective_context_type),
safe_builtins_(this),
isolate_(v8_context->GetIsolate()) {
VLOG(1) << "Created context:\n"
<< " extension id: " << GetExtensionID() << "\n"
<< " frame: " << web_frame_ << "\n"
<< " URL: " << GetURL() << "\n"
- << " context type: " << GetContextTypeDescription();
+ << " context type: " << GetContextTypeDescription() << "\n"
+ << " effective extension id: "
+ << (effective_extension_.get() ? effective_extension_->id() : "")
+ << " effective context type: "
+ << GetEffectiveContextTypeDescription();
gin::PerContextData::From(v8_context)->set_runner(this);
}
ScriptContext::~ScriptContext() {
VLOG(1) << "Destroyed context for extension\n"
- << " extension id: " << GetExtensionID();
+ << " extension id: " << GetExtensionID() << "\n"
+ << " effective extension id: "
+ << (effective_extension_.get() ? effective_extension_->id() : "");
Invalidate();
}
@@ -133,24 +168,11 @@ void ScriptContext::DispatchOnUnloadEvent() {
}
std::string ScriptContext::GetContextTypeDescription() {
- switch (context_type_) {
- case Feature::UNSPECIFIED_CONTEXT:
- return "UNSPECIFIED";
- case Feature::BLESSED_EXTENSION_CONTEXT:
- return "BLESSED_EXTENSION";
- case Feature::UNBLESSED_EXTENSION_CONTEXT:
- return "UNBLESSED_EXTENSION";
- case Feature::CONTENT_SCRIPT_CONTEXT:
- return "CONTENT_SCRIPT";
- case Feature::WEB_PAGE_CONTEXT:
- return "WEB_PAGE";
- case Feature::BLESSED_WEB_PAGE_CONTEXT:
- return "BLESSED_WEB_PAGE";
- case Feature::WEBUI_CONTEXT:
- return "WEBUI";
- }
- NOTREACHED();
- return std::string();
+ return GetContextTypeDescriptionString(context_type_);
+}
+
+std::string ScriptContext::GetEffectiveContextTypeDescription() {
+ return GetContextTypeDescriptionString(effective_context_type_);
}
GURL ScriptContext::GetURL() const {
« no previous file with comments | « extensions/renderer/script_context.h ('k') | extensions/renderer/script_context_set_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698