| OLD | NEW |
| 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 #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 "chrome/common/extensions/user_script.h" | 13 #include "chrome/common/extensions/user_script.h" |
| 14 #include "content/public/browser/web_contents_observer.h" | 14 #include "content/public/browser/web_contents_observer.h" |
| 15 | 15 |
| 16 // Implement API call tabs.executeScript and tabs.insertCSS. | 16 // Implement API call tabs.executeScript and tabs.insertCSS. |
| 17 class ExecuteCodeInTabFunction : public AsyncExtensionFunction, | 17 class ExecuteCodeInTabFunction : public AsyncExtensionFunction, |
| 18 public content::WebContentsObserver { | 18 public content::WebContentsObserver { |
| 19 public: | 19 public: |
| 20 ExecuteCodeInTabFunction(); | 20 ExecuteCodeInTabFunction(); |
| 21 |
| 22 protected: |
| 21 virtual ~ExecuteCodeInTabFunction(); | 23 virtual ~ExecuteCodeInTabFunction(); |
| 22 | 24 |
| 23 private: | 25 // ExtensionFunction: |
| 24 virtual bool RunImpl() OVERRIDE; | 26 virtual bool RunImpl() OVERRIDE; |
| 25 | 27 |
| 28 private: |
| 26 // content::WebContentsObserver overrides. | 29 // content::WebContentsObserver overrides. |
| 27 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 30 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 28 | 31 |
| 29 // Message handler. | 32 // Message handler. |
| 30 void OnExecuteCodeFinished(int request_id, bool success, | 33 void OnExecuteCodeFinished(int request_id, bool success, |
| 31 const std::string& error); | 34 const std::string& error); |
| 32 | 35 |
| 33 // Called when contents from the file whose path is specified in JSON | 36 // Called when contents from the file whose path is specified in JSON |
| 34 // arguments has been loaded. | 37 // arguments has been loaded. |
| 35 void DidLoadFile(bool success, const std::string& data); | 38 void DidLoadFile(bool success, const std::string& data); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 58 | 61 |
| 59 // If all_frames_ is true, script or CSS text would be injected | 62 // If all_frames_ is true, script or CSS text would be injected |
| 60 // to all frames; Otherwise only injected to top main frame. | 63 // to all frames; Otherwise only injected to top main frame. |
| 61 bool all_frames_; | 64 bool all_frames_; |
| 62 | 65 |
| 63 // The intended time to run the script. | 66 // The intended time to run the script. |
| 64 UserScript::RunLocation run_at_; | 67 UserScript::RunLocation run_at_; |
| 65 }; | 68 }; |
| 66 | 69 |
| 67 class TabsExecuteScriptFunction : public ExecuteCodeInTabFunction { | 70 class TabsExecuteScriptFunction : public ExecuteCodeInTabFunction { |
| 71 private: |
| 72 virtual ~TabsExecuteScriptFunction() {} |
| 73 |
| 68 DECLARE_EXTENSION_FUNCTION_NAME("tabs.executeScript") | 74 DECLARE_EXTENSION_FUNCTION_NAME("tabs.executeScript") |
| 69 }; | 75 }; |
| 70 | 76 |
| 71 class TabsInsertCSSFunction : public ExecuteCodeInTabFunction { | 77 class TabsInsertCSSFunction : public ExecuteCodeInTabFunction { |
| 78 private: |
| 79 virtual ~TabsInsertCSSFunction() {} |
| 80 |
| 72 DECLARE_EXTENSION_FUNCTION_NAME("tabs.insertCSS") | 81 DECLARE_EXTENSION_FUNCTION_NAME("tabs.insertCSS") |
| 73 }; | 82 }; |
| 74 | 83 |
| 75 #endif // CHROME_BROWSER_EXTENSIONS_EXECUTE_CODE_IN_TAB_FUNCTION_H__ | 84 #endif // CHROME_BROWSER_EXTENSIONS_EXECUTE_CODE_IN_TAB_FUNCTION_H__ |
| OLD | NEW |