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

Side by Side Diff: chrome/browser/guestview/guestview.h

Issue 237533008: Refactor GuestView. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_GUESTVIEW_GUESTVIEW_H_ 5 #ifndef CHROME_BROWSER_GUESTVIEW_GUESTVIEW_H_
6 #define CHROME_BROWSER_GUESTVIEW_GUESTVIEW_H_ 6 #define CHROME_BROWSER_GUESTVIEW_GUESTVIEW_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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 return embedder_web_contents_; 75 return embedder_web_contents_;
76 } 76 }
77 77
78 // Returns the guest WebContents. 78 // Returns the guest WebContents.
79 content::WebContents* guest_web_contents() const { 79 content::WebContents* guest_web_contents() const {
80 return guest_web_contents_; 80 return guest_web_contents_;
81 } 81 }
82 82
83 virtual Type GetViewType() const; 83 virtual Type GetViewType() const;
84 84
85 // Returns a WebViewGuest if this GuestView belongs to a <webview>. 85 // Returns a *ViewGuest if this GuestView is of the given view type.
86 virtual WebViewGuest* AsWebView() = 0; 86 template <class T>
Xi Han 2014/04/15 21:35:37 We do not want a bunch of As*View functions, e.g.,
87 87 T* As() {
88 // Returns an AdViewGuest if the GuestView belongs to an <adview>. 88 if (GetViewType() == T::Type()) {
89 virtual AdViewGuest* AsAdView() = 0; 89 return static_cast<T*>(this);
90 }
91 return NULL;
92 }
90 93
91 // Returns whether this guest has an associated embedder. 94 // Returns whether this guest has an associated embedder.
92 bool attached() const { return !!embedder_web_contents_; } 95 bool attached() const { return !!embedder_web_contents_; }
93 96
94 // Returns the instance ID of the <*view> element. 97 // Returns the instance ID of the <*view> element.
95 int view_instance_id() const { return view_instance_id_; } 98 int view_instance_id() const { return view_instance_id_; }
96 99
97 // Returns the instance ID of the guest WebContents. 100 // Returns the instance ID of the guest WebContents.
98 int guest_instance_id() const { return guest_instance_id_; } 101 int guest_instance_id() const { return guest_instance_id_; }
99 102
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 std::queue<Event*> pending_events_; 144 std::queue<Event*> pending_events_;
142 145
143 // This is used to ensure pending tasks will not fire after this object is 146 // This is used to ensure pending tasks will not fire after this object is
144 // destroyed. 147 // destroyed.
145 base::WeakPtrFactory<GuestView> weak_ptr_factory_; 148 base::WeakPtrFactory<GuestView> weak_ptr_factory_;
146 149
147 DISALLOW_COPY_AND_ASSIGN(GuestView); 150 DISALLOW_COPY_AND_ASSIGN(GuestView);
148 }; 151 };
149 152
150 #endif // CHROME_BROWSER_GUESTVIEW_GUESTVIEW_H_ 153 #endif // CHROME_BROWSER_GUESTVIEW_GUESTVIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698