| 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_SCRIPT_EXECUTOR_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_SCRIPT_EXECUTOR_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_SCRIPT_EXECUTOR_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_SCRIPT_EXECUTOR_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/callback_forward.h" | 10 #include "base/callback_forward.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 JAVASCRIPT, | 42 JAVASCRIPT, |
| 43 CSS, | 43 CSS, |
| 44 }; | 44 }; |
| 45 | 45 |
| 46 // The scope of the script injection across the frames. | 46 // The scope of the script injection across the frames. |
| 47 enum FrameScope { | 47 enum FrameScope { |
| 48 TOP_FRAME, | 48 TOP_FRAME, |
| 49 ALL_FRAMES, | 49 ALL_FRAMES, |
| 50 }; | 50 }; |
| 51 | 51 |
| 52 // Whether to insert the script in about: frames when its origin matches |
| 53 // the extension's host permissions. |
| 54 enum MatchAboutBlank { |
| 55 DONT_MATCH_ABOUT_BLANK, |
| 56 MATCH_ABOUT_BLANK, |
| 57 }; |
| 58 |
| 52 // The type of world to inject into (main world, or its own isolated world). | 59 // The type of world to inject into (main world, or its own isolated world). |
| 53 enum WorldType { | 60 enum WorldType { |
| 54 MAIN_WORLD, | 61 MAIN_WORLD, |
| 55 ISOLATED_WORLD, | 62 ISOLATED_WORLD, |
| 56 }; | 63 }; |
| 57 | 64 |
| 58 // The type of process the target is. | 65 // The type of process the target is. |
| 59 enum ProcessType { | 66 enum ProcessType { |
| 60 DEFAULT_PROCESS, | 67 DEFAULT_PROCESS, |
| 61 WEB_VIEW_PROCESS, | 68 WEB_VIEW_PROCESS, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 76 // Executes a script. The arguments match ExtensionMsg_ExecuteCode_Params in | 83 // Executes a script. The arguments match ExtensionMsg_ExecuteCode_Params in |
| 77 // extension_messages.h (request_id is populated automatically). | 84 // extension_messages.h (request_id is populated automatically). |
| 78 // | 85 // |
| 79 // |callback| will always be called even if the IPC'd renderer is destroyed | 86 // |callback| will always be called even if the IPC'd renderer is destroyed |
| 80 // before a response is received (in this case the callback will be with a | 87 // before a response is received (in this case the callback will be with a |
| 81 // failure and appropriate error message). | 88 // failure and appropriate error message). |
| 82 void ExecuteScript(const std::string& extension_id, | 89 void ExecuteScript(const std::string& extension_id, |
| 83 ScriptType script_type, | 90 ScriptType script_type, |
| 84 const std::string& code, | 91 const std::string& code, |
| 85 FrameScope frame_scope, | 92 FrameScope frame_scope, |
| 93 MatchAboutBlank match_about_blank, |
| 86 UserScript::RunLocation run_at, | 94 UserScript::RunLocation run_at, |
| 87 WorldType world_type, | 95 WorldType world_type, |
| 88 ProcessType process_type, | 96 ProcessType process_type, |
| 89 const GURL& webview_src, | 97 const GURL& webview_src, |
| 90 const GURL& file_url, | 98 const GURL& file_url, |
| 91 bool user_gesture, | 99 bool user_gesture, |
| 92 ResultType result_type, | 100 ResultType result_type, |
| 93 const ExecuteScriptCallback& callback); | 101 const ExecuteScriptCallback& callback); |
| 94 | 102 |
| 95 private: | 103 private: |
| 96 // The next value to use for request_id in ExtensionMsg_ExecuteCode_Params. | 104 // The next value to use for request_id in ExtensionMsg_ExecuteCode_Params. |
| 97 int next_request_id_; | 105 int next_request_id_; |
| 98 | 106 |
| 99 content::WebContents* web_contents_; | 107 content::WebContents* web_contents_; |
| 100 | 108 |
| 101 ObserverList<TabHelper::ScriptExecutionObserver>* script_observers_; | 109 ObserverList<TabHelper::ScriptExecutionObserver>* script_observers_; |
| 102 }; | 110 }; |
| 103 | 111 |
| 104 } // namespace extensions | 112 } // namespace extensions |
| 105 | 113 |
| 106 #endif // CHROME_BROWSER_EXTENSIONS_SCRIPT_EXECUTOR_H_ | 114 #endif // CHROME_BROWSER_EXTENSIONS_SCRIPT_EXECUTOR_H_ |
| OLD | NEW |