Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(499)

Side by Side Diff: extensions/browser/guest_view/guest_view_base.h

Issue 787813004: Move ZoomController out of ChromeWebViewGuestDelegate. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix build deps, address fsamuel@'s comments. Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
262 private: 268 private:
263 class OwnerLifetimeObserver; 269 class OwnerLifetimeObserver;
264 270
265 class OpenerLifetimeObserver; 271 class OpenerLifetimeObserver;
266 272
267 void SendQueuedEvents(); 273 void SendQueuedEvents();
268 274
269 void CompleteInit(const std::string& owner_extension_id, 275 void CompleteInit(const std::string& owner_extension_id,
270 const WebContentsCreatedCallback& callback, 276 const WebContentsCreatedCallback& callback,
271 content::WebContents* guest_web_contents); 277 content::WebContents* guest_web_contents);
272 278
279 void OwnerWebContentsWillBeDestroyed();
280
273 static void RegisterGuestViewTypes(); 281 static void RegisterGuestViewTypes();
274 282
275 // WebContentsObserver implementation. 283 // WebContentsObserver implementation.
276 void DidStopLoading(content::RenderViewHost* render_view_host) final; 284 void DidStopLoading(content::RenderViewHost* render_view_host) final;
277 void RenderViewReady() final; 285 void RenderViewReady() final;
278 void WebContentsDestroyed() final; 286 void WebContentsDestroyed() final;
279 287
280 // WebContentsDelegate implementation. 288 // WebContentsDelegate implementation.
281 void ActivateContents(content::WebContents* contents) final; 289 void ActivateContents(content::WebContents* contents) final;
282 void DeactivateContents(content::WebContents* contents) final; 290 void DeactivateContents(content::WebContents* contents) final;
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 // This is used to ensure pending tasks will not fire after this object is 367 // This is used to ensure pending tasks will not fire after this object is
360 // destroyed. 368 // destroyed.
361 base::WeakPtrFactory<GuestViewBase> weak_ptr_factory_; 369 base::WeakPtrFactory<GuestViewBase> weak_ptr_factory_;
362 370
363 DISALLOW_COPY_AND_ASSIGN(GuestViewBase); 371 DISALLOW_COPY_AND_ASSIGN(GuestViewBase);
364 }; 372 };
365 373
366 } // namespace extensions 374 } // namespace extensions
367 375
368 #endif // EXTENSIONS_BROWSER_GUEST_VIEW_GUEST_VIEW_BASE_H_ 376 #endif // EXTENSIONS_BROWSER_GUEST_VIEW_GUEST_VIEW_BASE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698