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

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

Issue 10375021: Move Extension into extensions namespace (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Take 6 Created 8 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
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/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"
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 CHECK(!success); 150 CHECK(!success);
151 error_ = error; 151 error_ = error;
152 } 152 }
153 153
154 SendResponse(success); 154 SendResponse(success);
155 } 155 }
156 156
157 void ExecuteCodeInTabFunction::DidLoadFile(bool success, 157 void ExecuteCodeInTabFunction::DidLoadFile(bool success,
158 const std::string& data) { 158 const std::string& data) {
159 std::string function_name = name(); 159 std::string function_name = name();
160 const Extension* extension = GetExtension(); 160 const extensions::Extension* extension = GetExtension();
161 161
162 // Check if the file is CSS and needs localization. 162 // Check if the file is CSS and needs localization.
163 if (success && 163 if (success &&
164 function_name == TabsInsertCSSFunction::function_name() && 164 function_name == TabsInsertCSSFunction::function_name() &&
165 extension != NULL && 165 extension != NULL &&
166 data.find(ExtensionMessageBundle::kMessageBegin) != std::string::npos) { 166 data.find(ExtensionMessageBundle::kMessageBegin) != std::string::npos) {
167 BrowserThread::PostTask( 167 BrowserThread::PostTask(
168 BrowserThread::FILE, FROM_HERE, 168 BrowserThread::FILE, FROM_HERE,
169 base::Bind(&ExecuteCodeInTabFunction::LocalizeCSS, this, 169 base::Bind(&ExecuteCodeInTabFunction::LocalizeCSS, this,
170 data, 170 data,
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 224
225 bool success = ExtensionTabUtil::GetTabById( 225 bool success = ExtensionTabUtil::GetTabById(
226 execute_tab_id_, profile(), include_incognito(), &browser, NULL, 226 execute_tab_id_, profile(), include_incognito(), &browser, NULL,
227 &contents, NULL) && contents && browser; 227 &contents, NULL) && contents && browser;
228 228
229 if (!success) { 229 if (!success) {
230 SendResponse(false); 230 SendResponse(false);
231 return false; 231 return false;
232 } 232 }
233 233
234 const Extension* extension = GetExtension(); 234 const extensions::Extension* extension = GetExtension();
235 if (!extension) { 235 if (!extension) {
236 SendResponse(false); 236 SendResponse(false);
237 return false; 237 return false;
238 } 238 }
239 239
240 ScriptExecutor::ScriptType script_type = ScriptExecutor::JAVASCRIPT; 240 ScriptExecutor::ScriptType script_type = ScriptExecutor::JAVASCRIPT;
241 std::string function_name = name(); 241 std::string function_name = name();
242 if (function_name == TabsInsertCSSFunction::function_name()) { 242 if (function_name == TabsInsertCSSFunction::function_name()) {
243 script_type = ScriptExecutor::CSS; 243 script_type = ScriptExecutor::CSS;
244 } else if (function_name != TabsExecuteScriptFunction::function_name()) { 244 } else if (function_name != TabsExecuteScriptFunction::function_name()) {
245 NOTREACHED(); 245 NOTREACHED();
246 } 246 }
247 247
248 contents->extension_tab_helper()->script_executor()->ExecuteScript( 248 contents->extension_tab_helper()->script_executor()->ExecuteScript(
249 extension->id(), 249 extension->id(),
250 script_type, 250 script_type,
251 code_string, 251 code_string,
252 all_frames_ ? ScriptExecutor::ALL_FRAMES : ScriptExecutor::TOP_FRAME, 252 all_frames_ ? ScriptExecutor::ALL_FRAMES : ScriptExecutor::TOP_FRAME,
253 run_at_, 253 run_at_,
254 ScriptExecutor::ISOLATED_WORLD, 254 ScriptExecutor::ISOLATED_WORLD,
255 base::Bind(&ExecuteCodeInTabFunction::OnExecuteCodeFinished, this)); 255 base::Bind(&ExecuteCodeInTabFunction::OnExecuteCodeFinished, this));
256 return true; 256 return true;
257 } 257 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/default_apps.cc ('k') | chrome/browser/extensions/extension_activity_log.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698