OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 EXTENSIONS_BROWSER_GUEST_VIEW_EXTENSIONS_GUEST_VIEW_MESSAGE_FILTER_H_ | 5 #ifndef EXTENSIONS_BROWSER_GUEST_VIEW_EXTENSIONS_GUEST_VIEW_MESSAGE_FILTER_H_ |
6 #define EXTENSIONS_BROWSER_GUEST_VIEW_EXTENSIONS_GUEST_VIEW_MESSAGE_FILTER_H_ | 6 #define EXTENSIONS_BROWSER_GUEST_VIEW_EXTENSIONS_GUEST_VIEW_MESSAGE_FILTER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
12 #include "content/public/browser/browser_message_filter.h" | 12 #include "content/public/browser/browser_message_filter.h" |
13 | 13 |
14 namespace content { | 14 namespace content { |
15 class BrowserContext; | 15 class BrowserContext; |
16 class WebContents; | 16 class WebContents; |
17 } | 17 } |
18 | 18 |
19 namespace gfx { | 19 namespace gfx { |
20 class Size; | 20 class Size; |
21 } | 21 } |
22 | 22 |
23 namespace extensions { | 23 namespace extensions { |
24 | 24 |
| 25 class WebViewGuest; |
| 26 |
25 // This class filters out incoming extensions GuestView-specific IPC messages | 27 // This class filters out incoming extensions GuestView-specific IPC messages |
26 // from thw renderer process. It is created on the UI thread. Messages may be | 28 // from thw renderer process. It is created on the UI thread. Messages may be |
27 // handled on the IO thread or the UI thread. | 29 // handled on the IO thread or the UI thread. |
28 class ExtensionsGuestViewMessageFilter : public content::BrowserMessageFilter { | 30 class ExtensionsGuestViewMessageFilter : public content::BrowserMessageFilter { |
29 public: | 31 public: |
30 ExtensionsGuestViewMessageFilter(int render_process_id, | 32 ExtensionsGuestViewMessageFilter(int render_process_id, |
31 content::BrowserContext* context); | 33 content::BrowserContext* context); |
32 | 34 |
33 private: | 35 private: |
34 friend class content::BrowserThread; | 36 friend class content::BrowserThread; |
35 friend class base::DeleteHelper<ExtensionsGuestViewMessageFilter>; | 37 friend class base::DeleteHelper<ExtensionsGuestViewMessageFilter>; |
36 | 38 |
37 ~ExtensionsGuestViewMessageFilter() override; | 39 ~ExtensionsGuestViewMessageFilter() override; |
38 | 40 |
39 // content::BrowserMessageFilter implementation. | 41 // content::BrowserMessageFilter implementation. |
40 void OverrideThreadForMessage(const IPC::Message& message, | 42 void OverrideThreadForMessage(const IPC::Message& message, |
41 content::BrowserThread::ID* thread) override; | 43 content::BrowserThread::ID* thread) override; |
42 void OnDestruct() const override; | 44 void OnDestruct() const override; |
43 bool OnMessageReceived(const IPC::Message& message) override; | 45 bool OnMessageReceived(const IPC::Message& message) override; |
44 | 46 |
45 // Message handlers on the UI thread. | 47 // Message handlers on the UI thread. |
| 48 void OnAttachToEmbedderFrame(int embedder_local_render_frame_id, |
| 49 int element_instance_id, |
| 50 int guest_instance_id, |
| 51 const base::DictionaryValue& params); |
46 void OnCanExecuteContentScript(int render_view_id, | 52 void OnCanExecuteContentScript(int render_view_id, |
47 int script_id, | 53 int script_id, |
48 bool* allowed); | 54 bool* allowed); |
49 | 55 |
50 void OnCreateMimeHandlerViewGuest(int render_frame_id, | 56 void OnCreateMimeHandlerViewGuest(int render_frame_id, |
51 const std::string& view_id, | 57 const std::string& view_id, |
52 int element_instance_id, | 58 int element_instance_id, |
53 const gfx::Size& element_size); | 59 const gfx::Size& element_size); |
54 void OnResizeGuest(int render_frame_id, | 60 void OnResizeGuest(int render_frame_id, |
55 int element_instance_id, | 61 int element_instance_id, |
56 const gfx::Size& new_size); | 62 const gfx::Size& new_size); |
57 | 63 |
58 // Runs on UI thread. | 64 // Runs on UI thread. |
59 void MimeHandlerViewGuestCreatedCallback(int element_instance_id, | 65 void MimeHandlerViewGuestCreatedCallback(int element_instance_id, |
60 int embedder_render_process_id, | 66 int embedder_render_process_id, |
61 int embedder_render_frame_id, | 67 int embedder_render_frame_id, |
62 const gfx::Size& element_size, | 68 const gfx::Size& element_size, |
63 content::WebContents* web_contents); | 69 content::WebContents* web_contents); |
| 70 void WillAttachCallback(extensions::WebViewGuest* guest); |
64 | 71 |
65 const int render_process_id_; | 72 const int render_process_id_; |
66 | 73 |
67 // Should only be accessed on the UI thread. | 74 // Should only be accessed on the UI thread. |
68 content::BrowserContext* const browser_context_; | 75 content::BrowserContext* const browser_context_; |
69 | 76 |
70 // Weak pointers produced by this factory are bound to the IO thread. | 77 // Weak pointers produced by this factory are bound to the IO thread. |
71 base::WeakPtrFactory<ExtensionsGuestViewMessageFilter> weak_ptr_factory_; | 78 base::WeakPtrFactory<ExtensionsGuestViewMessageFilter> weak_ptr_factory_; |
72 | 79 |
73 DISALLOW_COPY_AND_ASSIGN(ExtensionsGuestViewMessageFilter); | 80 DISALLOW_COPY_AND_ASSIGN(ExtensionsGuestViewMessageFilter); |
74 }; | 81 }; |
75 | 82 |
76 } // namespace extensions | 83 } // namespace extensions |
77 | 84 |
78 #endif // EXTENSIONS_BROWSER_GUEST_VIEW_EXTENSIONS_GUEST_VIEW_MESSAGE_FILTER_H_ | 85 #endif // EXTENSIONS_BROWSER_GUEST_VIEW_EXTENSIONS_GUEST_VIEW_MESSAGE_FILTER_H_ |
OLD | NEW |