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

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

Issue 9316102: Update extension events, routing, and delivery to use user gesture. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 10 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 | Annotate | Revision Log
OLDNEW
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_dispatcher.h" 5 #include "chrome/renderer/extensions/extension_dispatcher.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "chrome/common/child_process_logging.h" 8 #include "chrome/common/child_process_logging.h"
9 #include "chrome/common/chrome_switches.h" 9 #include "chrome/common/chrome_switches.h"
10 #include "chrome/common/extensions/extension.h" 10 #include "chrome/common/extensions/extension.h"
(...skipping 12 matching lines...) Expand all
23 #include "chrome/renderer/extensions/schema_generated_bindings.h" 23 #include "chrome/renderer/extensions/schema_generated_bindings.h"
24 #include "chrome/renderer/extensions/user_script_slave.h" 24 #include "chrome/renderer/extensions/user_script_slave.h"
25 #include "content/public/renderer/render_thread.h" 25 #include "content/public/renderer/render_thread.h"
26 #include "grit/renderer_resources.h" 26 #include "grit/renderer_resources.h"
27 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDataSource.h" 27 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDataSource.h"
28 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" 28 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h"
29 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" 29 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
30 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityPolicy.h" 30 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityPolicy.h"
31 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" 31 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h"
32 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLReques t.h" 32 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLReques t.h"
33 #include "third_party/WebKit/Source/WebKit/chromium/public/WebUserGestureIndicat or.h"
33 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" 34 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
34 #include "ui/base/resource/resource_bundle.h" 35 #include "ui/base/resource/resource_bundle.h"
35 #include "v8/include/v8.h" 36 #include "v8/include/v8.h"
36 37
37 namespace { 38 namespace {
38 static const int64 kInitialExtensionIdleHandlerDelayMs = 5*1000; 39 static const int64 kInitialExtensionIdleHandlerDelayMs = 5*1000;
39 static const int64 kMaxExtensionIdleHandlerDelayMs = 5*60*1000; 40 static const int64 kMaxExtensionIdleHandlerDelayMs = 5*60*1000;
40 } 41 }
41 42
42 using namespace extensions; 43 using namespace extensions;
43 44
44 using WebKit::WebDataSource; 45 using WebKit::WebDataSource;
45 using WebKit::WebDocument; 46 using WebKit::WebDocument;
46 using WebKit::WebFrame; 47 using WebKit::WebFrame;
47 using WebKit::WebSecurityPolicy; 48 using WebKit::WebSecurityPolicy;
48 using WebKit::WebString; 49 using WebKit::WebString;
50 using WebKit::WebUserGestureIndicator;
49 using WebKit::WebVector; 51 using WebKit::WebVector;
50 using WebKit::WebView; 52 using WebKit::WebView;
51 using content::RenderThread; 53 using content::RenderThread;
52 54
53 ExtensionDispatcher::ExtensionDispatcher() 55 ExtensionDispatcher::ExtensionDispatcher()
54 : is_webkit_initialized_(false), 56 : is_webkit_initialized_(false),
55 webrequest_adblock_(false), 57 webrequest_adblock_(false),
56 webrequest_adblock_plus_(false), 58 webrequest_adblock_plus_(false),
57 webrequest_other_(false) { 59 webrequest_other_(false) {
58 const CommandLine& command_line = *(CommandLine::ForCurrentProcess()); 60 const CommandLine& command_line = *(CommandLine::ForCurrentProcess());
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 void ExtensionDispatcher::OnSetFunctionNames( 152 void ExtensionDispatcher::OnSetFunctionNames(
151 const std::vector<std::string>& names) { 153 const std::vector<std::string>& names) {
152 function_names_.clear(); 154 function_names_.clear();
153 for (size_t i = 0; i < names.size(); ++i) 155 for (size_t i = 0; i < names.size(); ++i)
154 function_names_.insert(names[i]); 156 function_names_.insert(names[i]);
155 } 157 }
156 158
157 void ExtensionDispatcher::OnMessageInvoke(const std::string& extension_id, 159 void ExtensionDispatcher::OnMessageInvoke(const std::string& extension_id,
158 const std::string& function_name, 160 const std::string& function_name,
159 const ListValue& args, 161 const ListValue& args,
160 const GURL& event_url) { 162 const GURL& event_url,
163 bool user_caused) {
164 scoped_ptr<WebUserGestureIndicator> user_gesture;
165 if (user_caused) {
166 user_gesture.reset(
167 WebUserGestureIndicator::DefinitelyProcessingUserGesture());
168 }
169
161 v8_context_set_.DispatchChromeHiddenMethod( 170 v8_context_set_.DispatchChromeHiddenMethod(
162 extension_id, function_name, args, NULL, event_url); 171 extension_id, function_name, args, NULL, event_url);
163 172
164 // Reset the idle handler each time there's any activity like event or message 173 // Reset the idle handler each time there's any activity like event or message
165 // dispatch, for which Invoke is the chokepoint. 174 // dispatch, for which Invoke is the chokepoint.
166 if (is_extension_process_) { 175 if (is_extension_process_) {
167 RenderThread::Get()->ScheduleIdleHandler( 176 RenderThread::Get()->ScheduleIdleHandler(
168 kInitialExtensionIdleHandlerDelayMs); 177 kInitialExtensionIdleHandlerDelayMs);
169 } 178 }
170 179
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 507
499 RenderThread::Get()->RegisterExtension(extension); 508 RenderThread::Get()->RegisterExtension(extension);
500 } 509 }
501 510
502 void ExtensionDispatcher::OnUsingWebRequestAPI( 511 void ExtensionDispatcher::OnUsingWebRequestAPI(
503 bool adblock, bool adblock_plus, bool other) { 512 bool adblock, bool adblock_plus, bool other) {
504 webrequest_adblock_ = adblock; 513 webrequest_adblock_ = adblock;
505 webrequest_adblock_plus_ = adblock_plus; 514 webrequest_adblock_plus_ = adblock_plus;
506 webrequest_other_ = other; 515 webrequest_other_ = other;
507 } 516 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698