| 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.h" | 5 #include "mash/quick_launch/quick_launch.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/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 } | 133 } |
| 134 | 134 |
| 135 void OnGotCatalogEntries(std::vector<catalog::mojom::EntryPtr> entries) { | 135 void OnGotCatalogEntries(std::vector<catalog::mojom::EntryPtr> entries) { |
| 136 for (const auto& entry : entries) | 136 for (const auto& entry : entries) |
| 137 app_names_.insert(base::UTF8ToUTF16(entry->name)); | 137 app_names_.insert(base::UTF8ToUTF16(entry->name)); |
| 138 } | 138 } |
| 139 | 139 |
| 140 void Launch(const std::string& name, bool new_window) { | 140 void Launch(const std::string& name, bool new_window) { |
| 141 std::unique_ptr<service_manager::Connection> connection = | 141 std::unique_ptr<service_manager::Connection> connection = |
| 142 connector_->Connect(name); | 142 connector_->Connect(name); |
| 143 mojom::LaunchablePtr launchable; | 143 ::mash::mojom::LaunchablePtr launchable; |
| 144 connection->GetInterface(&launchable); | 144 connection->GetInterface(&launchable); |
| 145 connections_.push_back(std::move(connection)); | 145 connections_.push_back(std::move(connection)); |
| 146 launchable->Launch(mojom::kWindow, | 146 launchable->Launch(mojom::kWindow, |
| 147 new_window ? mojom::LaunchMode::MAKE_NEW | 147 new_window ? mojom::LaunchMode::MAKE_NEW |
| 148 : mojom::LaunchMode::REUSE); | 148 : mojom::LaunchMode::REUSE); |
| 149 } | 149 } |
| 150 | 150 |
| 151 QuickLaunch* quick_launch_; | 151 QuickLaunch* quick_launch_; |
| 152 service_manager::Connector* connector_; | 152 service_manager::Connector* connector_; |
| 153 views::Textfield* prompt_; | 153 views::Textfield* prompt_; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 176 aura_init_ = base::MakeUnique<views::AuraInit>( | 176 aura_init_ = base::MakeUnique<views::AuraInit>( |
| 177 context()->connector(), context()->identity(), "views_mus_resources.pak"); | 177 context()->connector(), context()->identity(), "views_mus_resources.pak"); |
| 178 window_manager_connection_ = views::WindowManagerConnection::Create( | 178 window_manager_connection_ = views::WindowManagerConnection::Create( |
| 179 context()->connector(), context()->identity()); | 179 context()->connector(), context()->identity()); |
| 180 | 180 |
| 181 Launch(mojom::kWindow, mojom::LaunchMode::MAKE_NEW); | 181 Launch(mojom::kWindow, mojom::LaunchMode::MAKE_NEW); |
| 182 } | 182 } |
| 183 | 183 |
| 184 bool QuickLaunch::OnConnect(const service_manager::ServiceInfo& remote_info, | 184 bool QuickLaunch::OnConnect(const service_manager::ServiceInfo& remote_info, |
| 185 service_manager::InterfaceRegistry* registry) { | 185 service_manager::InterfaceRegistry* registry) { |
| 186 registry->AddInterface<mojom::Launchable>(this); | 186 registry->AddInterface<::mash::mojom::Launchable>(this); |
| 187 return true; | 187 return true; |
| 188 } | 188 } |
| 189 | 189 |
| 190 void QuickLaunch::Launch(uint32_t what, mojom::LaunchMode how) { | 190 void QuickLaunch::Launch(uint32_t what, mojom::LaunchMode how) { |
| 191 bool reuse = how == mojom::LaunchMode::REUSE || | 191 bool reuse = how == mojom::LaunchMode::REUSE || |
| 192 how == mojom::LaunchMode::DEFAULT; | 192 how == mojom::LaunchMode::DEFAULT; |
| 193 if (reuse && !windows_.empty()) { | 193 if (reuse && !windows_.empty()) { |
| 194 windows_.back()->Activate(); | 194 windows_.back()->Activate(); |
| 195 return; | 195 return; |
| 196 } | 196 } |
| 197 catalog::mojom::CatalogPtr catalog; | 197 catalog::mojom::CatalogPtr catalog; |
| 198 context()->connector()->ConnectToInterface(catalog::mojom::kServiceName, | 198 context()->connector()->ConnectToInterface(catalog::mojom::kServiceName, |
| 199 &catalog); | 199 &catalog); |
| 200 | 200 |
| 201 views::Widget* window = views::Widget::CreateWindowWithContextAndBounds( | 201 views::Widget* window = views::Widget::CreateWindowWithContextAndBounds( |
| 202 new QuickLaunchUI(this, context()->connector(), std::move(catalog)), | 202 new QuickLaunchUI(this, context()->connector(), std::move(catalog)), |
| 203 nullptr, gfx::Rect(10, 640, 0, 0)); | 203 nullptr, gfx::Rect(10, 640, 0, 0)); |
| 204 window->Show(); | 204 window->Show(); |
| 205 windows_.push_back(window); | 205 windows_.push_back(window); |
| 206 } | 206 } |
| 207 | 207 |
| 208 void QuickLaunch::Create(const service_manager::Identity& remote_identity, | 208 void QuickLaunch::Create(const service_manager::Identity& remote_identity, |
| 209 mojom::LaunchableRequest request) { | 209 ::mash::mojom::LaunchableRequest request) { |
| 210 bindings_.AddBinding(this, std::move(request)); | 210 bindings_.AddBinding(this, std::move(request)); |
| 211 } | 211 } |
| 212 | 212 |
| 213 } // namespace quick_launch | 213 } // namespace quick_launch |
| 214 } // namespace mash | 214 } // namespace mash |
| OLD | NEW |