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

Side by Side Diff: chrome/browser/extensions/script_executor.cc

Issue 270153004: Introduce ActiveScriptController; track active extension scripts (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Kalman's Created 6 years, 7 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/browser/extensions/script_executor.h" 5 #include "chrome/browser/extensions/script_executor.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/pickle.h" 9 #include "base/pickle.h"
10 #include "chrome/browser/extensions/active_script_controller.h"
11 #include "chrome/browser/extensions/location_bar_controller.h"
12 #include "chrome/browser/extensions/tab_helper.h"
13 #include "content/public/browser/navigation_controller.h"
14 #include "content/public/browser/navigation_entry.h"
10 #include "content/public/browser/render_view_host.h" 15 #include "content/public/browser/render_view_host.h"
11 #include "content/public/browser/web_contents.h" 16 #include "content/public/browser/web_contents.h"
12 #include "content/public/browser/web_contents_observer.h" 17 #include "content/public/browser/web_contents_observer.h"
13 #include "extensions/common/extension_messages.h" 18 #include "extensions/common/extension_messages.h"
14 #include "ipc/ipc_message.h" 19 #include "ipc/ipc_message.h"
15 #include "ipc/ipc_message_macros.h" 20 #include "ipc/ipc_message_macros.h"
16 21
17 namespace base { 22 namespace base {
18 class ListValue; 23 class ListValue;
19 } // namespace base 24 } // namespace base
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 const std::string& code, 118 const std::string& code,
114 ScriptExecutor::FrameScope frame_scope, 119 ScriptExecutor::FrameScope frame_scope,
115 UserScript::RunLocation run_at, 120 UserScript::RunLocation run_at,
116 ScriptExecutor::WorldType world_type, 121 ScriptExecutor::WorldType world_type,
117 ScriptExecutor::ProcessType process_type, 122 ScriptExecutor::ProcessType process_type,
118 const GURL& webview_src, 123 const GURL& webview_src,
119 const GURL& file_url, 124 const GURL& file_url,
120 bool user_gesture, 125 bool user_gesture,
121 ScriptExecutor::ResultType result_type, 126 ScriptExecutor::ResultType result_type,
122 const ExecuteScriptCallback& callback) { 127 const ExecuteScriptCallback& callback) {
128 LocationBarController* location_bar_controller =
129 TabHelper::FromWebContents(web_contents_)->location_bar_controller();
130 // TODO(rdevlin.cronin): Now, this is just a notification. Soon, it should
131 // block until the user gives the OK to execute.
132 location_bar_controller->active_script_controller()->NotifyScriptExecuting(
133 extension_id,
134 web_contents_->GetController().GetVisibleEntry()->GetPageID());
not at google - send to devlin 2014/05/08 20:47:09 now I remember why the old code implemented Script
Devlin 2014/05/08 23:01:00 Yeah, I was debating it. But wanted to keep the C
135
123 ExtensionMsg_ExecuteCode_Params params; 136 ExtensionMsg_ExecuteCode_Params params;
124 params.request_id = next_request_id_++; 137 params.request_id = next_request_id_++;
125 params.extension_id = extension_id; 138 params.extension_id = extension_id;
126 params.is_javascript = (script_type == JAVASCRIPT); 139 params.is_javascript = (script_type == JAVASCRIPT);
127 params.code = code; 140 params.code = code;
128 params.all_frames = (frame_scope == ALL_FRAMES); 141 params.all_frames = (frame_scope == ALL_FRAMES);
129 params.run_at = static_cast<int>(run_at); 142 params.run_at = static_cast<int>(run_at);
130 params.in_main_world = (world_type == MAIN_WORLD); 143 params.in_main_world = (world_type == MAIN_WORLD);
131 params.is_web_view = (process_type == WEB_VIEW_PROCESS); 144 params.is_web_view = (process_type == WEB_VIEW_PROCESS);
132 params.webview_src = webview_src; 145 params.webview_src = webview_src;
133 params.file_url = file_url; 146 params.file_url = file_url;
134 params.wants_result = (result_type == JSON_SERIALIZED_RESULT); 147 params.wants_result = (result_type == JSON_SERIALIZED_RESULT);
135 params.user_gesture = user_gesture; 148 params.user_gesture = user_gesture;
136 149
137 // Handler handles IPCs and deletes itself on completion. 150 // Handler handles IPCs and deletes itself on completion.
138 new Handler(script_observers_, web_contents_, params, callback); 151 new Handler(script_observers_, web_contents_, params, callback);
139 } 152 }
140 153
141 } // namespace extensions 154 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698