| 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" | |
| 15 | 14 |
| 16 // Implement API call tabs.executeScript and tabs.insertCSS. | 15 // Implement API call tabs.executeScript and tabs.insertCSS. |
| 17 class ExecuteCodeInTabFunction : public AsyncExtensionFunction, | 16 class ExecuteCodeInTabFunction : public AsyncExtensionFunction { |
| 18 public content::WebContentsObserver { | |
| 19 public: | 17 public: |
| 20 ExecuteCodeInTabFunction(); | 18 ExecuteCodeInTabFunction(); |
| 21 | 19 |
| 22 protected: | 20 protected: |
| 23 virtual ~ExecuteCodeInTabFunction(); | 21 virtual ~ExecuteCodeInTabFunction(); |
| 24 | 22 |
| 25 // ExtensionFunction: | 23 // ExtensionFunction: |
| 26 virtual bool RunImpl() OVERRIDE; | 24 virtual bool RunImpl() OVERRIDE; |
| 27 | 25 |
| 28 private: | 26 private: |
| 29 // content::WebContentsObserver overrides. | |
| 30 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | |
| 31 | |
| 32 // Message handler. | 27 // Message handler. |
| 33 void OnExecuteCodeFinished(int request_id, bool success, | 28 void OnExecuteCodeFinished(bool success, const std::string& error); |
| 34 const std::string& error); | |
| 35 | 29 |
| 36 // Called when contents from the file whose path is specified in JSON | 30 // Called when contents from the file whose path is specified in JSON |
| 37 // arguments has been loaded. | 31 // arguments has been loaded. |
| 38 void DidLoadFile(bool success, const std::string& data); | 32 void DidLoadFile(bool success, const std::string& data); |
| 39 | 33 |
| 40 // Runs on FILE thread. Loads message bundles for the extension and | 34 // Runs on FILE thread. Loads message bundles for the extension and |
| 41 // localizes the CSS data. Calls back DidLoadAndLocalizeFile on the UI thread. | 35 // localizes the CSS data. Calls back DidLoadAndLocalizeFile on the UI thread. |
| 42 void LocalizeCSS( | 36 void LocalizeCSS( |
| 43 const std::string& data, | 37 const std::string& data, |
| 44 const std::string& extension_id, | 38 const std::string& extension_id, |
| (...skipping 30 matching lines...) Expand all Loading... |
| 75 }; | 69 }; |
| 76 | 70 |
| 77 class TabsInsertCSSFunction : public ExecuteCodeInTabFunction { | 71 class TabsInsertCSSFunction : public ExecuteCodeInTabFunction { |
| 78 private: | 72 private: |
| 79 virtual ~TabsInsertCSSFunction() {} | 73 virtual ~TabsInsertCSSFunction() {} |
| 80 | 74 |
| 81 DECLARE_EXTENSION_FUNCTION_NAME("tabs.insertCSS") | 75 DECLARE_EXTENSION_FUNCTION_NAME("tabs.insertCSS") |
| 82 }; | 76 }; |
| 83 | 77 |
| 84 #endif // CHROME_BROWSER_EXTENSIONS_EXECUTE_CODE_IN_TAB_FUNCTION_H__ | 78 #endif // CHROME_BROWSER_EXTENSIONS_EXECUTE_CODE_IN_TAB_FUNCTION_H__ |
| OLD | NEW |