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

Side by Side Diff: extensions/renderer/dispatcher.cc

Issue 985643004: Make ContentRendererClient::DidCreateScriptContext take a WebLocalFrame. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: namespace Created 5 years, 9 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/dispatcher.h" 5 #include "extensions/renderer/dispatcher.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/debug/alias.h" 10 #include "base/debug/alias.h"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 #include "extensions/renderer/user_gestures_native_handler.h" 84 #include "extensions/renderer/user_gestures_native_handler.h"
85 #include "extensions/renderer/utils_native_handler.h" 85 #include "extensions/renderer/utils_native_handler.h"
86 #include "extensions/renderer/v8_context_native_handler.h" 86 #include "extensions/renderer/v8_context_native_handler.h"
87 #include "grit/extensions_renderer_resources.h" 87 #include "grit/extensions_renderer_resources.h"
88 #include "third_party/WebKit/public/platform/WebString.h" 88 #include "third_party/WebKit/public/platform/WebString.h"
89 #include "third_party/WebKit/public/platform/WebURLRequest.h" 89 #include "third_party/WebKit/public/platform/WebURLRequest.h"
90 #include "third_party/WebKit/public/web/WebCustomElement.h" 90 #include "third_party/WebKit/public/web/WebCustomElement.h"
91 #include "third_party/WebKit/public/web/WebDataSource.h" 91 #include "third_party/WebKit/public/web/WebDataSource.h"
92 #include "third_party/WebKit/public/web/WebDocument.h" 92 #include "third_party/WebKit/public/web/WebDocument.h"
93 #include "third_party/WebKit/public/web/WebFrame.h" 93 #include "third_party/WebKit/public/web/WebFrame.h"
94 #include "third_party/WebKit/public/web/WebLocalFrame.h"
94 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" 95 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h"
95 #include "third_party/WebKit/public/web/WebScopedUserGesture.h" 96 #include "third_party/WebKit/public/web/WebScopedUserGesture.h"
96 #include "third_party/WebKit/public/web/WebSecurityPolicy.h" 97 #include "third_party/WebKit/public/web/WebSecurityPolicy.h"
97 #include "third_party/WebKit/public/web/WebView.h" 98 #include "third_party/WebKit/public/web/WebView.h"
98 #include "third_party/mojo/src/mojo/public/js/constants.h" 99 #include "third_party/mojo/src/mojo/public/js/constants.h"
99 #include "ui/base/layout.h" 100 #include "ui/base/layout.h"
100 #include "ui/base/resource/resource_bundle.h" 101 #include "ui/base/resource/resource_bundle.h"
101 #include "v8/include/v8.h" 102 #include "v8/include/v8.h"
102 103
103 using base::UserMetricsAction; 104 using base::UserMetricsAction;
104 using blink::WebDataSource; 105 using blink::WebDataSource;
105 using blink::WebDocument; 106 using blink::WebDocument;
106 using blink::WebFrame;
107 using blink::WebScopedUserGesture; 107 using blink::WebScopedUserGesture;
108 using blink::WebSecurityPolicy; 108 using blink::WebSecurityPolicy;
109 using blink::WebString; 109 using blink::WebString;
110 using blink::WebVector; 110 using blink::WebVector;
111 using blink::WebView; 111 using blink::WebView;
112 using content::RenderThread; 112 using content::RenderThread;
113 using content::RenderView; 113 using content::RenderView;
114 114
115 namespace extensions { 115 namespace extensions {
116 116
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 222
223 bool Dispatcher::IsExtensionActive(const std::string& extension_id) const { 223 bool Dispatcher::IsExtensionActive(const std::string& extension_id) const {
224 bool is_active = 224 bool is_active =
225 active_extension_ids_.find(extension_id) != active_extension_ids_.end(); 225 active_extension_ids_.find(extension_id) != active_extension_ids_.end();
226 if (is_active) 226 if (is_active)
227 CHECK(extensions_.Contains(extension_id)); 227 CHECK(extensions_.Contains(extension_id));
228 return is_active; 228 return is_active;
229 } 229 }
230 230
231 const Extension* Dispatcher::GetExtensionFromFrameAndWorld( 231 const Extension* Dispatcher::GetExtensionFromFrameAndWorld(
232 const WebFrame* frame, 232 const blink::WebFrame* frame,
233 int world_id, 233 int world_id,
234 bool use_effective_url) { 234 bool use_effective_url) {
235 std::string extension_id; 235 std::string extension_id;
236 if (world_id != 0) { 236 if (world_id != 0) {
237 // Isolated worlds (content script). 237 // Isolated worlds (content script).
238 extension_id = ScriptInjection::GetHostIdForIsolatedWorld(world_id); 238 extension_id = ScriptInjection::GetHostIdForIsolatedWorld(world_id);
239 } else if (!frame->document().securityOrigin().isUnique()) { 239 } else if (!frame->document().securityOrigin().isUnique()) {
240 // TODO(kalman): Delete the above check. 240 // TODO(kalman): Delete the above check.
241 241
242 // Extension pages (chrome-extension:// URLs). 242 // Extension pages (chrome-extension:// URLs).
(...skipping 12 matching lines...) Expand all
255 if (extension_id != "invalid") { 255 if (extension_id != "invalid") {
256 LOG(ERROR) << "Extension \"" << extension_id << "\" not found"; 256 LOG(ERROR) << "Extension \"" << extension_id << "\" not found";
257 RenderThread::Get()->RecordAction( 257 RenderThread::Get()->RecordAction(
258 UserMetricsAction("ExtensionNotFound_ED")); 258 UserMetricsAction("ExtensionNotFound_ED"));
259 } 259 }
260 } 260 }
261 return extension; 261 return extension;
262 } 262 }
263 263
264 void Dispatcher::DidCreateScriptContext( 264 void Dispatcher::DidCreateScriptContext(
265 WebFrame* frame, 265 blink::WebLocalFrame* frame,
266 const v8::Handle<v8::Context>& v8_context, 266 const v8::Handle<v8::Context>& v8_context,
267 int extension_group, 267 int extension_group,
268 int world_id) { 268 int world_id) {
269 const base::TimeTicks start_time = base::TimeTicks::Now(); 269 const base::TimeTicks start_time = base::TimeTicks::Now();
270 270
271 const Extension* extension = 271 const Extension* extension =
272 GetExtensionFromFrameAndWorld(frame, world_id, false); 272 GetExtensionFromFrameAndWorld(frame, world_id, false);
273 const Extension* effective_extension = 273 const Extension* effective_extension =
274 GetExtensionFromFrameAndWorld(frame, world_id, true); 274 GetExtensionFromFrameAndWorld(frame, world_id, true);
275 275
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 break; 387 break;
388 case Feature::WEBUI_CONTEXT: 388 case Feature::WEBUI_CONTEXT:
389 UMA_HISTOGRAM_TIMES("Extensions.DidCreateScriptContext_WebUI", elapsed); 389 UMA_HISTOGRAM_TIMES("Extensions.DidCreateScriptContext_WebUI", elapsed);
390 break; 390 break;
391 } 391 }
392 392
393 VLOG(1) << "Num tracked contexts: " << script_context_set_.size(); 393 VLOG(1) << "Num tracked contexts: " << script_context_set_.size();
394 } 394 }
395 395
396 void Dispatcher::WillReleaseScriptContext( 396 void Dispatcher::WillReleaseScriptContext(
397 WebFrame* frame, 397 blink::WebLocalFrame* frame,
398 const v8::Handle<v8::Context>& v8_context, 398 const v8::Handle<v8::Context>& v8_context,
399 int world_id) { 399 int world_id) {
400 ScriptContext* context = script_context_set_.GetByV8Context(v8_context); 400 ScriptContext* context = script_context_set_.GetByV8Context(v8_context);
401 if (!context) 401 if (!context)
402 return; 402 return;
403 403
404 context->DispatchOnUnloadEvent(); 404 context->DispatchOnUnloadEvent();
405 // TODO(kalman): add an invalidation observer interface to ScriptContext. 405 // TODO(kalman): add an invalidation observer interface to ScriptContext.
406 request_sender_->InvalidateSource(context); 406 request_sender_->InvalidateSource(context);
407 407
(...skipping 1145 matching lines...) Expand 10 before | Expand all | Expand 10 after
1553 return v8::Handle<v8::Object>(); 1553 return v8::Handle<v8::Object>();
1554 1554
1555 if (bind_name) 1555 if (bind_name)
1556 *bind_name = split.back(); 1556 *bind_name = split.back();
1557 1557
1558 return bind_object.IsEmpty() ? AsObjectOrEmpty(GetOrCreateChrome(context)) 1558 return bind_object.IsEmpty() ? AsObjectOrEmpty(GetOrCreateChrome(context))
1559 : bind_object; 1559 : bind_object;
1560 } 1560 }
1561 1561
1562 } // namespace extensions 1562 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/renderer/dispatcher.h ('k') | extensions/shell/renderer/shell_content_renderer_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698