| 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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 service_manager::Connector* connector_; | 148 service_manager::Connector* connector_; |
| 149 views::Textfield* prompt_; | 149 views::Textfield* prompt_; |
| 150 std::vector<std::unique_ptr<service_manager::Connection>> connections_; | 150 std::vector<std::unique_ptr<service_manager::Connection>> connections_; |
| 151 catalog::mojom::CatalogPtr catalog_; | 151 catalog::mojom::CatalogPtr catalog_; |
| 152 std::set<base::string16> app_names_; | 152 std::set<base::string16> app_names_; |
| 153 bool suggestion_rejected_ = false; | 153 bool suggestion_rejected_ = false; |
| 154 | 154 |
| 155 DISALLOW_COPY_AND_ASSIGN(QuickLaunchUI); | 155 DISALLOW_COPY_AND_ASSIGN(QuickLaunchUI); |
| 156 }; | 156 }; |
| 157 | 157 |
| 158 QuickLaunch::QuickLaunch() {} | 158 QuickLaunch::QuickLaunch() { |
| 159 registry_.AddInterface<::mash::mojom::Launchable>(this); |
| 160 } |
| 159 QuickLaunch::~QuickLaunch() {} | 161 QuickLaunch::~QuickLaunch() {} |
| 160 | 162 |
| 161 void QuickLaunch::RemoveWindow(views::Widget* window) { | 163 void QuickLaunch::RemoveWindow(views::Widget* window) { |
| 162 auto it = std::find(windows_.begin(), windows_.end(), window); | 164 auto it = std::find(windows_.begin(), windows_.end(), window); |
| 163 DCHECK(it != windows_.end()); | 165 DCHECK(it != windows_.end()); |
| 164 windows_.erase(it); | 166 windows_.erase(it); |
| 165 if (windows_.empty() && base::MessageLoop::current()->is_running()) | 167 if (windows_.empty() && base::MessageLoop::current()->is_running()) |
| 166 base::MessageLoop::current()->QuitWhenIdle(); | 168 base::MessageLoop::current()->QuitWhenIdle(); |
| 167 } | 169 } |
| 168 | 170 |
| 169 void QuickLaunch::OnStart() { | 171 void QuickLaunch::OnStart() { |
| 170 tracing_.Initialize(context()->connector(), context()->identity().name()); | 172 tracing_.Initialize(context()->connector(), context()->identity().name()); |
| 171 | 173 |
| 172 aura_init_ = base::MakeUnique<views::AuraInit>( | 174 aura_init_ = base::MakeUnique<views::AuraInit>( |
| 173 context()->connector(), context()->identity(), "views_mus_resources.pak", | 175 context()->connector(), context()->identity(), "views_mus_resources.pak", |
| 174 std::string(), nullptr, views::AuraInit::Mode::AURA_MUS); | 176 std::string(), nullptr, views::AuraInit::Mode::AURA_MUS); |
| 175 | 177 |
| 176 Launch(mojom::kWindow, mojom::LaunchMode::MAKE_NEW); | 178 Launch(mojom::kWindow, mojom::LaunchMode::MAKE_NEW); |
| 177 } | 179 } |
| 178 | 180 |
| 179 bool QuickLaunch::OnConnect(const service_manager::ServiceInfo& remote_info, | 181 void QuickLaunch::OnBindInterface( |
| 180 service_manager::InterfaceRegistry* registry) { | 182 const service_manager::ServiceInfo& source_info, |
| 181 registry->AddInterface<::mash::mojom::Launchable>(this); | 183 const std::string& interface_name, |
| 182 return true; | 184 mojo::ScopedMessagePipeHandle interface_pipe) { |
| 185 registry_.BindInterface(source_info.identity, interface_name, |
| 186 std::move(interface_pipe)); |
| 183 } | 187 } |
| 184 | 188 |
| 185 void QuickLaunch::Launch(uint32_t what, mojom::LaunchMode how) { | 189 void QuickLaunch::Launch(uint32_t what, mojom::LaunchMode how) { |
| 186 bool reuse = how == mojom::LaunchMode::REUSE || | 190 bool reuse = how == mojom::LaunchMode::REUSE || |
| 187 how == mojom::LaunchMode::DEFAULT; | 191 how == mojom::LaunchMode::DEFAULT; |
| 188 if (reuse && !windows_.empty()) { | 192 if (reuse && !windows_.empty()) { |
| 189 windows_.back()->Activate(); | 193 windows_.back()->Activate(); |
| 190 return; | 194 return; |
| 191 } | 195 } |
| 192 catalog::mojom::CatalogPtr catalog; | 196 catalog::mojom::CatalogPtr catalog; |
| 193 context()->connector()->BindInterface(catalog::mojom::kServiceName, &catalog); | 197 context()->connector()->BindInterface(catalog::mojom::kServiceName, &catalog); |
| 194 | 198 |
| 195 views::Widget* window = views::Widget::CreateWindowWithContextAndBounds( | 199 views::Widget* window = views::Widget::CreateWindowWithContextAndBounds( |
| 196 new QuickLaunchUI(this, context()->connector(), std::move(catalog)), | 200 new QuickLaunchUI(this, context()->connector(), std::move(catalog)), |
| 197 nullptr, gfx::Rect(10, 640, 0, 0)); | 201 nullptr, gfx::Rect(10, 640, 0, 0)); |
| 198 window->Show(); | 202 window->Show(); |
| 199 windows_.push_back(window); | 203 windows_.push_back(window); |
| 200 } | 204 } |
| 201 | 205 |
| 202 void QuickLaunch::Create(const service_manager::Identity& remote_identity, | 206 void QuickLaunch::Create(const service_manager::Identity& remote_identity, |
| 203 ::mash::mojom::LaunchableRequest request) { | 207 ::mash::mojom::LaunchableRequest request) { |
| 204 bindings_.AddBinding(this, std::move(request)); | 208 bindings_.AddBinding(this, std::move(request)); |
| 205 } | 209 } |
| 206 | 210 |
| 207 } // namespace quick_launch | 211 } // namespace quick_launch |
| 208 } // namespace mash | 212 } // namespace mash |
| OLD | NEW |