OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_GUEST_VIEW_GUEST_VIEW_BASE_H_ | 5 #ifndef CHROME_BROWSER_GUEST_VIEW_GUEST_VIEW_BASE_H_ |
6 #define CHROME_BROWSER_GUEST_VIEW_GUEST_VIEW_BASE_H_ | 6 #define CHROME_BROWSER_GUEST_VIEW_GUEST_VIEW_BASE_H_ |
7 | 7 |
8 #include <queue> | 8 #include <queue> |
9 | 9 |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
11 #include "base/values.h" | 11 #include "base/values.h" |
12 #include "content/public/browser/browser_plugin_guest_delegate.h" | 12 #include "content/public/browser/browser_plugin_guest_delegate.h" |
13 #include "content/public/browser/web_contents.h" | 13 #include "content/public/browser/web_contents.h" |
| 14 #include "content/public/browser/web_contents_delegate.h" |
14 | 15 |
15 struct RendererContentSettingRules; | 16 struct RendererContentSettingRules; |
16 | 17 |
17 // A GuestViewBase is the base class browser-side API implementation for a | 18 // A GuestViewBase is the base class browser-side API implementation for a |
18 // <*view> tag. GuestViewBase maintains an association between a guest | 19 // <*view> tag. GuestViewBase maintains an association between a guest |
19 // WebContents and an embedder WebContents. It receives events issued from | 20 // WebContents and an embedder WebContents. It receives events issued from |
20 // the guest and relays them to the embedder. | 21 // the guest and relays them to the embedder. |
21 class GuestViewBase : public content::BrowserPluginGuestDelegate { | 22 class GuestViewBase : public content::BrowserPluginGuestDelegate, |
| 23 public content::WebContentsDelegate { |
22 public: | 24 public: |
23 class Event { | 25 class Event { |
24 public: | 26 public: |
25 Event(const std::string& name, scoped_ptr<base::DictionaryValue> args); | 27 Event(const std::string& name, scoped_ptr<base::DictionaryValue> args); |
26 ~Event(); | 28 ~Event(); |
27 | 29 |
28 const std::string& name() const { return name_; } | 30 const std::string& name() const { return name_; } |
29 | 31 |
30 scoped_ptr<base::DictionaryValue> GetArguments(); | 32 scoped_ptr<base::DictionaryValue> GetArguments(); |
31 | 33 |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 | 118 |
117 // Returns the embedder's process ID. | 119 // Returns the embedder's process ID. |
118 int embedder_render_process_id() const { return embedder_render_process_id_; } | 120 int embedder_render_process_id() const { return embedder_render_process_id_; } |
119 | 121 |
120 GuestViewBase* GetOpener() const { | 122 GuestViewBase* GetOpener() const { |
121 return opener_.get(); | 123 return opener_.get(); |
122 } | 124 } |
123 | 125 |
124 void SetOpener(GuestViewBase* opener); | 126 void SetOpener(GuestViewBase* opener); |
125 | 127 |
| 128 // WebContentsDelegate implementation. |
| 129 virtual bool ShouldFocusPageAfterCrash() OVERRIDE; |
| 130 virtual bool PreHandleGestureEvent( |
| 131 content::WebContents* source, |
| 132 const blink::WebGestureEvent& event) OVERRIDE; |
| 133 |
126 // BrowserPluginGuestDelegate implementation. | 134 // BrowserPluginGuestDelegate implementation. |
127 virtual void Destroy() OVERRIDE; | 135 virtual void Destroy() OVERRIDE; |
128 virtual void RegisterDestructionCallback( | 136 virtual void RegisterDestructionCallback( |
129 const DestructionCallback& callback) OVERRIDE; | 137 const DestructionCallback& callback) OVERRIDE; |
130 virtual bool PreHandleGestureEvent( | |
131 content::WebContents* source, | |
132 const blink::WebGestureEvent& event) OVERRIDE; | |
133 | |
134 protected: | 138 protected: |
135 GuestViewBase(int guest_instance_id, | 139 GuestViewBase(int guest_instance_id, |
136 content::WebContents* guest_web_contents, | 140 content::WebContents* guest_web_contents, |
137 const std::string& embedder_extension_id); | 141 const std::string& embedder_extension_id); |
138 virtual ~GuestViewBase(); | 142 virtual ~GuestViewBase(); |
139 | 143 |
140 // Dispatches an event |event_name| to the embedder with the |event| fields. | 144 // Dispatches an event |event_name| to the embedder with the |event| fields. |
141 void DispatchEvent(Event* event); | 145 void DispatchEvent(Event* event); |
142 | 146 |
143 private: | 147 private: |
(...skipping 27 matching lines...) Expand all Loading... |
171 scoped_ptr<base::DictionaryValue> extra_params_; | 175 scoped_ptr<base::DictionaryValue> extra_params_; |
172 | 176 |
173 // This is used to ensure pending tasks will not fire after this object is | 177 // This is used to ensure pending tasks will not fire after this object is |
174 // destroyed. | 178 // destroyed. |
175 base::WeakPtrFactory<GuestViewBase> weak_ptr_factory_; | 179 base::WeakPtrFactory<GuestViewBase> weak_ptr_factory_; |
176 | 180 |
177 DISALLOW_COPY_AND_ASSIGN(GuestViewBase); | 181 DISALLOW_COPY_AND_ASSIGN(GuestViewBase); |
178 }; | 182 }; |
179 | 183 |
180 #endif // CHROME_BROWSER_GUEST_VIEW_GUEST_VIEW_BASE_H_ | 184 #endif // CHROME_BROWSER_GUEST_VIEW_GUEST_VIEW_BASE_H_ |
OLD | NEW |