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 CHROME_BROWSER_GUEST_VIEW_GUEST_VIEW_BASE_H_ | 5 #ifndef CHROME_BROWSER_GUEST_VIEW_GUEST_VIEW_BASE_H_ |
6 #define CHROME_BROWSER_GUEST_VIEW_GUEST_VIEW_BASE_H_ | 6 #define CHROME_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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 | 45 |
46 // Returns a *ViewGuest if this GuestView is of the given view type. | 46 // Returns a *ViewGuest if this GuestView is of the given view type. |
47 template <typename T> | 47 template <typename T> |
48 T* As() { | 48 T* As() { |
49 if (IsViewType(T::Type)) | 49 if (IsViewType(T::Type)) |
50 return static_cast<T*>(this); | 50 return static_cast<T*>(this); |
51 | 51 |
52 return NULL; | 52 return NULL; |
53 } | 53 } |
54 | 54 |
55 static void RegisterGuestViewTypes(); | |
56 | |
57 typedef base::Callback<GuestViewBase*( | 55 typedef base::Callback<GuestViewBase*( |
58 content::BrowserContext*, int)> GuestCreationCallback; | 56 content::BrowserContext*, int)> GuestCreationCallback; |
59 static void RegisterGuestViewType(const std::string& view_type, | 57 static void RegisterGuestViewType(const std::string& view_type, |
60 const GuestCreationCallback& callback); | 58 const GuestCreationCallback& callback); |
61 | 59 |
62 static GuestViewBase* Create(content::BrowserContext* browser_context, | 60 static GuestViewBase* Create(content::BrowserContext* browser_context, |
63 int guest_instance_id, | 61 int guest_instance_id, |
64 const std::string& view_type); | 62 const std::string& view_type); |
65 | 63 |
66 static GuestViewBase* FromWebContents(content::WebContents* web_contents); | 64 static GuestViewBase* FromWebContents(content::WebContents* web_contents); |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 private: | 227 private: |
230 class EmbedderWebContentsObserver; | 228 class EmbedderWebContentsObserver; |
231 | 229 |
232 void SendQueuedEvents(); | 230 void SendQueuedEvents(); |
233 | 231 |
234 void CompleteInit(const std::string& embedder_extension_id, | 232 void CompleteInit(const std::string& embedder_extension_id, |
235 int embedder_render_process_id, | 233 int embedder_render_process_id, |
236 const WebContentsCreatedCallback& callback, | 234 const WebContentsCreatedCallback& callback, |
237 content::WebContents* guest_web_contents); | 235 content::WebContents* guest_web_contents); |
238 | 236 |
| 237 static void RegisterGuestViewTypes(); |
| 238 |
239 // WebContentsObserver implementation. | 239 // WebContentsObserver implementation. |
240 virtual void DidStopLoading( | 240 virtual void DidStopLoading( |
241 content::RenderViewHost* render_view_host) OVERRIDE FINAL; | 241 content::RenderViewHost* render_view_host) OVERRIDE FINAL; |
242 virtual void WebContentsDestroyed() OVERRIDE FINAL; | 242 virtual void WebContentsDestroyed() OVERRIDE FINAL; |
243 | 243 |
244 // WebContentsDelegate implementation. | 244 // WebContentsDelegate implementation. |
245 virtual bool ShouldFocusPageAfterCrash() OVERRIDE FINAL; | 245 virtual bool ShouldFocusPageAfterCrash() OVERRIDE FINAL; |
246 virtual bool PreHandleGestureEvent( | 246 virtual bool PreHandleGestureEvent( |
247 content::WebContents* source, | 247 content::WebContents* source, |
248 const blink::WebGestureEvent& event) OVERRIDE FINAL; | 248 const blink::WebGestureEvent& event) OVERRIDE FINAL; |
(...skipping 29 matching lines...) Expand all Loading... |
278 scoped_ptr<EmbedderWebContentsObserver> embedder_web_contents_observer_; | 278 scoped_ptr<EmbedderWebContentsObserver> embedder_web_contents_observer_; |
279 | 279 |
280 // This is used to ensure pending tasks will not fire after this object is | 280 // This is used to ensure pending tasks will not fire after this object is |
281 // destroyed. | 281 // destroyed. |
282 base::WeakPtrFactory<GuestViewBase> weak_ptr_factory_; | 282 base::WeakPtrFactory<GuestViewBase> weak_ptr_factory_; |
283 | 283 |
284 DISALLOW_COPY_AND_ASSIGN(GuestViewBase); | 284 DISALLOW_COPY_AND_ASSIGN(GuestViewBase); |
285 }; | 285 }; |
286 | 286 |
287 #endif // CHROME_BROWSER_GUEST_VIEW_GUEST_VIEW_BASE_H_ | 287 #endif // CHROME_BROWSER_GUEST_VIEW_GUEST_VIEW_BASE_H_ |
OLD | NEW |