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

Side by Side Diff: mash/example/window_type_launcher/window_type_launcher.cc

Issue 2420253002: Rename shell namespace to service_manager (Closed)
Patch Set: . Created 4 years, 2 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
« no previous file with comments | « mash/example/window_type_launcher/window_type_launcher.h ('k') | mash/init/init.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/example/window_type_launcher/window_type_launcher.h" 5 #include "mash/example/window_type_launcher/window_type_launcher.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 } 218 }
219 219
220 // The contents view/delegate of a window that shows some buttons that create 220 // The contents view/delegate of a window that shows some buttons that create
221 // various window types. 221 // various window types.
222 class WindowTypeLauncherView : public views::WidgetDelegateView, 222 class WindowTypeLauncherView : public views::WidgetDelegateView,
223 public views::ButtonListener, 223 public views::ButtonListener,
224 public views::MenuDelegate, 224 public views::MenuDelegate,
225 public views::ContextMenuController { 225 public views::ContextMenuController {
226 public: 226 public:
227 explicit WindowTypeLauncherView(WindowTypeLauncher* window_type_launcher, 227 explicit WindowTypeLauncherView(WindowTypeLauncher* window_type_launcher,
228 shell::Connector* connector) 228 service_manager::Connector* connector)
229 : window_type_launcher_(window_type_launcher), 229 : window_type_launcher_(window_type_launcher),
230 connector_(connector), 230 connector_(connector),
231 create_button_( 231 create_button_(
232 MdTextButton::Create(this, base::ASCIIToUTF16("Create Window"))), 232 MdTextButton::Create(this, base::ASCIIToUTF16("Create Window"))),
233 always_on_top_button_(MdTextButton::Create( 233 always_on_top_button_(MdTextButton::Create(
234 this, 234 this,
235 base::ASCIIToUTF16("Create Always On Top Window"))), 235 base::ASCIIToUTF16("Create Always On Top Window"))),
236 panel_button_( 236 panel_button_(
237 MdTextButton::Create(this, base::ASCIIToUTF16("Create Panel"))), 237 MdTextButton::Create(this, base::ASCIIToUTF16("Create Panel"))),
238 create_nonresizable_button_(MdTextButton::Create( 238 create_nonresizable_button_(MdTextButton::Create(
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 MenuItemView::NORMAL); 425 MenuItemView::NORMAL);
426 // MenuRunner takes ownership of root. 426 // MenuRunner takes ownership of root.
427 menu_runner_.reset(new MenuRunner( 427 menu_runner_.reset(new MenuRunner(
428 root, MenuRunner::HAS_MNEMONICS | views::MenuRunner::CONTEXT_MENU | 428 root, MenuRunner::HAS_MNEMONICS | views::MenuRunner::CONTEXT_MENU |
429 views::MenuRunner::ASYNC)); 429 views::MenuRunner::ASYNC));
430 menu_runner_->RunMenuAt(GetWidget(), NULL, gfx::Rect(point, gfx::Size()), 430 menu_runner_->RunMenuAt(GetWidget(), NULL, gfx::Rect(point, gfx::Size()),
431 views::MENU_ANCHOR_TOPLEFT, source_type); 431 views::MENU_ANCHOR_TOPLEFT, source_type);
432 } 432 }
433 433
434 WindowTypeLauncher* window_type_launcher_; 434 WindowTypeLauncher* window_type_launcher_;
435 shell::Connector* connector_; 435 service_manager::Connector* connector_;
436 views::Button* create_button_; 436 views::Button* create_button_;
437 views::Button* always_on_top_button_; 437 views::Button* always_on_top_button_;
438 views::Button* panel_button_; 438 views::Button* panel_button_;
439 views::Button* create_nonresizable_button_; 439 views::Button* create_nonresizable_button_;
440 views::Button* bubble_button_; 440 views::Button* bubble_button_;
441 views::Button* lock_button_; 441 views::Button* lock_button_;
442 views::Button* logout_button_; 442 views::Button* logout_button_;
443 views::Button* switch_user_button_; 443 views::Button* switch_user_button_;
444 views::Button* widgets_button_; 444 views::Button* widgets_button_;
445 views::Button* system_modal_button_; 445 views::Button* system_modal_button_;
(...skipping 16 matching lines...) Expand all
462 WindowTypeLauncher::~WindowTypeLauncher() {} 462 WindowTypeLauncher::~WindowTypeLauncher() {}
463 463
464 void WindowTypeLauncher::RemoveWindow(views::Widget* window) { 464 void WindowTypeLauncher::RemoveWindow(views::Widget* window) {
465 auto it = std::find(windows_.begin(), windows_.end(), window); 465 auto it = std::find(windows_.begin(), windows_.end(), window);
466 DCHECK(it != windows_.end()); 466 DCHECK(it != windows_.end());
467 windows_.erase(it); 467 windows_.erase(it);
468 if (windows_.empty()) 468 if (windows_.empty())
469 base::MessageLoop::current()->QuitWhenIdle(); 469 base::MessageLoop::current()->QuitWhenIdle();
470 } 470 }
471 471
472 void WindowTypeLauncher::OnStart(const shell::Identity& identity) { 472 void WindowTypeLauncher::OnStart(const service_manager::Identity& identity) {
473 aura_init_.reset( 473 aura_init_.reset(
474 new views::AuraInit(connector(), "views_mus_resources.pak")); 474 new views::AuraInit(connector(), "views_mus_resources.pak"));
475 window_manager_connection_ = 475 window_manager_connection_ =
476 views::WindowManagerConnection::Create(connector(), identity); 476 views::WindowManagerConnection::Create(connector(), identity);
477 } 477 }
478 478
479 bool WindowTypeLauncher::OnConnect(const shell::Identity& remote_identity, 479 bool WindowTypeLauncher::OnConnect(
480 shell::InterfaceRegistry* registry) { 480 const service_manager::Identity& remote_identity,
481 service_manager::InterfaceRegistry* registry) {
481 registry->AddInterface<mash::mojom::Launchable>(this); 482 registry->AddInterface<mash::mojom::Launchable>(this);
482 return true; 483 return true;
483 } 484 }
484 485
485 void WindowTypeLauncher::Launch(uint32_t what, mash::mojom::LaunchMode how) { 486 void WindowTypeLauncher::Launch(uint32_t what, mash::mojom::LaunchMode how) {
486 bool reuse = how == mash::mojom::LaunchMode::REUSE || 487 bool reuse = how == mash::mojom::LaunchMode::REUSE ||
487 how == mash::mojom::LaunchMode::DEFAULT; 488 how == mash::mojom::LaunchMode::DEFAULT;
488 if (reuse && !windows_.empty()) { 489 if (reuse && !windows_.empty()) {
489 windows_.back()->Activate(); 490 windows_.back()->Activate();
490 return; 491 return;
491 } 492 }
492 views::Widget* window = new views::Widget; 493 views::Widget* window = new views::Widget;
493 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); 494 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
494 params.delegate = new WindowTypeLauncherView(this, connector()); 495 params.delegate = new WindowTypeLauncherView(this, connector());
495 window->Init(params); 496 window->Init(params);
496 window->Show(); 497 window->Show();
497 windows_.push_back(window); 498 windows_.push_back(window);
498 } 499 }
499 500
500 void WindowTypeLauncher::Create(const shell::Identity& remote_identity, 501 void WindowTypeLauncher::Create(
501 mash::mojom::LaunchableRequest request) { 502 const service_manager::Identity& remote_identity,
503 mash::mojom::LaunchableRequest request) {
502 bindings_.AddBinding(this, std::move(request)); 504 bindings_.AddBinding(this, std::move(request));
503 } 505 }
504 506
505 MojoResult ServiceMain(MojoHandle service_request_handle) { 507 MojoResult ServiceMain(MojoHandle service_request_handle) {
506 return shell::ServiceRunner(new WindowTypeLauncher) 508 return service_manager::ServiceRunner(new WindowTypeLauncher)
507 .Run(service_request_handle); 509 .Run(service_request_handle);
508 } 510 }
OLDNEW
« no previous file with comments | « mash/example/window_type_launcher/window_type_launcher.h ('k') | mash/init/init.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698