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

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

Issue 11312228: Move extension_error_utils.* and url_pattern_set.* into (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: hate Created 8 years, 1 month 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/api/tabs/execute_code_in_tab_function.h" 5 #include "chrome/browser/extensions/api/tabs/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/api/tabs/tabs.h" 10 #include "chrome/browser/extensions/api/tabs/tabs.h"
11 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" 11 #include "chrome/browser/extensions/api/tabs/tabs_constants.h"
12 #include "chrome/browser/extensions/extension_service.h" 12 #include "chrome/browser/extensions/extension_service.h"
13 #include "chrome/browser/extensions/extension_tab_util.h" 13 #include "chrome/browser/extensions/extension_tab_util.h"
14 #include "chrome/browser/extensions/tab_helper.h"
15 #include "chrome/browser/extensions/file_reader.h" 14 #include "chrome/browser/extensions/file_reader.h"
16 #include "chrome/browser/extensions/script_executor.h" 15 #include "chrome/browser/extensions/script_executor.h"
16 #include "chrome/browser/extensions/tab_helper.h"
17 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
18 #include "chrome/browser/ui/browser.h" 18 #include "chrome/browser/ui/browser.h"
19 #include "chrome/common/extensions/api/tabs.h" 19 #include "chrome/common/extensions/api/tabs.h"
20 #include "chrome/common/extensions/extension.h" 20 #include "chrome/common/extensions/extension.h"
21 #include "chrome/common/extensions/extension_constants.h" 21 #include "chrome/common/extensions/extension_constants.h"
22 #include "chrome/common/extensions/extension_error_utils.h"
23 #include "chrome/common/extensions/extension_file_util.h" 22 #include "chrome/common/extensions/extension_file_util.h"
24 #include "chrome/common/extensions/extension_l10n_util.h" 23 #include "chrome/common/extensions/extension_l10n_util.h"
25 #include "chrome/common/extensions/extension_manifest_constants.h" 24 #include "chrome/common/extensions/extension_manifest_constants.h"
26 #include "chrome/common/extensions/extension_messages.h" 25 #include "chrome/common/extensions/extension_messages.h"
27 #include "chrome/common/extensions/message_bundle.h" 26 #include "chrome/common/extensions/message_bundle.h"
28 #include "content/public/browser/render_view_host.h" 27 #include "content/public/browser/render_view_host.h"
29 #include "content/public/browser/web_contents.h" 28 #include "content/public/browser/web_contents.h"
29 #include "extensions/common/error_utils.h"
30 30
31 using content::BrowserThread; 31 using content::BrowserThread;
32 using extensions::api::tabs::InjectDetails; 32 using extensions::api::tabs::InjectDetails;
33 using extensions::ErrorUtils;
33 using extensions::ScriptExecutor; 34 using extensions::ScriptExecutor;
34 using extensions::UserScript; 35 using extensions::UserScript;
35 36
36 namespace keys = extensions::tabs_constants; 37 namespace keys = extensions::tabs_constants;
37 38
38 ExecuteCodeInTabFunction::ExecuteCodeInTabFunction() 39 ExecuteCodeInTabFunction::ExecuteCodeInTabFunction()
39 : execute_tab_id_(-1) { 40 : execute_tab_id_(-1) {
40 } 41 }
41 42
42 ExecuteCodeInTabFunction::~ExecuteCodeInTabFunction() {} 43 ExecuteCodeInTabFunction::~ExecuteCodeInTabFunction() {}
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 204
204 void ExecuteCodeInTabFunction::DidLoadAndLocalizeFile(bool success, 205 void ExecuteCodeInTabFunction::DidLoadAndLocalizeFile(bool success,
205 const std::string& data) { 206 const std::string& data) {
206 if (success) { 207 if (success) {
207 if (!Execute(data)) 208 if (!Execute(data))
208 SendResponse(false); 209 SendResponse(false);
209 } else { 210 } else {
210 #if defined(OS_POSIX) 211 #if defined(OS_POSIX)
211 // TODO(viettrungluu): bug: there's no particular reason the path should be 212 // TODO(viettrungluu): bug: there's no particular reason the path should be
212 // UTF-8, in which case this may fail. 213 // UTF-8, in which case this may fail.
213 error_ = ExtensionErrorUtils::FormatErrorMessage(keys::kLoadFileError, 214 error_ = ErrorUtils::FormatErrorMessage(keys::kLoadFileError,
214 resource_.relative_path().value()); 215 resource_.relative_path().value());
215 #elif defined(OS_WIN) 216 #elif defined(OS_WIN)
216 error_ = ExtensionErrorUtils::FormatErrorMessage(keys::kLoadFileError, 217 error_ = ErrorUtils::FormatErrorMessage(keys::kLoadFileError,
217 WideToUTF8(resource_.relative_path().value())); 218 WideToUTF8(resource_.relative_path().value()));
218 #endif // OS_WIN 219 #endif // OS_WIN
219 SendResponse(false); 220 SendResponse(false);
220 } 221 }
221 } 222 }
222 223
223 bool ExecuteCodeInTabFunction::Execute(const std::string& code_string) { 224 bool ExecuteCodeInTabFunction::Execute(const std::string& code_string) {
224 content::WebContents* contents = NULL; 225 content::WebContents* contents = NULL;
225 Browser* browser = NULL; 226 Browser* browser = NULL;
226 227
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 script_executor()->ExecuteScript( 268 script_executor()->ExecuteScript(
268 extension->id(), 269 extension->id(),
269 script_type, 270 script_type,
270 code_string, 271 code_string,
271 frame_scope, 272 frame_scope,
272 run_at, 273 run_at,
273 ScriptExecutor::ISOLATED_WORLD, 274 ScriptExecutor::ISOLATED_WORLD,
274 base::Bind(&ExecuteCodeInTabFunction::OnExecuteCodeFinished, this)); 275 base::Bind(&ExecuteCodeInTabFunction::OnExecuteCodeFinished, this));
275 return true; 276 return true;
276 } 277 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/proxy/proxy_api_helpers.cc ('k') | chrome/browser/extensions/api/tabs/tabs.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698