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 #include "chrome/browser/extensions/script_executor_impl.h" | 5 #include "chrome/browser/extensions/script_executor_impl.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/pickle.h" | 9 #include "base/pickle.h" |
10 #include "chrome/common/extensions/extension_messages.h" | 10 #include "chrome/common/extensions/extension_messages.h" |
11 #include "content/public/browser/render_view_host.h" | 11 #include "content/public/browser/render_view_host.h" |
12 #include "content/public/browser/web_contents.h" | 12 #include "content/public/browser/web_contents.h" |
13 #include "content/public/browser/web_contents_observer.h" | 13 #include "content/public/browser/web_contents_observer.h" |
14 #include "ipc/ipc_message.h" | 14 #include "ipc/ipc_message.h" |
15 #include "ipc/ipc_message_macros.h" | 15 #include "ipc/ipc_message_macros.h" |
16 | 16 |
17 namespace extensions { | 17 namespace extensions { |
18 | 18 |
19 namespace { | 19 namespace { |
20 | 20 |
21 const char* kRendererDestroyed = "The tab was closed."; | 21 const char* kRendererDestroyed = "The tab was closed."; |
22 | 22 |
23 // A handler for a single injection request. On creation this will send the | 23 // A handler for a single injection request. On creation this will send the |
24 // injection request to the renderer, and it will be destroyed after either the | 24 // injection request to the renderer, and it will be destroyed after either the |
25 // corresponding response comes from the renderer, or the renderer is destroyed. | 25 // corresponding response comes from the renderer, or the renderer is destroyed. |
26 class Handler : public content::WebContentsObserver { | 26 class Handler : public content::WebContentsObserver { |
27 public: | 27 public: |
28 Handler(content::WebContents* web_contents, | 28 Handler(content::WebContents* web_contents, |
29 const ExtensionMsg_ExecuteCode_Params params, | 29 const ExtensionMsg_ExecuteCode_Params& params, |
30 const ScriptExecutor::ExecuteScriptCallback& callback) | 30 const ScriptExecutor::ExecuteScriptCallback& callback) |
31 : content::WebContentsObserver(web_contents), | 31 : content::WebContentsObserver(web_contents), |
32 request_id_(params.request_id), | 32 request_id_(params.request_id), |
33 callback_(callback) { | 33 callback_(callback) { |
34 content::RenderViewHost* rvh = web_contents->GetRenderViewHost(); | 34 content::RenderViewHost* rvh = web_contents->GetRenderViewHost(); |
35 rvh->Send(new ExtensionMsg_ExecuteCode(rvh->GetRoutingID(), params)); | 35 rvh->Send(new ExtensionMsg_ExecuteCode(rvh->GetRoutingID(), params)); |
36 } | 36 } |
37 | 37 |
38 virtual ~Handler() {} | 38 virtual ~Handler() {} |
39 | 39 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 params.code = code; | 98 params.code = code; |
99 params.all_frames = (frame_scope == ALL_FRAMES); | 99 params.all_frames = (frame_scope == ALL_FRAMES); |
100 params.run_at = (int) run_at; | 100 params.run_at = (int) run_at; |
101 params.in_main_world = (world_type == MAIN_WORLD); | 101 params.in_main_world = (world_type == MAIN_WORLD); |
102 | 102 |
103 // Handler handles IPCs and deletes itself on completion. | 103 // Handler handles IPCs and deletes itself on completion. |
104 new Handler(web_contents_, params, callback); | 104 new Handler(web_contents_, params, callback); |
105 } | 105 } |
106 | 106 |
107 } // namespace extensions | 107 } // namespace extensions |
OLD | NEW |