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

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: 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 TabHelper* tab_helper = TabHelper::FromWebContents(web_contents_);
129 if (tab_helper) {
130 LocationBarController* location_bar_controller =
131 TabHelper::FromWebContents(web_contents_)->location_bar_controller();
132 // TODO(rdevlin.cronin): Now, this is just a notification. Soon, it should
133 // block until the user gives the OK to execute.
134 location_bar_controller->active_script_controller()->NotifyScriptExecuting(
135 extension_id,
136 web_contents_->GetController().GetVisibleEntry()->GetPageID());
137 }
138
123 ExtensionMsg_ExecuteCode_Params params; 139 ExtensionMsg_ExecuteCode_Params params;
124 params.request_id = next_request_id_++; 140 params.request_id = next_request_id_++;
125 params.extension_id = extension_id; 141 params.extension_id = extension_id;
126 params.is_javascript = (script_type == JAVASCRIPT); 142 params.is_javascript = (script_type == JAVASCRIPT);
127 params.code = code; 143 params.code = code;
128 params.all_frames = (frame_scope == ALL_FRAMES); 144 params.all_frames = (frame_scope == ALL_FRAMES);
129 params.run_at = static_cast<int>(run_at); 145 params.run_at = static_cast<int>(run_at);
130 params.in_main_world = (world_type == MAIN_WORLD); 146 params.in_main_world = (world_type == MAIN_WORLD);
131 params.is_web_view = (process_type == WEB_VIEW_PROCESS); 147 params.is_web_view = (process_type == WEB_VIEW_PROCESS);
132 params.webview_src = webview_src; 148 params.webview_src = webview_src;
133 params.file_url = file_url; 149 params.file_url = file_url;
134 params.wants_result = (result_type == JSON_SERIALIZED_RESULT); 150 params.wants_result = (result_type == JSON_SERIALIZED_RESULT);
135 params.user_gesture = user_gesture; 151 params.user_gesture = user_gesture;
136 152
137 // Handler handles IPCs and deletes itself on completion. 153 // Handler handles IPCs and deletes itself on completion.
138 new Handler(script_observers_, web_contents_, params, callback); 154 new Handler(script_observers_, web_contents_, params, callback);
139 } 155 }
140 156
141 } // namespace extensions 157 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/page_action_controller.cc ('k') | chrome/browser/extensions/tab_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698