| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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 MANDOLINE_UI_BROWSER_BROWSER_MANAGER_H_ | 5 #ifndef MANDOLINE_UI_BROWSER_BROWSER_MANAGER_H_ |
| 6 #define MANDOLINE_UI_BROWSER_BROWSER_MANAGER_H_ | 6 #define MANDOLINE_UI_BROWSER_BROWSER_MANAGER_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/memory/scoped_vector.h" | 10 #include "base/memory/scoped_vector.h" |
| 11 #include "mandoline/ui/browser/browser_delegate.h" |
| 11 #include "mandoline/ui/browser/public/interfaces/launch_handler.mojom.h" | 12 #include "mandoline/ui/browser/public/interfaces/launch_handler.mojom.h" |
| 12 #include "mojo/application/public/cpp/application_delegate.h" | 13 #include "mojo/application/public/cpp/application_delegate.h" |
| 13 #include "mojo/application/public/cpp/application_impl.h" | 14 #include "mojo/application/public/cpp/application_impl.h" |
| 14 #include "mojo/application/public/cpp/connect.h" | 15 #include "mojo/application/public/cpp/connect.h" |
| 15 #include "mojo/common/weak_binding_set.h" | 16 #include "mojo/common/weak_binding_set.h" |
| 16 | 17 |
| 17 #if defined(USE_AURA) | 18 #if defined(USE_AURA) |
| 18 #include "mandoline/ui/aura/aura_init.h" | 19 #include "mandoline/ui/aura/aura_init.h" |
| 19 #endif | 20 #endif |
| 20 | 21 |
| 21 namespace mojo { | 22 namespace mojo { |
| 22 class View; | 23 class View; |
| 23 } | 24 } |
| 24 | 25 |
| 25 namespace mandoline { | 26 namespace mandoline { |
| 26 | 27 |
| 27 class Browser; | 28 class Browser; |
| 28 | 29 |
| 29 // BrowserManager creates and manages the lifetime of Browsers. | 30 // BrowserManager creates and manages the lifetime of Browsers. |
| 30 class BrowserManager : public mojo::ApplicationDelegate, | 31 class BrowserManager : public mojo::ApplicationDelegate, |
| 32 public BrowserDelegate, |
| 31 public LaunchHandler, | 33 public LaunchHandler, |
| 32 public mojo::InterfaceFactory<LaunchHandler> { | 34 public mojo::InterfaceFactory<LaunchHandler> { |
| 33 public: | 35 public: |
| 34 BrowserManager(); | 36 BrowserManager(); |
| 35 ~BrowserManager() override; | 37 ~BrowserManager() override; |
| 36 | 38 |
| 37 // BrowserManager owns the returned Browser. | 39 // BrowserManager owns the returned Browser. |
| 38 Browser* CreateBrowser(); | 40 Browser* CreateBrowser(); |
| 39 | 41 |
| 40 // Invoked by |browser| when it has closed. | |
| 41 void BrowserClosed(Browser* browser); | |
| 42 | |
| 43 bool InitUIIfNecessary(Browser* browser, mojo::View* view); | |
| 44 | |
| 45 private: | 42 private: |
| 46 class DevicePixelRatioWaiter; | 43 class DevicePixelRatioWaiter; |
| 47 | 44 |
| 48 void OnDevicePixelRatioAvailable(Browser* browser, mojo::View* view); | 45 void OnDevicePixelRatioAvailable(Browser* browser, mojo::View* view); |
| 49 | 46 |
| 50 // Overridden from LaunchHandler: | 47 // Overridden from LaunchHandler: |
| 51 void LaunchURL(const mojo::String& url) override; | 48 void LaunchURL(const mojo::String& url) override; |
| 52 | 49 |
| 53 // Overridden from mojo::ApplicationDelegate: | 50 // Overridden from mojo::ApplicationDelegate: |
| 54 void Initialize(mojo::ApplicationImpl* app) override; | 51 void Initialize(mojo::ApplicationImpl* app) override; |
| 55 bool ConfigureIncomingConnection( | 52 bool ConfigureIncomingConnection( |
| 56 mojo::ApplicationConnection* connection) override; | 53 mojo::ApplicationConnection* connection) override; |
| 57 | 54 |
| 55 // Overridden from BrowserDelegate: |
| 56 bool InitUIIfNecessary(Browser* browser, mojo::View* view) override; |
| 57 void BrowserClosed(Browser* browser) override; |
| 58 |
| 58 // Overridden from mojo::InterfaceFactory<LaunchHandler>: | 59 // Overridden from mojo::InterfaceFactory<LaunchHandler>: |
| 59 void Create(mojo::ApplicationConnection* connection, | 60 void Create(mojo::ApplicationConnection* connection, |
| 60 mojo::InterfaceRequest<LaunchHandler> request) override; | 61 mojo::InterfaceRequest<LaunchHandler> request) override; |
| 61 | 62 |
| 62 mojo::ApplicationImpl* app_; | 63 mojo::ApplicationImpl* app_; |
| 63 // TODO(sky): This should be held in the ui classes, not here. | 64 // TODO(sky): This should be held in the ui classes, not here. |
| 64 #if defined(USE_AURA) | 65 #if defined(USE_AURA) |
| 65 scoped_ptr<AuraInit> aura_init_; | 66 scoped_ptr<AuraInit> aura_init_; |
| 66 #endif | 67 #endif |
| 67 mojo::WeakBindingSet<LaunchHandler> launch_handler_bindings_; | 68 mojo::WeakBindingSet<LaunchHandler> launch_handler_bindings_; |
| 68 std::set<Browser*> browsers_; | 69 std::set<Browser*> browsers_; |
| 69 | 70 |
| 70 scoped_ptr<DevicePixelRatioWaiter> device_pixel_ratio_waiter_; | 71 scoped_ptr<DevicePixelRatioWaiter> device_pixel_ratio_waiter_; |
| 71 | 72 |
| 72 DISALLOW_COPY_AND_ASSIGN(BrowserManager); | 73 DISALLOW_COPY_AND_ASSIGN(BrowserManager); |
| 73 }; | 74 }; |
| 74 | 75 |
| 75 } // namespace mandoline | 76 } // namespace mandoline |
| 76 | 77 |
| 77 #endif // MANDOLINE_UI_BROWSER_BROWSER_MANAGER_H_ | 78 #endif // MANDOLINE_UI_BROWSER_BROWSER_MANAGER_H_ |
| OLD | NEW |