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

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

Issue 9030032: Get rid of a bunch of tab_contents.h includes from chrome. These are all trivial changes to use W... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix cros Created 8 years, 11 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/execute_code_in_tab_function.h" 5 #include "chrome/browser/extensions/execute_code_in_tab_function.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/extensions/extension_service.h" 10 #include "chrome/browser/extensions/extension_service.h"
11 #include "chrome/browser/extensions/extension_tab_util.h" 11 #include "chrome/browser/extensions/extension_tab_util.h"
12 #include "chrome/browser/extensions/extension_tabs_module.h" 12 #include "chrome/browser/extensions/extension_tabs_module.h"
13 #include "chrome/browser/extensions/extension_tabs_module_constants.h" 13 #include "chrome/browser/extensions/extension_tabs_module_constants.h"
14 #include "chrome/browser/extensions/file_reader.h" 14 #include "chrome/browser/extensions/file_reader.h"
15 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/browser/ui/browser.h" 16 #include "chrome/browser/ui/browser.h"
17 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 17 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
18 #include "chrome/common/extensions/extension.h" 18 #include "chrome/common/extensions/extension.h"
19 #include "chrome/common/extensions/extension_constants.h" 19 #include "chrome/common/extensions/extension_constants.h"
20 #include "chrome/common/extensions/extension_error_utils.h" 20 #include "chrome/common/extensions/extension_error_utils.h"
21 #include "chrome/common/extensions/extension_file_util.h" 21 #include "chrome/common/extensions/extension_file_util.h"
22 #include "chrome/common/extensions/extension_l10n_util.h" 22 #include "chrome/common/extensions/extension_l10n_util.h"
23 #include "chrome/common/extensions/extension_message_bundle.h" 23 #include "chrome/common/extensions/extension_message_bundle.h"
24 #include "chrome/common/extensions/extension_messages.h" 24 #include "chrome/common/extensions/extension_messages.h"
25 #include "content/browser/renderer_host/render_view_host.h" 25 #include "content/browser/renderer_host/render_view_host.h"
26 #include "content/browser/renderer_host/render_view_host.h" 26 #include "content/browser/renderer_host/render_view_host.h"
27 #include "content/browser/tab_contents/tab_contents.h" 27 #include "content/public/browser/web_contents.h"
28 28
29 using content::BrowserThread; 29 using content::BrowserThread;
30 30
31 namespace keys = extension_tabs_module_constants; 31 namespace keys = extension_tabs_module_constants;
32 32
33 ExecuteCodeInTabFunction::ExecuteCodeInTabFunction() 33 ExecuteCodeInTabFunction::ExecuteCodeInTabFunction()
34 : execute_tab_id_(-1), 34 : execute_tab_id_(-1),
35 all_frames_(false) { 35 all_frames_(false) {
36 } 36 }
37 37
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 &browser, NULL, &contents, NULL)) { 80 &browser, NULL, &contents, NULL)) {
81 return false; 81 return false;
82 } 82 }
83 } 83 }
84 84
85 // NOTE: This can give the wrong answer due to race conditions, but it is OK, 85 // NOTE: This can give the wrong answer due to race conditions, but it is OK,
86 // we check again in the renderer. 86 // we check again in the renderer.
87 CHECK(browser); 87 CHECK(browser);
88 CHECK(contents); 88 CHECK(contents);
89 if (!GetExtension()->CanExecuteScriptOnPage( 89 if (!GetExtension()->CanExecuteScriptOnPage(
90 contents->tab_contents()->GetURL(), NULL, &error_)) { 90 contents->web_contents()->GetURL(), NULL, &error_)) {
91 return false; 91 return false;
92 } 92 }
93 93
94 if (script_info->HasKey(keys::kAllFramesKey)) { 94 if (script_info->HasKey(keys::kAllFramesKey)) {
95 if (!script_info->GetBoolean(keys::kAllFramesKey, &all_frames_)) 95 if (!script_info->GetBoolean(keys::kAllFramesKey, &all_frames_))
96 return false; 96 return false;
97 } 97 }
98 98
99 std::string code_string; 99 std::string code_string;
100 if (script_info->HasKey(keys::kCodeKey)) { 100 if (script_info->HasKey(keys::kCodeKey)) {
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 DCHECK(false); 217 DCHECK(false);
218 } 218 }
219 219
220 ExtensionMsg_ExecuteCode_Params params; 220 ExtensionMsg_ExecuteCode_Params params;
221 params.request_id = request_id(); 221 params.request_id = request_id();
222 params.extension_id = extension->id(); 222 params.extension_id = extension->id();
223 params.is_javascript = is_js_code; 223 params.is_javascript = is_js_code;
224 params.code = code_string; 224 params.code = code_string;
225 params.all_frames = all_frames_; 225 params.all_frames = all_frames_;
226 params.in_main_world = false; 226 params.in_main_world = false;
227 contents->tab_contents()->GetRenderViewHost()->Send( 227 contents->web_contents()->GetRenderViewHost()->Send(
228 new ExtensionMsg_ExecuteCode( 228 new ExtensionMsg_ExecuteCode(
229 contents->tab_contents()->GetRenderViewHost()->routing_id(), params)); 229 contents->web_contents()->GetRenderViewHost()->routing_id(), params));
230 230
231 Observe(contents->tab_contents()); 231 Observe(contents->web_contents());
232 AddRef(); // balanced in OnExecuteCodeFinished() 232 AddRef(); // balanced in OnExecuteCodeFinished()
233 return true; 233 return true;
234 } 234 }
235 235
236 bool ExecuteCodeInTabFunction::OnMessageReceived(const IPC::Message& message) { 236 bool ExecuteCodeInTabFunction::OnMessageReceived(const IPC::Message& message) {
237 if (message.type() != ExtensionHostMsg_ExecuteCodeFinished::ID) 237 if (message.type() != ExtensionHostMsg_ExecuteCodeFinished::ID)
238 return false; 238 return false;
239 239
240 int message_request_id; 240 int message_request_id;
241 void* iter = NULL; 241 void* iter = NULL;
(...skipping 18 matching lines...) Expand all
260 if (!error.empty()) { 260 if (!error.empty()) {
261 CHECK(!success); 261 CHECK(!success);
262 error_ = error; 262 error_ = error;
263 } 263 }
264 264
265 SendResponse(success); 265 SendResponse(success);
266 266
267 Observe(NULL); 267 Observe(NULL);
268 Release(); // balanced in Execute() 268 Release(); // balanced in Execute()
269 } 269 }
OLDNEW
« no previous file with comments | « chrome/browser/download/save_package_file_picker.cc ('k') | chrome/browser/extensions/extension_debugger_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698