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

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

Issue 7552028: Injected CSS localization fix (see bug no.) (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Updated. Created 9 years, 4 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 #ifndef CHROME_BROWSER_EXTENSIONS_EXECUTE_CODE_IN_TAB_FUNCTION_H__ 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXECUTE_CODE_IN_TAB_FUNCTION_H__
6 #define CHROME_BROWSER_EXTENSIONS_EXECUTE_CODE_IN_TAB_FUNCTION_H__ 6 #define CHROME_BROWSER_EXTENSIONS_EXECUTE_CODE_IN_TAB_FUNCTION_H__
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
11 #include "chrome/browser/extensions/extension_function.h" 11 #include "chrome/browser/extensions/extension_function.h"
12 #include "chrome/common/extensions/extension_resource.h" 12 #include "chrome/common/extensions/extension_resource.h"
13 #include "content/browser/tab_contents/tab_contents_observer.h" 13 #include "content/browser/tab_contents/tab_contents_observer.h"
14 14
15 class MessageLoop;
16
15 // Implement API call tabs.executeScript and tabs.insertCSS. 17 // Implement API call tabs.executeScript and tabs.insertCSS.
16 class ExecuteCodeInTabFunction : public AsyncExtensionFunction, 18 class ExecuteCodeInTabFunction : public AsyncExtensionFunction,
17 public TabContentsObserver { 19 public TabContentsObserver {
18 public: 20 public:
19 ExecuteCodeInTabFunction(); 21 ExecuteCodeInTabFunction();
20 virtual ~ExecuteCodeInTabFunction(); 22 virtual ~ExecuteCodeInTabFunction();
21 23
22 private: 24 private:
23 virtual bool RunImpl(); 25 virtual bool RunImpl();
24 26
25 // TabContentsObserver overrides. 27 // TabContentsObserver overrides.
26 virtual bool OnMessageReceived(const IPC::Message& message); 28 virtual bool OnMessageReceived(const IPC::Message& message);
27 29
28 // Message handler. 30 // Message handler.
29 void OnExecuteCodeFinished(int request_id, bool success, 31 void OnExecuteCodeFinished(int request_id, bool success,
30 const std::string& error); 32 const std::string& error);
31 33
32 // Called when contents from the file whose path is specified in JSON 34 // Called when contents from the file whose path is specified in JSON
33 // arguments has been loaded. 35 // arguments has been loaded.
34 void DidLoadFile(bool success, const std::string& data); 36 void DidLoadFile(bool success, const std::string& data);
35 37
38 // Runs on FILE thread. Loads message bundles for the extension and
39 // localizes the CSS data. Calls back DidLoadAndLocalizeFile on the UI thread.
40 void LocalizeCSS(
41 const std::string& data,
42 const std::string& extension_id,
43 const FilePath& extension_path,
44 const std::string& extension_default_locale,
45 MessageLoop* origin_loop);
46
47 // Called when contents from the loaded file have been localized.
48 void DidLoadAndLocalizeFile(bool success, const std::string& data);
49
36 // Run in UI thread. Code string contains the code to be executed. Returns 50 // Run in UI thread. Code string contains the code to be executed. Returns
37 // true on success. If true is returned, this does an AddRef. 51 // true on success. If true is returned, this does an AddRef.
38 bool Execute(const std::string& code_string); 52 bool Execute(const std::string& code_string);
39 53
40 // Id of tab which executes code. 54 // Id of tab which executes code.
41 int execute_tab_id_; 55 int execute_tab_id_;
42 56
43 // Contains extension resource built from path of file which is 57 // Contains extension resource built from path of file which is
44 // specified in JSON arguments. 58 // specified in JSON arguments.
45 ExtensionResource resource_; 59 ExtensionResource resource_;
46 60
47 // If all_frames_ is true, script or CSS text would be injected 61 // If all_frames_ is true, script or CSS text would be injected
48 // to all frames; Otherwise only injected to top main frame. 62 // to all frames; Otherwise only injected to top main frame.
49 bool all_frames_; 63 bool all_frames_;
50 }; 64 };
51 65
52 class TabsExecuteScriptFunction : public ExecuteCodeInTabFunction { 66 class TabsExecuteScriptFunction : public ExecuteCodeInTabFunction {
53 DECLARE_EXTENSION_FUNCTION_NAME("tabs.executeScript") 67 DECLARE_EXTENSION_FUNCTION_NAME("tabs.executeScript")
54 }; 68 };
55 69
56 class TabsInsertCSSFunction : public ExecuteCodeInTabFunction { 70 class TabsInsertCSSFunction : public ExecuteCodeInTabFunction {
57 DECLARE_EXTENSION_FUNCTION_NAME("tabs.insertCSS") 71 DECLARE_EXTENSION_FUNCTION_NAME("tabs.insertCSS")
58 }; 72 };
59 73
60 #endif // CHROME_BROWSER_EXTENSIONS_EXECUTE_CODE_IN_TAB_FUNCTION_H__ 74 #endif // CHROME_BROWSER_EXTENSIONS_EXECUTE_CODE_IN_TAB_FUNCTION_H__
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698