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

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

Issue 1096623002: Moved guest_view_registry to GuestViewManager and made it an instance map (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@switch_to_frombrowsercontextifavailable
Patch Set: Addressed comments Created 5 years, 8 months 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"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 public: 53 public:
54 // Returns a *ViewGuest if this GuestView is of the given view type. 54 // Returns a *ViewGuest if this GuestView is of the given view type.
55 template <typename T> 55 template <typename T>
56 T* As() { 56 T* As() {
57 if (IsViewType(T::Type)) 57 if (IsViewType(T::Type))
58 return static_cast<T*>(this); 58 return static_cast<T*>(this);
59 59
60 return nullptr; 60 return nullptr;
61 } 61 }
62 62
63 using GuestCreationCallback =
64 base::Callback<GuestViewBase*(content::WebContents*)>;
65 static void RegisterGuestViewType(const std::string& view_type,
66 const GuestCreationCallback& callback);
67
68 static GuestViewBase* Create(content::WebContents* owner_web_contents,
69 const std::string& view_type);
70
71 static GuestViewBase* FromWebContents( 63 static GuestViewBase* FromWebContents(
72 const content::WebContents* web_contents); 64 const content::WebContents* web_contents);
73 65
74 static GuestViewBase* From(int owner_process_id, int instance_id); 66 static GuestViewBase* From(int owner_process_id, int instance_id);
75 67
76 static bool IsGuest(content::WebContents* web_contents); 68 static bool IsGuest(content::WebContents* web_contents);
77 69
78 virtual const char* GetViewType() const = 0; 70 virtual const char* GetViewType() const = 0;
79 71
80 // This method is called after the guest has been attached to an embedder and 72 // This method is called after the guest has been attached to an embedder and
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 gfx::Size GetDefaultSize() const; 364 gfx::Size GetDefaultSize() const;
373 365
374 // Get the zoom factor for the embedder's web contents. 366 // Get the zoom factor for the embedder's web contents.
375 double GetEmbedderZoomFactor() const; 367 double GetEmbedderZoomFactor() const;
376 368
377 void SetUpSizing(const base::DictionaryValue& params); 369 void SetUpSizing(const base::DictionaryValue& params);
378 370
379 void StartTrackingEmbedderZoomLevel(); 371 void StartTrackingEmbedderZoomLevel();
380 void StopTrackingEmbedderZoomLevel(); 372 void StopTrackingEmbedderZoomLevel();
381 373
382 static void RegisterGuestViewTypes();
383
384 // This guest tracks the lifetime of the WebContents specified by 374 // This guest tracks the lifetime of the WebContents specified by
385 // |owner_web_contents_|. If |owner_web_contents_| is destroyed then this 375 // |owner_web_contents_|. If |owner_web_contents_| is destroyed then this
386 // guest will also self-destruct. 376 // guest will also self-destruct.
387 content::WebContents* owner_web_contents_; 377 content::WebContents* owner_web_contents_;
388 std::string owner_extension_id_; 378 std::string owner_extension_id_;
389 content::BrowserContext* const browser_context_; 379 content::BrowserContext* const browser_context_;
390 380
391 // |guest_instance_id_| is a profile-wide unique identifier for a guest 381 // |guest_instance_id_| is a profile-wide unique identifier for a guest
392 // WebContents. 382 // WebContents.
393 const int guest_instance_id_; 383 const int guest_instance_id_;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 // This is used to ensure pending tasks will not fire after this object is 446 // This is used to ensure pending tasks will not fire after this object is
457 // destroyed. 447 // destroyed.
458 base::WeakPtrFactory<GuestViewBase> weak_ptr_factory_; 448 base::WeakPtrFactory<GuestViewBase> weak_ptr_factory_;
459 449
460 DISALLOW_COPY_AND_ASSIGN(GuestViewBase); 450 DISALLOW_COPY_AND_ASSIGN(GuestViewBase);
461 }; 451 };
462 452
463 } // namespace extensions 453 } // namespace extensions
464 454
465 #endif // EXTENSIONS_BROWSER_GUEST_VIEW_GUEST_VIEW_BASE_H_ 455 #endif // EXTENSIONS_BROWSER_GUEST_VIEW_GUEST_VIEW_BASE_H_
OLDNEW
« no previous file with comments | « extensions/browser/guest_view/guest_view.h ('k') | extensions/browser/guest_view/guest_view_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698