| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #include "mash/browser/browser.h" | 5 #include "mash/browser/browser.h" |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 846 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 857 if (windows_.empty()) | 857 if (windows_.empty()) |
| 858 base::MessageLoop::current()->QuitWhenIdle(); | 858 base::MessageLoop::current()->QuitWhenIdle(); |
| 859 } | 859 } |
| 860 | 860 |
| 861 std::unique_ptr<navigation::View> Browser::CreateView() { | 861 std::unique_ptr<navigation::View> Browser::CreateView() { |
| 862 navigation::mojom::ViewFactoryPtr factory; | 862 navigation::mojom::ViewFactoryPtr factory; |
| 863 connector()->ConnectToInterface("exe:navigation", &factory); | 863 connector()->ConnectToInterface("exe:navigation", &factory); |
| 864 return base::MakeUnique<navigation::View>(std::move(factory)); | 864 return base::MakeUnique<navigation::View>(std::move(factory)); |
| 865 } | 865 } |
| 866 | 866 |
| 867 void Browser::OnStart(const shell::Identity& identity) { | 867 void Browser::OnStart(const service_manager::Identity& identity) { |
| 868 tracing_.Initialize(connector(), identity.name()); | 868 tracing_.Initialize(connector(), identity.name()); |
| 869 | 869 |
| 870 aura_init_.reset( | 870 aura_init_.reset( |
| 871 new views::AuraInit(connector(), "views_mus_resources.pak")); | 871 new views::AuraInit(connector(), "views_mus_resources.pak")); |
| 872 window_manager_connection_ = | 872 window_manager_connection_ = |
| 873 views::WindowManagerConnection::Create(connector(), identity); | 873 views::WindowManagerConnection::Create(connector(), identity); |
| 874 } | 874 } |
| 875 | 875 |
| 876 bool Browser::OnConnect(const shell::Identity& remote_identity, | 876 bool Browser::OnConnect(const service_manager::Identity& remote_identity, |
| 877 shell::InterfaceRegistry* registry) { | 877 service_manager::InterfaceRegistry* registry) { |
| 878 registry->AddInterface<mojom::Launchable>(this); | 878 registry->AddInterface<mojom::Launchable>(this); |
| 879 return true; | 879 return true; |
| 880 } | 880 } |
| 881 | 881 |
| 882 void Browser::Launch(uint32_t what, mojom::LaunchMode how) { | 882 void Browser::Launch(uint32_t what, mojom::LaunchMode how) { |
| 883 bool reuse = | 883 bool reuse = |
| 884 how == mojom::LaunchMode::REUSE || how == mojom::LaunchMode::DEFAULT; | 884 how == mojom::LaunchMode::REUSE || how == mojom::LaunchMode::DEFAULT; |
| 885 if (reuse && !windows_.empty()) { | 885 if (reuse && !windows_.empty()) { |
| 886 windows_.back()->Activate(); | 886 windows_.back()->Activate(); |
| 887 return; | 887 return; |
| 888 } | 888 } |
| 889 | 889 |
| 890 UI* ui = new UI(this, UI::Type::WINDOW, CreateView()); | 890 UI* ui = new UI(this, UI::Type::WINDOW, CreateView()); |
| 891 views::Widget* window = views::Widget::CreateWindowWithContextAndBounds( | 891 views::Widget* window = views::Widget::CreateWindowWithContextAndBounds( |
| 892 ui, nullptr, gfx::Rect(10, 10, 1024, 600)); | 892 ui, nullptr, gfx::Rect(10, 10, 1024, 600)); |
| 893 ui->NavigateTo(GURL("http://www.google.com/")); | 893 ui->NavigateTo(GURL("http://www.google.com/")); |
| 894 window->Show(); | 894 window->Show(); |
| 895 AddWindow(window); | 895 AddWindow(window); |
| 896 } | 896 } |
| 897 | 897 |
| 898 void Browser::Create(const shell::Identity& remote_identity, | 898 void Browser::Create(const service_manager::Identity& remote_identity, |
| 899 mojom::LaunchableRequest request) { | 899 mojom::LaunchableRequest request) { |
| 900 bindings_.AddBinding(this, std::move(request)); | 900 bindings_.AddBinding(this, std::move(request)); |
| 901 } | 901 } |
| 902 | 902 |
| 903 } // namespace browser | 903 } // namespace browser |
| 904 } // namespace mash | 904 } // namespace mash |
| OLD | NEW |