OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/extension_helper.h" | 5 #include "chrome/renderer/extensions/extension_helper.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/json/json_value_serializer.h" | 10 #include "base/json/json_value_serializer.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 #include "chrome/renderer/extensions/event_bindings.h" | 22 #include "chrome/renderer/extensions/event_bindings.h" |
23 #include "chrome/renderer/extensions/extension_dispatcher.h" | 23 #include "chrome/renderer/extensions/extension_dispatcher.h" |
24 #include "chrome/renderer/extensions/miscellaneous_bindings.h" | 24 #include "chrome/renderer/extensions/miscellaneous_bindings.h" |
25 #include "chrome/renderer/extensions/schema_generated_bindings.h" | 25 #include "chrome/renderer/extensions/schema_generated_bindings.h" |
26 #include "chrome/renderer/extensions/user_script_idle_scheduler.h" | 26 #include "chrome/renderer/extensions/user_script_idle_scheduler.h" |
27 #include "chrome/renderer/extensions/user_script_slave.h" | 27 #include "chrome/renderer/extensions/user_script_slave.h" |
28 #include "content/public/renderer/render_view.h" | 28 #include "content/public/renderer/render_view.h" |
29 #include "third_party/WebKit/Source/WebKit/chromium/public/WebConsoleMessage.h" | 29 #include "third_party/WebKit/Source/WebKit/chromium/public/WebConsoleMessage.h" |
30 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 30 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
31 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLReques
t.h" | 31 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLReques
t.h" |
| 32 #include "third_party/WebKit/Source/WebKit/chromium/public/WebUserGestureIndicat
or.h" |
32 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | 33 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
33 #include "webkit/glue/image_resource_fetcher.h" | 34 #include "webkit/glue/image_resource_fetcher.h" |
34 #include "webkit/glue/resource_fetcher.h" | 35 #include "webkit/glue/resource_fetcher.h" |
35 | 36 |
36 using extensions::MiscellaneousBindings; | 37 using extensions::MiscellaneousBindings; |
37 using extensions::SchemaGeneratedBindings; | 38 using extensions::SchemaGeneratedBindings; |
38 using WebKit::WebConsoleMessage; | 39 using WebKit::WebConsoleMessage; |
39 using WebKit::WebDataSource; | 40 using WebKit::WebDataSource; |
40 using WebKit::WebFrame; | 41 using WebKit::WebFrame; |
41 using WebKit::WebURLRequest; | 42 using WebKit::WebURLRequest; |
| 43 using WebKit::WebUserGestureIndicator; |
42 using WebKit::WebView; | 44 using WebKit::WebView; |
43 using webkit_glue::ImageResourceFetcher; | 45 using webkit_glue::ImageResourceFetcher; |
44 using webkit_glue::ResourceFetcher; | 46 using webkit_glue::ResourceFetcher; |
45 | 47 |
46 namespace { | 48 namespace { |
47 // Keeps a mapping from the frame pointer to a UserScriptIdleScheduler object. | 49 // Keeps a mapping from the frame pointer to a UserScriptIdleScheduler object. |
48 // We store this mapping per process, because a frame can jump from one | 50 // We store this mapping per process, because a frame can jump from one |
49 // document to another with adoptNode, and so having the object be a | 51 // document to another with adoptNode, and so having the object be a |
50 // RenderViewObserver means it might miss some notifications after it moves. | 52 // RenderViewObserver means it might miss some notifications after it moves. |
51 typedef std::map<WebFrame*, UserScriptIdleScheduler*> SchedulerMap; | 53 typedef std::map<WebFrame*, UserScriptIdleScheduler*> SchedulerMap; |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 SchemaGeneratedBindings::HandleResponse( | 211 SchemaGeneratedBindings::HandleResponse( |
210 extension_dispatcher_->v8_context_set(), request_id, success, | 212 extension_dispatcher_->v8_context_set(), request_id, success, |
211 response, error, &extension_id); | 213 response, error, &extension_id); |
212 | 214 |
213 extension_dispatcher_->CheckIdleStatus(extension_id); | 215 extension_dispatcher_->CheckIdleStatus(extension_id); |
214 } | 216 } |
215 | 217 |
216 void ExtensionHelper::OnExtensionMessageInvoke(const std::string& extension_id, | 218 void ExtensionHelper::OnExtensionMessageInvoke(const std::string& extension_id, |
217 const std::string& function_name, | 219 const std::string& function_name, |
218 const ListValue& args, | 220 const ListValue& args, |
219 const GURL& event_url) { | 221 const GURL& event_url, |
| 222 bool user_caused) { |
| 223 scoped_ptr<WebUserGestureIndicator> user_gesture; |
| 224 if (user_caused) { |
| 225 user_gesture.reset( |
| 226 WebUserGestureIndicator::DefinitelyProcessingUserGesture()); |
| 227 } |
220 extension_dispatcher_->v8_context_set().DispatchChromeHiddenMethod( | 228 extension_dispatcher_->v8_context_set().DispatchChromeHiddenMethod( |
221 extension_id, function_name, args, render_view(), event_url); | 229 extension_id, function_name, args, render_view(), event_url); |
222 } | 230 } |
223 | 231 |
224 void ExtensionHelper::OnExtensionDeliverMessage(int target_id, | 232 void ExtensionHelper::OnExtensionDeliverMessage(int target_id, |
225 const std::string& message) { | 233 const std::string& message) { |
226 MiscellaneousBindings::DeliverMessage( | 234 MiscellaneousBindings::DeliverMessage( |
227 extension_dispatcher_->v8_context_set().GetAll(), | 235 extension_dispatcher_->v8_context_set().GetAll(), |
228 target_id, | 236 target_id, |
229 message, | 237 message, |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 routing_id(), *pending_app_info_)); | 378 routing_id(), *pending_app_info_)); |
371 pending_app_info_.reset(NULL); | 379 pending_app_info_.reset(NULL); |
372 } | 380 } |
373 | 381 |
374 void ExtensionHelper::AddErrorToRootConsole(const string16& message) { | 382 void ExtensionHelper::AddErrorToRootConsole(const string16& message) { |
375 if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) { | 383 if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) { |
376 render_view()->GetWebView()->mainFrame()->addMessageToConsole( | 384 render_view()->GetWebView()->mainFrame()->addMessageToConsole( |
377 WebConsoleMessage(WebConsoleMessage::LevelError, message)); | 385 WebConsoleMessage(WebConsoleMessage::LevelError, message)); |
378 } | 386 } |
379 } | 387 } |
OLD | NEW |