| 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/quick_launch/quick_launch_application.h" | 5 #include "mash/quick_launch/quick_launch_application.h" |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/strings/string16.h" | 9 #include "base/strings/string16.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| 11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 12 #include "mash/public/interfaces/launchable.mojom.h" | 12 #include "mash/public/interfaces/launchable.mojom.h" |
| 13 #include "mojo/public/c/system/main.h" | 13 #include "mojo/public/c/system/main.h" |
| 14 #include "services/catalog/public/interfaces/catalog.mojom.h" | 14 #include "services/catalog/public/interfaces/catalog.mojom.h" |
| 15 #include "services/shell/public/cpp/application_runner.h" | 15 #include "services/shell/public/cpp/application_runner.h" |
| 16 #include "services/shell/public/cpp/connector.h" | 16 #include "services/shell/public/cpp/connector.h" |
| 17 #include "services/shell/public/cpp/shell_client.h" | 17 #include "services/shell/public/cpp/service.h" |
| 18 #include "services/tracing/public/cpp/tracing_impl.h" | 18 #include "services/tracing/public/cpp/tracing_impl.h" |
| 19 #include "services/ui/common/gpu_service.h" | 19 #include "services/ui/common/gpu_service.h" |
| 20 #include "ui/views/background.h" | 20 #include "ui/views/background.h" |
| 21 #include "ui/views/controls/textfield/textfield.h" | 21 #include "ui/views/controls/textfield/textfield.h" |
| 22 #include "ui/views/controls/textfield/textfield_controller.h" | 22 #include "ui/views/controls/textfield/textfield_controller.h" |
| 23 #include "ui/views/mus/aura_init.h" | 23 #include "ui/views/mus/aura_init.h" |
| 24 #include "ui/views/mus/window_manager_connection.h" | 24 #include "ui/views/mus/window_manager_connection.h" |
| 25 #include "ui/views/widget/widget_delegate.h" | 25 #include "ui/views/widget/widget_delegate.h" |
| 26 #include "url/gurl.h" | 26 #include "url/gurl.h" |
| 27 | 27 |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 QuickLaunchApplication::~QuickLaunchApplication() {} | 157 QuickLaunchApplication::~QuickLaunchApplication() {} |
| 158 | 158 |
| 159 void QuickLaunchApplication::RemoveWindow(views::Widget* window) { | 159 void QuickLaunchApplication::RemoveWindow(views::Widget* window) { |
| 160 auto it = std::find(windows_.begin(), windows_.end(), window); | 160 auto it = std::find(windows_.begin(), windows_.end(), window); |
| 161 DCHECK(it != windows_.end()); | 161 DCHECK(it != windows_.end()); |
| 162 windows_.erase(it); | 162 windows_.erase(it); |
| 163 if (windows_.empty() && base::MessageLoop::current()->is_running()) | 163 if (windows_.empty() && base::MessageLoop::current()->is_running()) |
| 164 base::MessageLoop::current()->QuitWhenIdle(); | 164 base::MessageLoop::current()->QuitWhenIdle(); |
| 165 } | 165 } |
| 166 | 166 |
| 167 void QuickLaunchApplication::Initialize(shell::Connector* connector, | 167 void QuickLaunchApplication::OnStart(shell::Connector* connector, |
| 168 const shell::Identity& identity, | 168 const shell::Identity& identity, |
| 169 uint32_t id) { | 169 uint32_t id) { |
| 170 connector_ = connector; | 170 connector_ = connector; |
| 171 ui::GpuService::Initialize(connector); | 171 ui::GpuService::Initialize(connector); |
| 172 tracing_.Initialize(connector, identity.name()); | 172 tracing_.Initialize(connector, identity.name()); |
| 173 | 173 |
| 174 aura_init_.reset(new views::AuraInit(connector, "views_mus_resources.pak")); | 174 aura_init_.reset(new views::AuraInit(connector, "views_mus_resources.pak")); |
| 175 window_manager_connection_ = | 175 window_manager_connection_ = |
| 176 views::WindowManagerConnection::Create(connector, identity); | 176 views::WindowManagerConnection::Create(connector, identity); |
| 177 | 177 |
| 178 Launch(mojom::kWindow, mojom::LaunchMode::MAKE_NEW); | 178 Launch(mojom::kWindow, mojom::LaunchMode::MAKE_NEW); |
| 179 } | 179 } |
| 180 | 180 |
| 181 bool QuickLaunchApplication::AcceptConnection(shell::Connection* connection) { | 181 bool QuickLaunchApplication::OnConnect(shell::Connection* connection) { |
| 182 connection->AddInterface<mojom::Launchable>(this); | 182 connection->AddInterface<mojom::Launchable>(this); |
| 183 return true; | 183 return true; |
| 184 } | 184 } |
| 185 | 185 |
| 186 void QuickLaunchApplication::Launch(uint32_t what, mojom::LaunchMode how) { | 186 void QuickLaunchApplication::Launch(uint32_t what, mojom::LaunchMode how) { |
| 187 bool reuse = how == mojom::LaunchMode::REUSE || | 187 bool reuse = how == mojom::LaunchMode::REUSE || |
| 188 how == mojom::LaunchMode::DEFAULT; | 188 how == mojom::LaunchMode::DEFAULT; |
| 189 if (reuse && !windows_.empty()) { | 189 if (reuse && !windows_.empty()) { |
| 190 windows_.back()->Activate(); | 190 windows_.back()->Activate(); |
| 191 return; | 191 return; |
| 192 } | 192 } |
| 193 catalog::mojom::CatalogPtr catalog; | 193 catalog::mojom::CatalogPtr catalog; |
| 194 connector_->ConnectToInterface("mojo:catalog", &catalog); | 194 connector_->ConnectToInterface("mojo:catalog", &catalog); |
| 195 | 195 |
| 196 views::Widget* window = views::Widget::CreateWindowWithContextAndBounds( | 196 views::Widget* window = views::Widget::CreateWindowWithContextAndBounds( |
| 197 new QuickLaunchUI(this, connector_, std::move(catalog)), nullptr, | 197 new QuickLaunchUI(this, connector_, std::move(catalog)), nullptr, |
| 198 gfx::Rect(10, 640, 0, 0)); | 198 gfx::Rect(10, 640, 0, 0)); |
| 199 window->Show(); | 199 window->Show(); |
| 200 windows_.push_back(window); | 200 windows_.push_back(window); |
| 201 } | 201 } |
| 202 | 202 |
| 203 void QuickLaunchApplication::Create(shell::Connection* connection, | 203 void QuickLaunchApplication::Create(shell::Connection* connection, |
| 204 mojom::LaunchableRequest request) { | 204 mojom::LaunchableRequest request) { |
| 205 bindings_.AddBinding(this, std::move(request)); | 205 bindings_.AddBinding(this, std::move(request)); |
| 206 } | 206 } |
| 207 | 207 |
| 208 } // namespace quick_launch | 208 } // namespace quick_launch |
| 209 } // namespace mash | 209 } // namespace mash |
| OLD | NEW |