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

Side by Side Diff: chrome/renderer/extensions/chrome_v8_extension.cc

Issue 8659009: Consider the origin when computing extension permissions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/chrome_v8_extension.h" 5 #include "chrome/renderer/extensions/chrome_v8_extension.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/lazy_instance.h" 8 #include "base/lazy_instance.h"
9 #include "base/stringprintf.h" 9 #include "base/stringprintf.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
11 #include "chrome/common/extensions/extension.h" 11 #include "chrome/common/extensions/extension.h"
12 #include "chrome/common/extensions/extension_set.h" 12 #include "chrome/common/extensions/extension_set.h"
13 #include "chrome/common/extensions/api/extension_api.h" 13 #include "chrome/common/extensions/api/extension_api.h"
14 #include "chrome/renderer/extensions/chrome_v8_context.h" 14 #include "chrome/renderer/extensions/chrome_v8_context.h"
15 #include "chrome/renderer/extensions/extension_dispatcher.h" 15 #include "chrome/renderer/extensions/extension_dispatcher.h"
16 #include "content/public/renderer/render_view.h" 16 #include "content/public/renderer/render_view.h"
17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" 17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h"
18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" 18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" 19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
20 #include "ui/base/resource/resource_bundle.h" 20 #include "ui/base/resource/resource_bundle.h"
21 21
22 using extensions::ExtensionAPI; 22 using extensions::ExtensionAPI;
23 using WebKit::WebDocument;
23 using WebKit::WebFrame; 24 using WebKit::WebFrame;
24 using WebKit::WebView; 25 using WebKit::WebView;
25 26
26 namespace { 27 namespace {
27 28
28 static base::LazyInstance<ChromeV8Extension::InstanceSet> g_instances = 29 static base::LazyInstance<ChromeV8Extension::InstanceSet> g_instances =
29 LAZY_INSTANCE_INITIALIZER; 30 LAZY_INSTANCE_INITIALIZER;
30 31
31 } // namespace 32 } // namespace
32 33
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 return NULL; 97 return NULL;
97 else 98 else
98 return iter->second.get(); 99 return iter->second.get();
99 } 100 }
100 101
101 const Extension* ChromeV8Extension::GetExtensionForCurrentRenderView() const { 102 const Extension* ChromeV8Extension::GetExtensionForCurrentRenderView() const {
102 content::RenderView* renderview = GetCurrentRenderView(); 103 content::RenderView* renderview = GetCurrentRenderView();
103 if (!renderview) 104 if (!renderview)
104 return NULL; // this can happen as a tab is closing. 105 return NULL; // this can happen as a tab is closing.
105 106
106 GURL url = renderview->GetWebView()->mainFrame()->document().url(); 107 WebDocument document = renderview->GetWebView()->mainFrame()->document();
108 GURL url = document.url();
107 const ExtensionSet* extensions = extension_dispatcher_->extensions(); 109 const ExtensionSet* extensions = extension_dispatcher_->extensions();
108 if (!extensions->ExtensionBindingsAllowed(url)) 110 if (!extensions->ExtensionBindingsAllowed(
111 ExtensionURLInfo(document.securityOrigin(), url)))
109 return NULL; 112 return NULL;
110 113
111 return extensions->GetByURL(url); 114 return extensions->GetByURL(
115 ExtensionURLInfo(document.securityOrigin(), url));
112 } 116 }
113 117
114 bool ChromeV8Extension::CheckCurrentContextAccessToExtensionAPI( 118 bool ChromeV8Extension::CheckCurrentContextAccessToExtensionAPI(
115 const std::string& function_name) const { 119 const std::string& function_name) const {
116 ChromeV8Context* context = 120 ChromeV8Context* context =
117 extension_dispatcher_->v8_context_set().GetCurrent(); 121 extension_dispatcher_->v8_context_set().GetCurrent();
118 if (!context) { 122 if (!context) {
119 DLOG(ERROR) << "Not in a v8::Context"; 123 DLOG(ERROR) << "Not in a v8::Context";
120 return false; 124 return false;
121 } 125 }
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 if (args.Length() < 1) 203 if (args.Length() < 1)
200 return v8::Undefined(); 204 return v8::Undefined();
201 205
202 std::vector<std::string> components; 206 std::vector<std::string> components;
203 for (int i = 0; i < args.Length(); ++i) 207 for (int i = 0; i < args.Length(); ++i)
204 components.push_back(*v8::String::Utf8Value(args[i]->ToString())); 208 components.push_back(*v8::String::Utf8Value(args[i]->ToString()));
205 209
206 LOG(ERROR) << JoinString(components, ','); 210 LOG(ERROR) << JoinString(components, ',');
207 return v8::Undefined(); 211 return v8::Undefined();
208 } 212 }
OLDNEW
« no previous file with comments | « chrome/renderer/extensions/app_bindings.cc ('k') | chrome/renderer/extensions/extension_dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698