| 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 "ash/public/cpp/shelf_types.h" |
| 8 #include "ash/public/cpp/window_properties.h" |
| 7 #include "base/macros.h" | 9 #include "base/macros.h" |
| 8 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| 9 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
| 10 #include "base/run_loop.h" | 12 #include "base/run_loop.h" |
| 11 #include "base/strings/string16.h" | 13 #include "base/strings/string16.h" |
| 12 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
| 14 #include "mash/public/interfaces/launchable.mojom.h" | 16 #include "mash/public/interfaces/launchable.mojom.h" |
| 15 #include "services/catalog/public/interfaces/catalog.mojom.h" | 17 #include "services/catalog/public/interfaces/catalog.mojom.h" |
| 16 #include "services/catalog/public/interfaces/constants.mojom.h" | 18 #include "services/catalog/public/interfaces/constants.mojom.h" |
| 17 #include "services/service_manager/public/c/main.h" | 19 #include "services/service_manager/public/c/main.h" |
| 18 #include "services/service_manager/public/cpp/connector.h" | 20 #include "services/service_manager/public/cpp/connector.h" |
| 19 #include "services/service_manager/public/cpp/service.h" | 21 #include "services/service_manager/public/cpp/service.h" |
| 20 #include "services/service_manager/public/cpp/service_context.h" | 22 #include "services/service_manager/public/cpp/service_context.h" |
| 21 #include "services/service_manager/public/cpp/service_runner.h" | 23 #include "services/service_manager/public/cpp/service_runner.h" |
| 22 #include "ui/aura/window.h" | 24 #include "ui/aura/window.h" |
| 23 #include "ui/aura/window_tree_host.h" | |
| 24 #include "ui/views/background.h" | 25 #include "ui/views/background.h" |
| 25 #include "ui/views/controls/textfield/textfield.h" | 26 #include "ui/views/controls/textfield/textfield.h" |
| 26 #include "ui/views/controls/textfield/textfield_controller.h" | 27 #include "ui/views/controls/textfield/textfield_controller.h" |
| 27 #include "ui/views/mus/aura_init.h" | 28 #include "ui/views/mus/aura_init.h" |
| 28 #include "ui/views/widget/widget.h" | 29 #include "ui/views/widget/widget.h" |
| 29 #include "ui/views/widget/widget_delegate.h" | 30 #include "ui/views/widget/widget_delegate.h" |
| 30 #include "url/gurl.h" | 31 #include "url/gurl.h" |
| 31 | 32 |
| 32 namespace mash { | 33 namespace mash { |
| 33 namespace quick_launch { | 34 namespace quick_launch { |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 DCHECK(it != windows_.end()); | 168 DCHECK(it != windows_.end()); |
| 168 windows_.erase(it); | 169 windows_.erase(it); |
| 169 if (windows_.empty() && base::RunLoop::IsRunningOnCurrentThread()) | 170 if (windows_.empty() && base::RunLoop::IsRunningOnCurrentThread()) |
| 170 base::MessageLoop::current()->QuitWhenIdle(); | 171 base::MessageLoop::current()->QuitWhenIdle(); |
| 171 } | 172 } |
| 172 | 173 |
| 173 void QuickLaunch::OnStart() { | 174 void QuickLaunch::OnStart() { |
| 174 aura_init_ = base::MakeUnique<views::AuraInit>( | 175 aura_init_ = base::MakeUnique<views::AuraInit>( |
| 175 context()->connector(), context()->identity(), "views_mus_resources.pak", | 176 context()->connector(), context()->identity(), "views_mus_resources.pak", |
| 176 std::string(), nullptr, views::AuraInit::Mode::AURA_MUS); | 177 std::string(), nullptr, views::AuraInit::Mode::AURA_MUS); |
| 177 | 178 ash::RegisterWindowPropertiesForTransportAndMirroring(); |
| 178 Launch(mojom::kWindow, mojom::LaunchMode::MAKE_NEW); | 179 Launch(mojom::kWindow, mojom::LaunchMode::MAKE_NEW); |
| 179 } | 180 } |
| 180 | 181 |
| 181 void QuickLaunch::OnBindInterface( | 182 void QuickLaunch::OnBindInterface( |
| 182 const service_manager::BindSourceInfo& source_info, | 183 const service_manager::BindSourceInfo& source_info, |
| 183 const std::string& interface_name, | 184 const std::string& interface_name, |
| 184 mojo::ScopedMessagePipeHandle interface_pipe) { | 185 mojo::ScopedMessagePipeHandle interface_pipe) { |
| 185 registry_.BindInterface(source_info, interface_name, | 186 registry_.BindInterface(source_info, interface_name, |
| 186 std::move(interface_pipe)); | 187 std::move(interface_pipe)); |
| 187 } | 188 } |
| 188 | 189 |
| 189 void QuickLaunch::Launch(uint32_t what, mojom::LaunchMode how) { | 190 void QuickLaunch::Launch(uint32_t what, mojom::LaunchMode how) { |
| 190 bool reuse = how == mojom::LaunchMode::REUSE || | 191 bool reuse = how == mojom::LaunchMode::REUSE || |
| 191 how == mojom::LaunchMode::DEFAULT; | 192 how == mojom::LaunchMode::DEFAULT; |
| 192 if (reuse && !windows_.empty()) { | 193 if (reuse && !windows_.empty()) { |
| 193 windows_.back()->Activate(); | 194 windows_.back()->Activate(); |
| 194 return; | 195 return; |
| 195 } | 196 } |
| 196 catalog::mojom::CatalogPtr catalog; | 197 catalog::mojom::CatalogPtr catalog; |
| 197 context()->connector()->BindInterface(catalog::mojom::kServiceName, &catalog); | 198 context()->connector()->BindInterface(catalog::mojom::kServiceName, &catalog); |
| 198 | 199 |
| 199 views::Widget* window = views::Widget::CreateWindowWithContextAndBounds( | 200 views::Widget* widget = views::Widget::CreateWindowWithContextAndBounds( |
| 200 new QuickLaunchUI(this, context()->connector(), std::move(catalog)), | 201 new QuickLaunchUI(this, context()->connector(), std::move(catalog)), |
| 201 nullptr, gfx::Rect(10, 640, 0, 0)); | 202 nullptr, gfx::Rect(10, 640, 0, 0)); |
| 202 window->GetNativeWindow()->GetHost()->window()->SetName("QuickLaunch"); | 203 aura::Window* window = widget->GetNativeWindow(); |
| 203 window->Show(); | 204 window->SetName("QuickLaunch"); |
| 204 windows_.push_back(window); | 205 const ash::ShelfID shelf_id("org.chromium.mash.quick_launch"); |
| 206 window->SetProperty(ash::kShelfIDKey, new std::string(shelf_id.Serialize())); |
| 207 window->SetProperty<int>(ash::kShelfItemTypeKey, ash::TYPE_DIALOG); |
| 208 |
| 209 widget->Show(); |
| 210 windows_.push_back(widget); |
| 205 } | 211 } |
| 206 | 212 |
| 207 void QuickLaunch::Create(const service_manager::BindSourceInfo& source_info, | 213 void QuickLaunch::Create(const service_manager::BindSourceInfo& source_info, |
| 208 ::mash::mojom::LaunchableRequest request) { | 214 ::mash::mojom::LaunchableRequest request) { |
| 209 bindings_.AddBinding(this, std::move(request)); | 215 bindings_.AddBinding(this, std::move(request)); |
| 210 } | 216 } |
| 211 | 217 |
| 212 } // namespace quick_launch | 218 } // namespace quick_launch |
| 213 } // namespace mash | 219 } // namespace mash |
| OLD | NEW |