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 EXTENSIONS_BROWSER_GUEST_VIEW_GUEST_VIEW_BASE_H_ | 5 #ifndef EXTENSIONS_BROWSER_GUEST_VIEW_GUEST_VIEW_BASE_H_ |
6 #define EXTENSIONS_BROWSER_GUEST_VIEW_GUEST_VIEW_BASE_H_ | 6 #define EXTENSIONS_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 "components/ui/zoom/zoom_observer.h" | |
12 #include "content/public/browser/browser_plugin_guest_delegate.h" | 13 #include "content/public/browser/browser_plugin_guest_delegate.h" |
13 #include "content/public/browser/render_process_host_observer.h" | 14 #include "content/public/browser/render_process_host_observer.h" |
14 #include "content/public/browser/web_contents.h" | 15 #include "content/public/browser/web_contents.h" |
15 #include "content/public/browser/web_contents_delegate.h" | 16 #include "content/public/browser/web_contents_delegate.h" |
16 #include "content/public/browser/web_contents_observer.h" | 17 #include "content/public/browser/web_contents_observer.h" |
17 #include "extensions/common/guest_view/guest_view_constants.h" | 18 #include "extensions/common/guest_view/guest_view_constants.h" |
18 | 19 |
19 struct RendererContentSettingRules; | 20 struct RendererContentSettingRules; |
20 | 21 |
21 namespace extensions { | 22 namespace extensions { |
22 | 23 |
23 // A GuestViewBase is the base class browser-side API implementation for a | 24 // A GuestViewBase is the base class browser-side API implementation for a |
24 // <*view> tag. GuestViewBase maintains an association between a guest | 25 // <*view> tag. GuestViewBase maintains an association between a guest |
25 // WebContents and an owner WebContents. It receives events issued from | 26 // WebContents and an owner WebContents. It receives events issued from |
26 // the guest and relays them to the owner. GuestViewBase tracks the lifetime | 27 // the guest and relays them to the owner. GuestViewBase tracks the lifetime |
27 // of its owner. A GuestViewBase's owner is referred to as an embedder if | 28 // of its owner. A GuestViewBase's owner is referred to as an embedder if |
28 // it is attached to a container within the owner's WebContents. | 29 // it is attached to a container within the owner's WebContents. |
29 class GuestViewBase : public content::BrowserPluginGuestDelegate, | 30 class GuestViewBase : public content::BrowserPluginGuestDelegate, |
30 public content::WebContentsDelegate, | 31 public content::WebContentsDelegate, |
31 public content::WebContentsObserver { | 32 public content::WebContentsObserver, |
33 public ui_zoom::ZoomObserver { | |
32 public: | 34 public: |
33 class Event { | 35 class Event { |
34 public: | 36 public: |
35 Event(const std::string& name, scoped_ptr<base::DictionaryValue> args); | 37 Event(const std::string& name, scoped_ptr<base::DictionaryValue> args); |
36 ~Event(); | 38 ~Event(); |
37 | 39 |
38 const std::string& name() const { return name_; } | 40 const std::string& name() const { return name_; } |
39 | 41 |
40 scoped_ptr<base::DictionaryValue> GetArguments(); | 42 scoped_ptr<base::DictionaryValue> GetArguments(); |
41 | 43 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
87 virtual void DidInitialize() {} | 89 virtual void DidInitialize() {} |
88 | 90 |
89 // This method is called when the initial set of frames within the page have | 91 // This method is called when the initial set of frames within the page have |
90 // completed loading. | 92 // completed loading. |
91 virtual void DidStopLoading() {} | 93 virtual void DidStopLoading() {} |
92 | 94 |
93 // This method is called before the embedder is destroyed. | 95 // This method is called before the embedder is destroyed. |
94 // |owner_web_contents_| should still be valid during this call. This | 96 // |owner_web_contents_| should still be valid during this call. This |
95 // allows the derived class to perform some cleanup related to the embedder | 97 // allows the derived class to perform some cleanup related to the embedder |
96 // web contents. | 98 // web contents. |
97 virtual void EmbedderWillBeDestroyed() {} | 99 virtual void EmbedderWillBeDestroyed(); |
Fady Samuel
2014/12/09 20:09:46
This method is meant to be overriden by derived cl
wjmaclean
2014/12/09 20:50:04
Done.
| |
98 | 100 |
99 // This method is called when the guest WebContents has been destroyed. This | 101 // This method is called when the guest WebContents has been destroyed. This |
100 // object will be destroyed after this call returns. | 102 // object will be destroyed after this call returns. |
101 // | 103 // |
102 // This gives the derived class an opportunity to perform some cleanup. | 104 // This gives the derived class an opportunity to perform some cleanup. |
103 virtual void GuestDestroyed() {} | 105 virtual void GuestDestroyed() {} |
104 | 106 |
105 // This method is invoked when the guest RenderView is ready, e.g. because we | 107 // This method is invoked when the guest RenderView is ready, e.g. because we |
106 // recreated it after a crash or after reattachment. | 108 // recreated it after a crash or after reattachment. |
107 // | 109 // |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
242 void ElementSizeChanged(const gfx::Size& old_size, | 244 void ElementSizeChanged(const gfx::Size& old_size, |
243 const gfx::Size& new_size) final; | 245 const gfx::Size& new_size) final; |
244 content::WebContents* GetOwnerWebContents() const final; | 246 content::WebContents* GetOwnerWebContents() const final; |
245 void GuestSizeChanged(const gfx::Size& old_size, | 247 void GuestSizeChanged(const gfx::Size& old_size, |
246 const gfx::Size& new_size) final; | 248 const gfx::Size& new_size) final; |
247 void RegisterDestructionCallback(const DestructionCallback& callback) final; | 249 void RegisterDestructionCallback(const DestructionCallback& callback) final; |
248 void WillAttach(content::WebContents* embedder_web_contents, | 250 void WillAttach(content::WebContents* embedder_web_contents, |
249 int browser_plugin_instance_id, | 251 int browser_plugin_instance_id, |
250 bool is_full_page_plugin) final; | 252 bool is_full_page_plugin) final; |
251 | 253 |
254 // ui_zoom::ZoomObserver implementation. | |
255 void OnZoomChanged( | |
256 const ui_zoom::ZoomController::ZoomChangedEventData& data) override; | |
257 | |
252 // Dispatches an event |event_name| to the embedder with the |event| fields. | 258 // Dispatches an event |event_name| to the embedder with the |event| fields. |
253 void DispatchEventToEmbedder(Event* event); | 259 void DispatchEventToEmbedder(Event* event); |
254 | 260 |
255 protected: | 261 protected: |
256 GuestViewBase(content::BrowserContext* browser_context, | 262 GuestViewBase(content::BrowserContext* browser_context, |
257 content::WebContents* owner_web_contents, | 263 content::WebContents* owner_web_contents, |
258 int guest_instance_id); | 264 int guest_instance_id); |
259 | 265 |
260 ~GuestViewBase() override; | 266 ~GuestViewBase() override; |
261 | 267 |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
359 // This is used to ensure pending tasks will not fire after this object is | 365 // This is used to ensure pending tasks will not fire after this object is |
360 // destroyed. | 366 // destroyed. |
361 base::WeakPtrFactory<GuestViewBase> weak_ptr_factory_; | 367 base::WeakPtrFactory<GuestViewBase> weak_ptr_factory_; |
362 | 368 |
363 DISALLOW_COPY_AND_ASSIGN(GuestViewBase); | 369 DISALLOW_COPY_AND_ASSIGN(GuestViewBase); |
364 }; | 370 }; |
365 | 371 |
366 } // namespace extensions | 372 } // namespace extensions |
367 | 373 |
368 #endif // EXTENSIONS_BROWSER_GUEST_VIEW_GUEST_VIEW_BASE_H_ | 374 #endif // EXTENSIONS_BROWSER_GUEST_VIEW_GUEST_VIEW_BASE_H_ |
OLD | NEW |