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

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

Issue 421005: Make executeScript and insertCSS inject code into all frames.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 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
« no previous file with comments | « no previous file | chrome/browser/extensions/execute_code_in_tab_function.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/file_path.h" 11 #include "base/file_path.h"
12 #include "chrome/browser/extensions/extension_function.h" 12 #include "chrome/browser/extensions/extension_function.h"
13 #include "chrome/common/extensions/extension_resource.h" 13 #include "chrome/common/extensions/extension_resource.h"
14 #include "chrome/common/notification_service.h" 14 #include "chrome/common/notification_service.h"
15 #include "chrome/common/notification_registrar.h" 15 #include "chrome/common/notification_registrar.h"
16 16
17 class MessageLoop; 17 class MessageLoop;
18 18
19 // Implement API call tabs.executeScript and tabs.insertCSS. 19 // Implement API call tabs.executeScript and tabs.insertCSS.
20 class ExecuteCodeInTabFunction : public AsyncExtensionFunction, 20 class ExecuteCodeInTabFunction : public AsyncExtensionFunction,
21 public NotificationObserver { 21 public NotificationObserver {
22 public: 22 public:
23 ExecuteCodeInTabFunction() : execute_tab_id_(-1) {} 23 ExecuteCodeInTabFunction() : execute_tab_id_(-1),
24 all_frames_(false) {}
24 25
25 private: 26 private:
26 virtual bool RunImpl(); 27 virtual bool RunImpl();
27 28
28 virtual void Observe(NotificationType type, 29 virtual void Observe(NotificationType type,
29 const NotificationSource& source, 30 const NotificationSource& source,
30 const NotificationDetails& details); 31 const NotificationDetails& details);
31 32
32 // Called when contents from the file whose path is specified in JSON 33 // Called when contents from the file whose path is specified in JSON
33 // arguments has been loaded. 34 // arguments has been loaded.
34 void DidLoadFile(bool success, const std::string& data); 35 void DidLoadFile(bool success, const std::string& data);
35 36
36 // Run in UI thread. Code string contains the code to be executed. 37 // Run in UI thread. Code string contains the code to be executed.
37 void Execute(const std::string& code_string); 38 void Execute(const std::string& code_string);
38 39
39 NotificationRegistrar registrar_; 40 NotificationRegistrar registrar_;
40 41
41 // Id of tab which executes code. 42 // Id of tab which executes code.
42 int execute_tab_id_; 43 int execute_tab_id_;
43 44
44 // Contains extension resource built from path of file which is 45 // Contains extension resource built from path of file which is
45 // specified in JSON arguments. 46 // specified in JSON arguments.
46 ExtensionResource resource_; 47 ExtensionResource resource_;
48
49 // If all_frames_ is true, script or CSS text would be injected
50 // to all frames; Otherwise only injected to top main frame.
51 bool all_frames_;
47 }; 52 };
48 53
49 class TabsExecuteScriptFunction : public ExecuteCodeInTabFunction { 54 class TabsExecuteScriptFunction : public ExecuteCodeInTabFunction {
50 DECLARE_EXTENSION_FUNCTION_NAME("tabs.executeScript") 55 DECLARE_EXTENSION_FUNCTION_NAME("tabs.executeScript")
51 }; 56 };
52 57
53 class TabsInsertCSSFunction : public ExecuteCodeInTabFunction { 58 class TabsInsertCSSFunction : public ExecuteCodeInTabFunction {
54 DECLARE_EXTENSION_FUNCTION_NAME("tabs.insertCSS") 59 DECLARE_EXTENSION_FUNCTION_NAME("tabs.insertCSS")
55 }; 60 };
56 61
57 #endif // CHROME_BROWSER_EXTENSIONS_EXECUTE_CODE_IN_TAB_FUNCTION_H__ 62 #endif // CHROME_BROWSER_EXTENSIONS_EXECUTE_CODE_IN_TAB_FUNCTION_H__
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/execute_code_in_tab_function.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698