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 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 void ElementSizeChanged(const gfx::Size& old_size, | 241 void ElementSizeChanged(const gfx::Size& old_size, |
240 const gfx::Size& new_size) final; | 242 const gfx::Size& new_size) final; |
241 content::WebContents* GetOwnerWebContents() const final; | 243 content::WebContents* GetOwnerWebContents() const final; |
242 void GuestSizeChanged(const gfx::Size& old_size, | 244 void GuestSizeChanged(const gfx::Size& old_size, |
243 const gfx::Size& new_size) final; | 245 const gfx::Size& new_size) final; |
244 void RegisterDestructionCallback(const DestructionCallback& callback) final; | 246 void RegisterDestructionCallback(const DestructionCallback& callback) final; |
245 void WillAttach(content::WebContents* embedder_web_contents, | 247 void WillAttach(content::WebContents* embedder_web_contents, |
246 int browser_plugin_instance_id, | 248 int browser_plugin_instance_id, |
247 bool is_full_page_plugin) final; | 249 bool is_full_page_plugin) final; |
248 | 250 |
| 251 // ui_zoom::ZoomObserver implementation. |
| 252 void OnZoomChanged( |
| 253 const ui_zoom::ZoomController::ZoomChangedEventData& data) override; |
| 254 |
249 // Dispatches an event |event_name| to the embedder with the |event| fields. | 255 // Dispatches an event |event_name| to the embedder with the |event| fields. |
250 void DispatchEventToEmbedder(Event* event); | 256 void DispatchEventToEmbedder(Event* event); |
251 | 257 |
252 protected: | 258 protected: |
253 GuestViewBase(content::BrowserContext* browser_context, | 259 GuestViewBase(content::BrowserContext* browser_context, |
254 content::WebContents* owner_web_contents, | 260 content::WebContents* owner_web_contents, |
255 int guest_instance_id); | 261 int guest_instance_id); |
256 | 262 |
257 ~GuestViewBase() override; | 263 ~GuestViewBase() override; |
258 | 264 |
259 private: | 265 private: |
260 class OwnerLifetimeObserver; | 266 class OwnerLifetimeObserver; |
261 | 267 |
262 class OpenerLifetimeObserver; | 268 class OpenerLifetimeObserver; |
263 | 269 |
264 void SendQueuedEvents(); | 270 void SendQueuedEvents(); |
265 | 271 |
266 void CompleteInit(const std::string& owner_extension_id, | 272 void CompleteInit(const std::string& owner_extension_id, |
267 const WebContentsCreatedCallback& callback, | 273 const WebContentsCreatedCallback& callback, |
268 content::WebContents* guest_web_contents); | 274 content::WebContents* guest_web_contents); |
269 | 275 |
| 276 void StartObservingOwnersZoomController(); |
| 277 void StopObservingOwnersZoomControllerIfNecessary(); |
| 278 |
270 static void RegisterGuestViewTypes(); | 279 static void RegisterGuestViewTypes(); |
271 | 280 |
272 // WebContentsObserver implementation. | 281 // WebContentsObserver implementation. |
273 void DidStopLoading(content::RenderViewHost* render_view_host) final; | 282 void DidStopLoading(content::RenderViewHost* render_view_host) final; |
274 void RenderViewReady() final; | 283 void RenderViewReady() final; |
275 void WebContentsDestroyed() final; | 284 void WebContentsDestroyed() final; |
276 | 285 |
277 // WebContentsDelegate implementation. | 286 // WebContentsDelegate implementation. |
278 void ActivateContents(content::WebContents* contents) final; | 287 void ActivateContents(content::WebContents* contents) final; |
279 void DeactivateContents(content::WebContents* contents) final; | 288 void DeactivateContents(content::WebContents* contents) final; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 | 354 |
346 // The maximum size constraints of the container element in autosize mode. | 355 // The maximum size constraints of the container element in autosize mode. |
347 gfx::Size max_auto_size_; | 356 gfx::Size max_auto_size_; |
348 | 357 |
349 // The minimum size constraints of the container element in autosize mode. | 358 // The minimum size constraints of the container element in autosize mode. |
350 gfx::Size min_auto_size_; | 359 gfx::Size min_auto_size_; |
351 | 360 |
352 // Whether the guest view is inside a plugin document. | 361 // Whether the guest view is inside a plugin document. |
353 bool is_full_page_plugin_; | 362 bool is_full_page_plugin_; |
354 | 363 |
| 364 bool observing_owners_zoom_controller_; |
| 365 |
355 // This is used to ensure pending tasks will not fire after this object is | 366 // This is used to ensure pending tasks will not fire after this object is |
356 // destroyed. | 367 // destroyed. |
357 base::WeakPtrFactory<GuestViewBase> weak_ptr_factory_; | 368 base::WeakPtrFactory<GuestViewBase> weak_ptr_factory_; |
358 | 369 |
359 DISALLOW_COPY_AND_ASSIGN(GuestViewBase); | 370 DISALLOW_COPY_AND_ASSIGN(GuestViewBase); |
360 }; | 371 }; |
361 | 372 |
362 } // namespace extensions | 373 } // namespace extensions |
363 | 374 |
364 #endif // EXTENSIONS_BROWSER_GUEST_VIEW_GUEST_VIEW_BASE_H_ | 375 #endif // EXTENSIONS_BROWSER_GUEST_VIEW_GUEST_VIEW_BASE_H_ |
OLD | NEW |