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" |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 // initialization parameters, a concrete subclass of GuestViewBase can | 163 // initialization parameters, a concrete subclass of GuestViewBase can |
164 // create a specialized WebContents that it returns back to GuestViewBase. | 164 // create a specialized WebContents that it returns back to GuestViewBase. |
165 typedef base::Callback<void(content::WebContents*)> | 165 typedef base::Callback<void(content::WebContents*)> |
166 WebContentsCreatedCallback; | 166 WebContentsCreatedCallback; |
167 virtual void CreateWebContents( | 167 virtual void CreateWebContents( |
168 const base::DictionaryValue& create_params, | 168 const base::DictionaryValue& create_params, |
169 const WebContentsCreatedCallback& callback) = 0; | 169 const WebContentsCreatedCallback& callback) = 0; |
170 | 170 |
171 // This creates a WebContents and initializes |this| GuestViewBase to use the | 171 // This creates a WebContents and initializes |this| GuestViewBase to use the |
172 // newly created WebContents. | 172 // newly created WebContents. |
173 void Init(const std::string& owner_extension_id, | 173 void Init(const base::DictionaryValue& create_params, |
174 const base::DictionaryValue& create_params, | |
175 const WebContentsCreatedCallback& callback); | 174 const WebContentsCreatedCallback& callback); |
176 | 175 |
177 void InitWithWebContents(const std::string& owner_extension_id, | 176 void InitWithWebContents(content::WebContents* guest_web_contents); |
178 content::WebContents* guest_web_contents); | |
179 | 177 |
180 bool IsViewType(const char* const view_type) const { | 178 bool IsViewType(const char* const view_type) const { |
181 return !strcmp(GetViewType(), view_type); | 179 return !strcmp(GetViewType(), view_type); |
182 } | 180 } |
183 | 181 |
184 // Toggles autosize mode for this GuestView. | 182 // Toggles autosize mode for this GuestView. |
185 void SetAutoSize(bool enabled, | 183 void SetAutoSize(bool enabled, |
186 const gfx::Size& min_size, | 184 const gfx::Size& min_size, |
187 const gfx::Size& max_size); | 185 const gfx::Size& max_size); |
188 | 186 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 | 267 |
270 ~GuestViewBase() override; | 268 ~GuestViewBase() override; |
271 | 269 |
272 private: | 270 private: |
273 class OwnerLifetimeObserver; | 271 class OwnerLifetimeObserver; |
274 | 272 |
275 class OpenerLifetimeObserver; | 273 class OpenerLifetimeObserver; |
276 | 274 |
277 void SendQueuedEvents(); | 275 void SendQueuedEvents(); |
278 | 276 |
279 void CompleteInit(const std::string& owner_extension_id, | 277 void CompleteInit(const WebContentsCreatedCallback& callback, |
280 const WebContentsCreatedCallback& callback, | |
281 content::WebContents* guest_web_contents); | 278 content::WebContents* guest_web_contents); |
282 | 279 |
283 void StartTrackingEmbedderZoomLevel(); | 280 void StartTrackingEmbedderZoomLevel(); |
284 void StopTrackingEmbedderZoomLevel(); | 281 void StopTrackingEmbedderZoomLevel(); |
285 | 282 |
286 static void RegisterGuestViewTypes(); | 283 static void RegisterGuestViewTypes(); |
287 | 284 |
288 // WebContentsObserver implementation. | 285 // WebContentsObserver implementation. |
289 void DidStopLoading(content::RenderViewHost* render_view_host) final; | 286 void DidStopLoading(content::RenderViewHost* render_view_host) final; |
290 void RenderViewReady() final; | 287 void RenderViewReady() final; |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 // This is used to ensure pending tasks will not fire after this object is | 368 // This is used to ensure pending tasks will not fire after this object is |
372 // destroyed. | 369 // destroyed. |
373 base::WeakPtrFactory<GuestViewBase> weak_ptr_factory_; | 370 base::WeakPtrFactory<GuestViewBase> weak_ptr_factory_; |
374 | 371 |
375 DISALLOW_COPY_AND_ASSIGN(GuestViewBase); | 372 DISALLOW_COPY_AND_ASSIGN(GuestViewBase); |
376 }; | 373 }; |
377 | 374 |
378 } // namespace extensions | 375 } // namespace extensions |
379 | 376 |
380 #endif // EXTENSIONS_BROWSER_GUEST_VIEW_GUEST_VIEW_BASE_H_ | 377 #endif // EXTENSIONS_BROWSER_GUEST_VIEW_GUEST_VIEW_BASE_H_ |
OLD | NEW |