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

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

Issue 10804020: Introduce runtime.onSuspendCanceled() event. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: respond to comments Created 8 years, 5 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
« no previous file with comments | « chrome/renderer/extensions/extension_dispatcher.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/callback.h" 7 #include "base/callback.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/string_piece.h" 10 #include "base/string_piece.h"
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 using extensions::TabsCustomBindings; 103 using extensions::TabsCustomBindings;
104 using extensions::UpdatedExtensionPermissionsInfo; 104 using extensions::UpdatedExtensionPermissionsInfo;
105 using extensions::WebRequestCustomBindings; 105 using extensions::WebRequestCustomBindings;
106 106
107 namespace { 107 namespace {
108 108
109 static const int64 kInitialExtensionIdleHandlerDelayMs = 5*1000; 109 static const int64 kInitialExtensionIdleHandlerDelayMs = 5*1000;
110 static const int64 kMaxExtensionIdleHandlerDelayMs = 5*60*1000; 110 static const int64 kMaxExtensionIdleHandlerDelayMs = 5*60*1000;
111 static const char kEventDispatchFunction[] = "Event.dispatchJSON"; 111 static const char kEventDispatchFunction[] = "Event.dispatchJSON";
112 static const char kOnUnloadEvent[] = "runtime.onSuspend"; 112 static const char kOnUnloadEvent[] = "runtime.onSuspend";
113 static const char kOnSuspendCanceledEvent[] = "runtime.onSuspendCanceled";
113 114
114 class ChromeHiddenNativeHandler : public NativeHandler { 115 class ChromeHiddenNativeHandler : public NativeHandler {
115 public: 116 public:
116 ChromeHiddenNativeHandler() { 117 ChromeHiddenNativeHandler() {
117 RouteFunction("GetChromeHidden", 118 RouteFunction("GetChromeHidden",
118 base::Bind(&ChromeHiddenNativeHandler::GetChromeHidden, 119 base::Bind(&ChromeHiddenNativeHandler::GetChromeHidden,
119 base::Unretained(this))); 120 base::Unretained(this)));
120 } 121 }
121 122
122 v8::Handle<v8::Value> GetChromeHidden(const v8::Arguments& args) { 123 v8::Handle<v8::Value> GetChromeHidden(const v8::Arguments& args) {
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 IPC_MESSAGE_HANDLER(ExtensionMsg_ActivateExtension, OnActivateExtension) 319 IPC_MESSAGE_HANDLER(ExtensionMsg_ActivateExtension, OnActivateExtension)
319 IPC_MESSAGE_HANDLER(ExtensionMsg_UpdatePermissions, OnUpdatePermissions) 320 IPC_MESSAGE_HANDLER(ExtensionMsg_UpdatePermissions, OnUpdatePermissions)
320 IPC_MESSAGE_HANDLER(ExtensionMsg_UpdateTabSpecificPermissions, 321 IPC_MESSAGE_HANDLER(ExtensionMsg_UpdateTabSpecificPermissions,
321 OnUpdateTabSpecificPermissions) 322 OnUpdateTabSpecificPermissions)
322 IPC_MESSAGE_HANDLER(ExtensionMsg_ClearTabSpecificPermissions, 323 IPC_MESSAGE_HANDLER(ExtensionMsg_ClearTabSpecificPermissions,
323 OnClearTabSpecificPermissions) 324 OnClearTabSpecificPermissions)
324 IPC_MESSAGE_HANDLER(ExtensionMsg_UpdateUserScripts, OnUpdateUserScripts) 325 IPC_MESSAGE_HANDLER(ExtensionMsg_UpdateUserScripts, OnUpdateUserScripts)
325 IPC_MESSAGE_HANDLER(ExtensionMsg_UsingWebRequestAPI, OnUsingWebRequestAPI) 326 IPC_MESSAGE_HANDLER(ExtensionMsg_UsingWebRequestAPI, OnUsingWebRequestAPI)
326 IPC_MESSAGE_HANDLER(ExtensionMsg_ShouldUnload, OnShouldUnload) 327 IPC_MESSAGE_HANDLER(ExtensionMsg_ShouldUnload, OnShouldUnload)
327 IPC_MESSAGE_HANDLER(ExtensionMsg_Unload, OnUnload) 328 IPC_MESSAGE_HANDLER(ExtensionMsg_Unload, OnUnload)
329 IPC_MESSAGE_HANDLER(ExtensionMsg_CancelUnload, OnCancelUnload)
328 IPC_MESSAGE_UNHANDLED(handled = false) 330 IPC_MESSAGE_UNHANDLED(handled = false)
329 IPC_END_MESSAGE_MAP() 331 IPC_END_MESSAGE_MAP()
330 332
331 return handled; 333 return handled;
332 } 334 }
333 335
334 void ExtensionDispatcher::WebKitInitialized() { 336 void ExtensionDispatcher::WebKitInitialized() {
335 // For extensions, we want to ensure we call the IdleHandler every so often, 337 // For extensions, we want to ensure we call the IdleHandler every so often,
336 // even if the extension keeps up activity. 338 // even if the extension keeps up activity.
337 if (is_extension_process_) { 339 if (is_extension_process_) {
(...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after
994 // event creates. 996 // event creates.
995 ListValue args; 997 ListValue args;
996 args.Set(0, Value::CreateStringValue(kOnUnloadEvent)); 998 args.Set(0, Value::CreateStringValue(kOnUnloadEvent));
997 args.Set(1, Value::CreateStringValue("[]")); 999 args.Set(1, Value::CreateStringValue("[]"));
998 v8_context_set_.DispatchChromeHiddenMethod( 1000 v8_context_set_.DispatchChromeHiddenMethod(
999 extension_id, kEventDispatchFunction, args, NULL, GURL()); 1001 extension_id, kEventDispatchFunction, args, NULL, GURL());
1000 1002
1001 RenderThread::Get()->Send(new ExtensionHostMsg_UnloadAck(extension_id)); 1003 RenderThread::Get()->Send(new ExtensionHostMsg_UnloadAck(extension_id));
1002 } 1004 }
1003 1005
1006 void ExtensionDispatcher::OnCancelUnload(const std::string& extension_id) {
1007 ListValue args;
1008 args.Set(0, Value::CreateStringValue(kOnSuspendCanceledEvent));
1009 args.Set(1, Value::CreateStringValue("[]"));
1010 v8_context_set_.DispatchChromeHiddenMethod(
1011 extension_id, kEventDispatchFunction, args, NULL, GURL());
1012 }
1013
1004 Feature::Context ExtensionDispatcher::ClassifyJavaScriptContext( 1014 Feature::Context ExtensionDispatcher::ClassifyJavaScriptContext(
1005 const std::string& extension_id, 1015 const std::string& extension_id,
1006 int extension_group, 1016 int extension_group,
1007 const ExtensionURLInfo& url_info) { 1017 const ExtensionURLInfo& url_info) {
1008 if (extension_group == EXTENSION_GROUP_CONTENT_SCRIPTS) 1018 if (extension_group == EXTENSION_GROUP_CONTENT_SCRIPTS)
1009 return Feature::CONTENT_SCRIPT_CONTEXT; 1019 return Feature::CONTENT_SCRIPT_CONTEXT;
1010 1020
1011 // We have an explicit check for sandboxed pages first since: 1021 // We have an explicit check for sandboxed pages first since:
1012 // 1. Sandboxed pages run in the same process as regular extension pages, so 1022 // 1. Sandboxed pages run in the same process as regular extension pages, so
1013 // the extension is considered active. 1023 // the extension is considered active.
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
1070 // APIs, they don't get extension bindings injected. If we end up here it 1080 // APIs, they don't get extension bindings injected. If we end up here it
1071 // means that a sandboxed page somehow managed to invoke an API anyway, so 1081 // means that a sandboxed page somehow managed to invoke an API anyway, so
1072 // we should abort. 1082 // we should abort.
1073 WebKit::WebFrame* frame = context->web_frame(); 1083 WebKit::WebFrame* frame = context->web_frame();
1074 ExtensionURLInfo url_info(frame->document().securityOrigin(), 1084 ExtensionURLInfo url_info(frame->document().securityOrigin(),
1075 extensions::UserScriptSlave::GetDataSourceURLForFrame(frame)); 1085 extensions::UserScriptSlave::GetDataSourceURLForFrame(frame));
1076 CHECK(!extensions_.IsSandboxedPage(url_info)); 1086 CHECK(!extensions_.IsSandboxedPage(url_info));
1077 1087
1078 return true; 1088 return true;
1079 } 1089 }
OLDNEW
« no previous file with comments | « chrome/renderer/extensions/extension_dispatcher.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698