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

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: lint fix Created 8 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 | 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/user_script_slave.h" 23 #include "chrome/renderer/extensions/user_script_slave.h"
24 #include "chrome/renderer/extensions/webstore_bindings.h" 24 #include "chrome/renderer/extensions/webstore_bindings.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/WebScopedUserGesture. 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 39
39 static const int64 kInitialExtensionIdleHandlerDelayMs = 5*1000; 40 static const int64 kInitialExtensionIdleHandlerDelayMs = 5*1000;
40 static const int64 kMaxExtensionIdleHandlerDelayMs = 5*60*1000; 41 static const int64 kMaxExtensionIdleHandlerDelayMs = 5*60*1000;
41 42
42 ChromeV8Context::ContextType ExtensionGroupToContextType(int extension_group) { 43 ChromeV8Context::ContextType ExtensionGroupToContextType(int extension_group) {
43 if (extension_group == EXTENSION_GROUP_CONTENT_SCRIPTS) 44 if (extension_group == EXTENSION_GROUP_CONTENT_SCRIPTS)
44 return ChromeV8Context::CONTENT_SCRIPT; 45 return ChromeV8Context::CONTENT_SCRIPT;
45 return ChromeV8Context::OTHER; 46 return ChromeV8Context::OTHER;
46 } 47 }
47 48
48 } 49 }
49 50
50 using namespace extensions; 51 using namespace extensions;
51 52
52 using WebKit::WebDataSource; 53 using WebKit::WebDataSource;
53 using WebKit::WebDocument; 54 using WebKit::WebDocument;
54 using WebKit::WebFrame; 55 using WebKit::WebFrame;
55 using WebKit::WebSecurityPolicy; 56 using WebKit::WebSecurityPolicy;
56 using WebKit::WebString; 57 using WebKit::WebString;
58 using WebKit::WebScopedUserGesture;
57 using WebKit::WebVector; 59 using WebKit::WebVector;
58 using WebKit::WebView; 60 using WebKit::WebView;
59 using content::RenderThread; 61 using content::RenderThread;
60 62
61 ExtensionDispatcher::ExtensionDispatcher() 63 ExtensionDispatcher::ExtensionDispatcher()
62 : is_webkit_initialized_(false), 64 : is_webkit_initialized_(false),
63 webrequest_adblock_(false), 65 webrequest_adblock_(false),
64 webrequest_adblock_plus_(false), 66 webrequest_adblock_plus_(false),
65 webrequest_other_(false) { 67 webrequest_other_(false) {
66 const CommandLine& command_line = *(CommandLine::ForCurrentProcess()); 68 const CommandLine& command_line = *(CommandLine::ForCurrentProcess());
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 void ExtensionDispatcher::OnSetFunctionNames( 161 void ExtensionDispatcher::OnSetFunctionNames(
160 const std::vector<std::string>& names) { 162 const std::vector<std::string>& names) {
161 function_names_.clear(); 163 function_names_.clear();
162 for (size_t i = 0; i < names.size(); ++i) 164 for (size_t i = 0; i < names.size(); ++i)
163 function_names_.insert(names[i]); 165 function_names_.insert(names[i]);
164 } 166 }
165 167
166 void ExtensionDispatcher::OnMessageInvoke(const std::string& extension_id, 168 void ExtensionDispatcher::OnMessageInvoke(const std::string& extension_id,
167 const std::string& function_name, 169 const std::string& function_name,
168 const ListValue& args, 170 const ListValue& args,
169 const GURL& event_url) { 171 const GURL& event_url,
172 bool user_gesture) {
173 scoped_ptr<WebScopedUserGesture> web_user_gesture;
174 if (user_gesture) {
175 web_user_gesture.reset(new WebScopedUserGesture);
176 }
177
170 v8_context_set_.DispatchChromeHiddenMethod( 178 v8_context_set_.DispatchChromeHiddenMethod(
171 extension_id, function_name, args, NULL, event_url); 179 extension_id, function_name, args, NULL, event_url);
172 180
173 // Reset the idle handler each time there's any activity like event or message 181 // Reset the idle handler each time there's any activity like event or message
174 // dispatch, for which Invoke is the chokepoint. 182 // dispatch, for which Invoke is the chokepoint.
175 if (is_extension_process_) { 183 if (is_extension_process_) {
176 RenderThread::Get()->ScheduleIdleHandler( 184 RenderThread::Get()->ScheduleIdleHandler(
177 kInitialExtensionIdleHandlerDelayMs); 185 kInitialExtensionIdleHandlerDelayMs);
178 } 186 }
179 187
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 webrequest_adblock_ = adblock; 542 webrequest_adblock_ = adblock;
535 webrequest_adblock_plus_ = adblock_plus; 543 webrequest_adblock_plus_ = adblock_plus;
536 webrequest_other_ = other; 544 webrequest_other_ = other;
537 } 545 }
538 546
539 void ExtensionDispatcher::OnShouldClose(const std::string& extension_id, 547 void ExtensionDispatcher::OnShouldClose(const std::string& extension_id,
540 int sequence_id) { 548 int sequence_id) {
541 RenderThread::Get()->Send( 549 RenderThread::Get()->Send(
542 new ExtensionHostMsg_ShouldCloseAck(extension_id, sequence_id)); 550 new ExtensionHostMsg_ShouldCloseAck(extension_id, sequence_id));
543 } 551 }
OLDNEW
« no previous file with comments | « chrome/renderer/extensions/extension_dispatcher.h ('k') | chrome/renderer/extensions/extension_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698