| OLD | NEW |
| (Empty) |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 #ifndef BLIMP_ENGINE_BROWSER_BLIMP_WINDOW_H_ | |
| 5 #define BLIMP_ENGINE_BROWSER_BLIMP_WINDOW_H_ | |
| 6 | |
| 7 #include <vector> | |
| 8 | |
| 9 #include "base/lazy_instance.h" | |
| 10 #include "base/macros.h" | |
| 11 #include "base/memory/scoped_ptr.h" | |
| 12 #include "content/public/browser/web_contents_delegate.h" | |
| 13 #include "content/public/browser/web_contents_observer.h" | |
| 14 #include "ui/gfx/geometry/size.h" | |
| 15 | |
| 16 namespace content { | |
| 17 class BrowserContext; | |
| 18 class SiteInstance; | |
| 19 class WebContents; | |
| 20 } | |
| 21 | |
| 22 class GURL; | |
| 23 | |
| 24 namespace blimp { | |
| 25 namespace engine { | |
| 26 | |
| 27 // Owns and controls a WebContents instance corresponding to a window on | |
| 28 // Blimp client. | |
| 29 class BlimpWindow : public content::WebContentsDelegate { | |
| 30 public: | |
| 31 // This also unregisters itself with a singleton registry. | |
| 32 ~BlimpWindow() override; | |
| 33 | |
| 34 // Creates a new blimp window with |initial_size| and navigates to the |url|. | |
| 35 // Caller retains ownership of |browser_context| and |site_instance| and | |
| 36 // ensures |browser_context| and |site_instance| outlives BlimpWindow. | |
| 37 static void Create(content::BrowserContext* browser_context, | |
| 38 const GURL& url, | |
| 39 content::SiteInstance* site_instance, | |
| 40 const gfx::Size& initial_size); | |
| 41 | |
| 42 // Navigates to |url|. | |
| 43 void LoadURL(const GURL& url); | |
| 44 | |
| 45 // content::WebContentsDelegate implementation. | |
| 46 content::WebContents* OpenURLFromTab( | |
| 47 content::WebContents* source, | |
| 48 const content::OpenURLParams& params) override; | |
| 49 void AddNewContents(content::WebContents* source, | |
| 50 content::WebContents* new_contents, | |
| 51 WindowOpenDisposition disposition, | |
| 52 const gfx::Rect& initial_rect, | |
| 53 bool user_gesture, | |
| 54 bool* was_blocked) override; | |
| 55 void RequestToLockMouse(content::WebContents* web_contents, | |
| 56 bool user_gesture, | |
| 57 bool last_unlocked_by_target) override; | |
| 58 void CloseContents(content::WebContents* source) override; | |
| 59 void ActivateContents(content::WebContents* contents) override; | |
| 60 void DeactivateContents(content::WebContents* contents) override; | |
| 61 | |
| 62 private: | |
| 63 // The newly created instance registers itself with a singleton registry. | |
| 64 explicit BlimpWindow(scoped_ptr<content::WebContents> web_contents); | |
| 65 | |
| 66 // Helper to create a new BlimpWindow given |web_contents|. | |
| 67 // The newly window is owned by a singleton registry. | |
| 68 static BlimpWindow* DoCreate(scoped_ptr<content::WebContents> web_contents, | |
| 69 const gfx::Size& initial_size); | |
| 70 | |
| 71 scoped_ptr<content::WebContents> web_contents_; | |
| 72 | |
| 73 DISALLOW_COPY_AND_ASSIGN(BlimpWindow); | |
| 74 }; | |
| 75 | |
| 76 } // namespace engine | |
| 77 } // namespace blimp | |
| 78 | |
| 79 #endif // BLIMP_ENGINE_BROWSER_BLIMP_WINDOW_H_ | |
| OLD | NEW |