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" |
11 #include "base/strings/string16.h" | 11 #include "base/strings/string16.h" |
12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
14 #include "base/threading/thread_task_runner_handle.h" | 14 #include "base/threading/thread_task_runner_handle.h" |
15 #include "base/timer/timer.h" | 15 #include "base/timer/timer.h" |
16 #include "mash/browser/debug_view.h" | 16 #include "mash/browser/debug_view.h" |
17 #include "mash/public/interfaces/launchable.mojom.h" | 17 #include "mash/public/interfaces/launchable.mojom.h" |
18 #include "mojo/public/c/system/main.h" | 18 #include "mojo/public/c/system/main.h" |
19 #include "services/navigation/public/cpp/view.h" | 19 #include "services/navigation/public/cpp/view.h" |
20 #include "services/navigation/public/cpp/view_delegate.h" | 20 #include "services/navigation/public/cpp/view_delegate.h" |
21 #include "services/navigation/public/cpp/view_observer.h" | 21 #include "services/navigation/public/cpp/view_observer.h" |
22 #include "services/navigation/public/interfaces/view.mojom.h" | 22 #include "services/navigation/public/interfaces/view.mojom.h" |
23 #include "services/shell/public/cpp/application_runner.h" | 23 #include "services/shell/public/cpp/application_runner.h" |
24 #include "services/shell/public/cpp/connector.h" | 24 #include "services/shell/public/cpp/connector.h" |
25 #include "services/shell/public/cpp/shell_client.h" | 25 #include "services/shell/public/cpp/service.h" |
26 #include "services/tracing/public/cpp/tracing_impl.h" | 26 #include "services/tracing/public/cpp/tracing_impl.h" |
27 #include "services/ui/public/cpp/window.h" | 27 #include "services/ui/public/cpp/window.h" |
28 #include "services/ui/public/cpp/window_tree_client.h" | 28 #include "services/ui/public/cpp/window_tree_client.h" |
29 #include "ui/aura/mus/mus_util.h" | 29 #include "ui/aura/mus/mus_util.h" |
30 #include "ui/base/models/menu_model.h" | 30 #include "ui/base/models/menu_model.h" |
31 #include "ui/gfx/canvas.h" | 31 #include "ui/gfx/canvas.h" |
32 #include "ui/gfx/paint_throbber.h" | 32 #include "ui/gfx/paint_throbber.h" |
33 #include "ui/gfx/text_constants.h" | 33 #include "ui/gfx/text_constants.h" |
34 #include "ui/native_theme/native_theme.h" | 34 #include "ui/native_theme/native_theme.h" |
35 #include "ui/views/background.h" | 35 #include "ui/views/background.h" |
(...skipping 822 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
858 if (windows_.empty()) | 858 if (windows_.empty()) |
859 base::MessageLoop::current()->QuitWhenIdle(); | 859 base::MessageLoop::current()->QuitWhenIdle(); |
860 } | 860 } |
861 | 861 |
862 std::unique_ptr<navigation::View> Browser::CreateView() { | 862 std::unique_ptr<navigation::View> Browser::CreateView() { |
863 navigation::mojom::ViewFactoryPtr factory; | 863 navigation::mojom::ViewFactoryPtr factory; |
864 connector_->ConnectToInterface("exe:navigation", &factory); | 864 connector_->ConnectToInterface("exe:navigation", &factory); |
865 return base::WrapUnique(new navigation::View(std::move(factory))); | 865 return base::WrapUnique(new navigation::View(std::move(factory))); |
866 } | 866 } |
867 | 867 |
868 void Browser::Initialize(shell::Connector* connector, | 868 void Browser::OnStart(shell::Connector* connector, |
869 const shell::Identity& identity, | 869 const shell::Identity& identity, |
870 uint32_t id) { | 870 uint32_t id) { |
871 connector_ = connector; | 871 connector_ = connector; |
872 tracing_.Initialize(connector, identity.name()); | 872 tracing_.Initialize(connector, identity.name()); |
873 | 873 |
874 aura_init_.reset(new views::AuraInit(connector, "views_mus_resources.pak")); | 874 aura_init_.reset(new views::AuraInit(connector, "views_mus_resources.pak")); |
875 window_manager_connection_ = | 875 window_manager_connection_ = |
876 views::WindowManagerConnection::Create(connector, identity); | 876 views::WindowManagerConnection::Create(connector, identity); |
877 } | 877 } |
878 | 878 |
879 bool Browser::AcceptConnection(shell::Connection* connection) { | 879 bool Browser::OnConnect(shell::Connection* connection) { |
880 connection->AddInterface<mojom::Launchable>(this); | 880 connection->AddInterface<mojom::Launchable>(this); |
881 return true; | 881 return true; |
882 } | 882 } |
883 | 883 |
884 void Browser::Launch(uint32_t what, mojom::LaunchMode how) { | 884 void Browser::Launch(uint32_t what, mojom::LaunchMode how) { |
885 bool reuse = | 885 bool reuse = |
886 how == mojom::LaunchMode::REUSE || how == mojom::LaunchMode::DEFAULT; | 886 how == mojom::LaunchMode::REUSE || how == mojom::LaunchMode::DEFAULT; |
887 if (reuse && !windows_.empty()) { | 887 if (reuse && !windows_.empty()) { |
888 windows_.back()->Activate(); | 888 windows_.back()->Activate(); |
889 return; | 889 return; |
890 } | 890 } |
891 | 891 |
892 UI* ui = new UI(this, UI::Type::WINDOW, CreateView()); | 892 UI* ui = new UI(this, UI::Type::WINDOW, CreateView()); |
893 views::Widget* window = views::Widget::CreateWindowWithContextAndBounds( | 893 views::Widget* window = views::Widget::CreateWindowWithContextAndBounds( |
894 ui, nullptr, gfx::Rect(10, 10, 1024, 600)); | 894 ui, nullptr, gfx::Rect(10, 10, 1024, 600)); |
895 ui->NavigateTo(GURL("http://www.google.com/")); | 895 ui->NavigateTo(GURL("http://www.google.com/")); |
896 window->Show(); | 896 window->Show(); |
897 AddWindow(window); | 897 AddWindow(window); |
898 } | 898 } |
899 | 899 |
900 void Browser::Create(shell::Connection* connection, | 900 void Browser::Create(shell::Connection* connection, |
901 mojom::LaunchableRequest request) { | 901 mojom::LaunchableRequest request) { |
902 bindings_.AddBinding(this, std::move(request)); | 902 bindings_.AddBinding(this, std::move(request)); |
903 } | 903 } |
904 | 904 |
905 } // namespace browser | 905 } // namespace browser |
906 } // namespace mash | 906 } // namespace mash |
OLD | NEW |