Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(139)

Side by Side Diff: mash/catalog_viewer/catalog_viewer.cc

Issue 2915223002: mash: Fix mash app shelf items; encapsulate ash property setup. (Closed)
Patch Set: Similar changes for other mash apps. Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/catalog_viewer/catalog_viewer.h" 5 #include "mash/catalog_viewer/catalog_viewer.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "ash/public/cpp/shelf_types.h"
11 #include "ash/public/cpp/window_properties.h"
10 #include "base/bind.h" 12 #include "base/bind.h"
11 #include "base/macros.h" 13 #include "base/macros.h"
12 #include "base/memory/ptr_util.h" 14 #include "base/memory/ptr_util.h"
13 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
14 #include "base/message_loop/message_loop.h" 16 #include "base/message_loop/message_loop.h"
15 #include "base/strings/utf_string_conversions.h" 17 #include "base/strings/utf_string_conversions.h"
16 #include "mojo/public/cpp/bindings/binding.h" 18 #include "mojo/public/cpp/bindings/binding.h"
17 #include "services/catalog/public/interfaces/catalog.mojom.h" 19 #include "services/catalog/public/interfaces/catalog.mojom.h"
18 #include "services/catalog/public/interfaces/constants.mojom.h" 20 #include "services/catalog/public/interfaces/constants.mojom.h"
19 #include "services/service_manager/public/cpp/connector.h" 21 #include "services/service_manager/public/cpp/connector.h"
20 #include "services/service_manager/public/cpp/service_context.h" 22 #include "services/service_manager/public/cpp/service_context.h"
23 #include "ui/aura/window.h"
21 #include "ui/base/models/table_model.h" 24 #include "ui/base/models/table_model.h"
22 #include "ui/base/resource/resource_bundle.h" 25 #include "ui/base/resource/resource_bundle.h"
23 #include "ui/resources/grit/ui_resources.h" 26 #include "ui/resources/grit/ui_resources.h"
24 #include "ui/views/background.h" 27 #include "ui/views/background.h"
25 #include "ui/views/border.h" 28 #include "ui/views/border.h"
26 #include "ui/views/controls/label.h" 29 #include "ui/views/controls/label.h"
27 #include "ui/views/controls/table/table_view.h" 30 #include "ui/views/controls/table/table_view.h"
28 #include "ui/views/controls/table/table_view_observer.h" 31 #include "ui/views/controls/table/table_view_observer.h"
29 #include "ui/views/controls/textfield/textfield.h" 32 #include "ui/views/controls/textfield/textfield.h"
30 #include "ui/views/controls/textfield/textfield_controller.h" 33 #include "ui/views/controls/textfield/textfield_controller.h"
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 DCHECK(it != windows_.end()); 221 DCHECK(it != windows_.end());
219 windows_.erase(it); 222 windows_.erase(it);
220 if (windows_.empty()) 223 if (windows_.empty())
221 base::MessageLoop::current()->QuitWhenIdle(); 224 base::MessageLoop::current()->QuitWhenIdle();
222 } 225 }
223 226
224 void CatalogViewer::OnStart() { 227 void CatalogViewer::OnStart() {
225 aura_init_ = base::MakeUnique<views::AuraInit>( 228 aura_init_ = base::MakeUnique<views::AuraInit>(
226 context()->connector(), context()->identity(), "views_mus_resources.pak", 229 context()->connector(), context()->identity(), "views_mus_resources.pak",
227 std::string(), nullptr, views::AuraInit::Mode::AURA_MUS); 230 std::string(), nullptr, views::AuraInit::Mode::AURA_MUS);
231 ash::RegisterWindowPropertiesForTransportAndMirroring();
228 } 232 }
229 233
230 void CatalogViewer::OnBindInterface( 234 void CatalogViewer::OnBindInterface(
231 const service_manager::BindSourceInfo& source_info, 235 const service_manager::BindSourceInfo& source_info,
232 const std::string& interface_name, 236 const std::string& interface_name,
233 mojo::ScopedMessagePipeHandle interface_pipe) { 237 mojo::ScopedMessagePipeHandle interface_pipe) {
234 registry_.BindInterface(source_info, interface_name, 238 registry_.BindInterface(source_info, interface_name,
235 std::move(interface_pipe)); 239 std::move(interface_pipe));
236 } 240 }
237 241
238 void CatalogViewer::Launch(uint32_t what, mojom::LaunchMode how) { 242 void CatalogViewer::Launch(uint32_t what, mojom::LaunchMode how) {
239 bool reuse = how == mojom::LaunchMode::REUSE || 243 bool reuse = how == mojom::LaunchMode::REUSE ||
240 how == mojom::LaunchMode::DEFAULT; 244 how == mojom::LaunchMode::DEFAULT;
241 if (reuse && !windows_.empty()) { 245 if (reuse && !windows_.empty()) {
242 windows_.back()->Activate(); 246 windows_.back()->Activate();
243 return; 247 return;
244 } 248 }
245 catalog::mojom::CatalogPtr catalog; 249 catalog::mojom::CatalogPtr catalog;
246 context()->connector()->BindInterface(catalog::mojom::kServiceName, &catalog); 250 context()->connector()->BindInterface(catalog::mojom::kServiceName, &catalog);
247 251
248 views::Widget* window = views::Widget::CreateWindowWithContextAndBounds( 252 views::Widget* widget = views::Widget::CreateWindowWithContextAndBounds(
249 new CatalogViewerContents(this, std::move(catalog)), nullptr, 253 new CatalogViewerContents(this, std::move(catalog)), nullptr,
250 gfx::Rect(25, 25, 500, 600)); 254 gfx::Rect(25, 25, 500, 600));
251 window->Show(); 255 aura::Window* window = widget->GetNativeWindow();
252 windows_.push_back(window); 256 const ash::ShelfID shelf_id("org.chromium.mash.catalog_viewer");
257 window->SetProperty(ash::kShelfIDKey, new std::string(shelf_id.Serialize()));
258 window->SetProperty<int>(ash::kShelfItemTypeKey, ash::TYPE_DIALOG);
259
260 widget->Show();
261 windows_.push_back(widget);
253 } 262 }
254 263
255 void CatalogViewer::Create(const service_manager::BindSourceInfo& source_info, 264 void CatalogViewer::Create(const service_manager::BindSourceInfo& source_info,
256 mojom::LaunchableRequest request) { 265 mojom::LaunchableRequest request) {
257 bindings_.AddBinding(this, std::move(request)); 266 bindings_.AddBinding(this, std::move(request));
258 } 267 }
259 268
260 } // namespace catalog_viewer 269 } // namespace catalog_viewer
261 } // namespace mash 270 } // namespace mash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698