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

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

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

Powered by Google App Engine
This is Rietveld 408576698