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

Side by Side Diff: ash/shell.cc

Issue 2898743002: Draggable peeking/fullscreen launcher with transparent background. (Closed)
Patch Set: Addressed comments. 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 (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 "ash/shell.h" 5 #include "ash/shell.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 10
11 #include "ash/accelerators/accelerator_controller.h" 11 #include "ash/accelerators/accelerator_controller.h"
12 #include "ash/accelerators/accelerator_delegate.h" 12 #include "ash/accelerators/accelerator_delegate.h"
13 #include "ash/accelerators/ash_focus_manager_factory.h" 13 #include "ash/accelerators/ash_focus_manager_factory.h"
14 #include "ash/accelerators/magnifier_key_scroller.h" 14 #include "ash/accelerators/magnifier_key_scroller.h"
15 #include "ash/accelerators/spoken_feedback_toggler.h" 15 #include "ash/accelerators/spoken_feedback_toggler.h"
16 #include "ash/accessibility_delegate.h" 16 #include "ash/accessibility_delegate.h"
17 #include "ash/app_list/app_list_delegate_impl.h"
18 #include "ash/ash_constants.h" 17 #include "ash/ash_constants.h"
19 #include "ash/ash_switches.h" 18 #include "ash/ash_switches.h"
20 #include "ash/aura/shell_port_classic.h" 19 #include "ash/aura/shell_port_classic.h"
21 #include "ash/autoclick/autoclick_controller.h" 20 #include "ash/autoclick/autoclick_controller.h"
22 #include "ash/cast_config_controller.h" 21 #include "ash/cast_config_controller.h"
23 #include "ash/devtools/ash_devtools_css_agent.h" 22 #include "ash/devtools/ash_devtools_css_agent.h"
24 #include "ash/devtools/ash_devtools_dom_agent.h" 23 #include "ash/devtools/ash_devtools_dom_agent.h"
25 #include "ash/display/cursor_window_controller.h" 24 #include "ash/display/cursor_window_controller.h"
26 #include "ash/display/display_color_manager_chromeos.h" 25 #include "ash/display/display_color_manager_chromeos.h"
27 #include "ash/display/display_configuration_controller.h" 26 #include "ash/display/display_configuration_controller.h"
(...skipping 19 matching lines...) Expand all
47 #include "ash/login_status.h" 46 #include "ash/login_status.h"
48 #include "ash/magnifier/magnification_controller.h" 47 #include "ash/magnifier/magnification_controller.h"
49 #include "ash/magnifier/partial_magnification_controller.h" 48 #include "ash/magnifier/partial_magnification_controller.h"
50 #include "ash/media_controller.h" 49 #include "ash/media_controller.h"
51 #include "ash/new_window_controller.h" 50 #include "ash/new_window_controller.h"
52 #include "ash/palette_delegate.h" 51 #include "ash/palette_delegate.h"
53 #include "ash/public/cpp/config.h" 52 #include "ash/public/cpp/config.h"
54 #include "ash/public/cpp/shell_window_ids.h" 53 #include "ash/public/cpp/shell_window_ids.h"
55 #include "ash/root_window_controller.h" 54 #include "ash/root_window_controller.h"
56 #include "ash/session/session_controller.h" 55 #include "ash/session/session_controller.h"
56 #include "ash/shelf/app_list_button.h"
xiyuan 2017/06/06 16:50:19 unused?
newcomer 2017/06/06 17:12:56 Done.
57 #include "ash/shelf/shelf.h" 57 #include "ash/shelf/shelf.h"
58 #include "ash/shelf/shelf_controller.h" 58 #include "ash/shelf/shelf_controller.h"
59 #include "ash/shelf/shelf_model.h" 59 #include "ash/shelf/shelf_model.h"
60 #include "ash/shelf/shelf_window_watcher.h" 60 #include "ash/shelf/shelf_window_watcher.h"
61 #include "ash/shell_delegate.h" 61 #include "ash/shell_delegate.h"
62 #include "ash/shell_init_params.h" 62 #include "ash/shell_init_params.h"
63 #include "ash/shell_observer.h" 63 #include "ash/shell_observer.h"
64 #include "ash/shell_port.h" 64 #include "ash/shell_port.h"
65 #include "ash/shutdown_controller.h" 65 #include "ash/shutdown_controller.h"
66 #include "ash/sticky_keys/sticky_keys_controller.h" 66 #include "ash/sticky_keys/sticky_keys_controller.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 #include "chromeos/chromeos_switches.h" 129 #include "chromeos/chromeos_switches.h"
130 #include "chromeos/dbus/dbus_thread_manager.h" 130 #include "chromeos/dbus/dbus_thread_manager.h"
131 #include "chromeos/system/devicemode.h" 131 #include "chromeos/system/devicemode.h"
132 #include "components/prefs/pref_registry_simple.h" 132 #include "components/prefs/pref_registry_simple.h"
133 #include "components/prefs/pref_service.h" 133 #include "components/prefs/pref_service.h"
134 #include "components/ui_devtools/devtools_server.h" 134 #include "components/ui_devtools/devtools_server.h"
135 #include "services/preferences/public/cpp/pref_service_factory.h" 135 #include "services/preferences/public/cpp/pref_service_factory.h"
136 #include "services/preferences/public/interfaces/preferences.mojom.h" 136 #include "services/preferences/public/interfaces/preferences.mojom.h"
137 #include "services/service_manager/public/cpp/connector.h" 137 #include "services/service_manager/public/cpp/connector.h"
138 #include "services/ui/public/interfaces/constants.mojom.h" 138 #include "services/ui/public/interfaces/constants.mojom.h"
139 #include "ui/app_list/app_list_features.h"
xiyuan 2017/06/06 16:50:19 unused?
newcomer 2017/06/06 17:12:56 Done.
139 #include "ui/app_list/presenter/app_list.h" 140 #include "ui/app_list/presenter/app_list.h"
141 #include "ui/app_list/presenter/app_list_delegate.h"
xiyuan 2017/06/06 16:50:18 remove since it is included in h already.
newcomer 2017/06/06 17:12:56 Done.
140 #include "ui/aura/client/aura_constants.h" 142 #include "ui/aura/client/aura_constants.h"
141 #include "ui/aura/env.h" 143 #include "ui/aura/env.h"
142 #include "ui/aura/layout_manager.h" 144 #include "ui/aura/layout_manager.h"
143 #include "ui/aura/mus/focus_synchronizer.h" 145 #include "ui/aura/mus/focus_synchronizer.h"
144 #include "ui/aura/mus/user_activity_forwarder.h" 146 #include "ui/aura/mus/user_activity_forwarder.h"
145 #include "ui/aura/mus/window_tree_client.h" 147 #include "ui/aura/mus/window_tree_client.h"
146 #include "ui/aura/window.h" 148 #include "ui/aura/window.h"
147 #include "ui/aura/window_event_dispatcher.h" 149 #include "ui/aura/window_event_dispatcher.h"
148 #include "ui/base/ui_base_switches.h" 150 #include "ui/base/ui_base_switches.h"
149 #include "ui/base/user_activity/user_activity_detector.h" 151 #include "ui/base/user_activity/user_activity_detector.h"
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 return app_list_->GetTargetVisibility(); 481 return app_list_->GetTargetVisibility();
480 } 482 }
481 483
482 void Shell::UpdateAfterLoginStatusChange(LoginStatus status) { 484 void Shell::UpdateAfterLoginStatusChange(LoginStatus status) {
483 for (WmWindow* root_window : shell_port_->GetAllRootWindows()) { 485 for (WmWindow* root_window : shell_port_->GetAllRootWindows()) {
484 root_window->GetRootWindowController()->UpdateAfterLoginStatusChange( 486 root_window->GetRootWindowController()->UpdateAfterLoginStatusChange(
485 status); 487 status);
486 } 488 }
487 } 489 }
488 490
491 void Shell::NotifyAppListVisibilityChanged(bool shown,
492 aura::Window* root_window) {
493 for (auto& observer : shell_observers_)
494 observer.OnAppListVisibilityChanged(shown, root_window);
495 }
496
489 void Shell::NotifyMaximizeModeStarted() { 497 void Shell::NotifyMaximizeModeStarted() {
490 for (auto& observer : shell_observers_) 498 for (auto& observer : shell_observers_)
491 observer.OnMaximizeModeStarted(); 499 observer.OnMaximizeModeStarted();
492 } 500 }
493 501
494 void Shell::NotifyMaximizeModeEnding() { 502 void Shell::NotifyMaximizeModeEnding() {
495 for (auto& observer : shell_observers_) 503 for (auto& observer : shell_observers_)
496 observer.OnMaximizeModeEnding(); 504 observer.OnMaximizeModeEnding();
497 } 505 }
498 506
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 // state on ShellPortClassic. http://crbug.com/671246. 597 // state on ShellPortClassic. http://crbug.com/671246.
590 598
591 gpu_support_.reset(shell_delegate_->CreateGPUSupport()); 599 gpu_support_.reset(shell_delegate_->CreateGPUSupport());
592 600
593 // Don't use Shell::GetAshConfig() as |instance_| has not yet been set. 601 // Don't use Shell::GetAshConfig() as |instance_| has not yet been set.
594 if (shell_port_->GetAshConfig() != Config::MASH) { 602 if (shell_port_->GetAshConfig() != Config::MASH) {
595 display_manager_.reset(ScreenAsh::CreateDisplayManager()); 603 display_manager_.reset(ScreenAsh::CreateDisplayManager());
596 window_tree_host_manager_.reset(new WindowTreeHostManager); 604 window_tree_host_manager_.reset(new WindowTreeHostManager);
597 user_metrics_recorder_.reset(new UserMetricsRecorder); 605 user_metrics_recorder_.reset(new UserMetricsRecorder);
598 } 606 }
607 app_list()->set_delegate(this);
599 608
600 PowerStatus::Initialize(); 609 PowerStatus::Initialize();
601 610
602 session_controller_->AddObserver(this); 611 session_controller_->AddObserver(this);
603 } 612 }
604 613
605 Shell::~Shell() { 614 Shell::~Shell() {
606 TRACE_EVENT0("shutdown", "ash::Shell::Destructor"); 615 TRACE_EVENT0("shutdown", "ash::Shell::Destructor");
607 616
608 const Config config = shell_port_->GetAshConfig(); 617 const Config config = shell_port_->GetAshConfig();
609 618
610 if (config != Config::MASH) 619 if (config != Config::MASH)
611 user_metrics_recorder_->OnShellShuttingDown(); 620 user_metrics_recorder_->OnShellShuttingDown();
612 621
622 app_list()->set_delegate(nullptr);
623
613 shell_delegate_->PreShutdown(); 624 shell_delegate_->PreShutdown();
614 625
615 // Remove the focus from any window. This will prevent overhead and side 626 // Remove the focus from any window. This will prevent overhead and side
616 // effects (e.g. crashes) from changing focus during shutdown. 627 // effects (e.g. crashes) from changing focus during shutdown.
617 // See bug crbug.com/134502. 628 // See bug crbug.com/134502.
618 aura::client::GetFocusClient(GetPrimaryRootWindow())->FocusWindow(nullptr); 629 aura::client::GetFocusClient(GetPrimaryRootWindow())->FocusWindow(nullptr);
619 630
620 // Please keep in same order as in Init() because it's easy to miss one. 631 // Please keep in same order as in Init() because it's easy to miss one.
621 if (window_modality_controller_) 632 if (window_modality_controller_)
622 window_modality_controller_.reset(); 633 window_modality_controller_.reset();
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
719 laser_pointer_controller_.reset(); 730 laser_pointer_controller_.reset();
720 partial_magnification_controller_.reset(); 731 partial_magnification_controller_.reset();
721 732
722 // This also deletes all RootWindows. Note that we invoke Shutdown() on 733 // This also deletes all RootWindows. Note that we invoke Shutdown() on
723 // WindowTreeHostManager before resetting |window_tree_host_manager_|, since 734 // WindowTreeHostManager before resetting |window_tree_host_manager_|, since
724 // destruction 735 // destruction
725 // of its owned RootWindowControllers relies on the value. 736 // of its owned RootWindowControllers relies on the value.
726 ScreenAsh::CreateScreenForShutdown(); 737 ScreenAsh::CreateScreenForShutdown();
727 display_configuration_controller_.reset(); 738 display_configuration_controller_.reset();
728 739
729 // AppListDelegateImpl depends upon AppList.
730 app_list_delegate_impl_.reset();
731
732 // These members access Shell in their destructors. 740 // These members access Shell in their destructors.
733 wallpaper_controller_.reset(); 741 wallpaper_controller_.reset();
734 accessibility_delegate_.reset(); 742 accessibility_delegate_.reset();
735 743
736 // Balances the Install() in Initialize(). 744 // Balances the Install() in Initialize().
737 views::FocusManagerFactory::Install(nullptr); 745 views::FocusManagerFactory::Install(nullptr);
738 746
739 // ShelfWindowWatcher has window observers and a pointer to the shelf model. 747 // ShelfWindowWatcher has window observers and a pointer to the shelf model.
740 shelf_window_watcher_.reset(); 748 shelf_window_watcher_.reset();
741 749
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
829 auto dom_backend = base::MakeUnique<devtools::AshDevToolsDOMAgent>(); 837 auto dom_backend = base::MakeUnique<devtools::AshDevToolsDOMAgent>();
830 auto css_backend = 838 auto css_backend =
831 base::MakeUnique<devtools::AshDevToolsCSSAgent>(dom_backend.get()); 839 base::MakeUnique<devtools::AshDevToolsCSSAgent>(dom_backend.get());
832 auto devtools_client = base::MakeUnique<ui::devtools::UiDevToolsClient>( 840 auto devtools_client = base::MakeUnique<ui::devtools::UiDevToolsClient>(
833 "Ash", devtools_server_.get()); 841 "Ash", devtools_server_.get());
834 devtools_client->AddAgent(std::move(dom_backend)); 842 devtools_client->AddAgent(std::move(dom_backend));
835 devtools_client->AddAgent(std::move(css_backend)); 843 devtools_client->AddAgent(std::move(css_backend));
836 devtools_server_->AttachClient(std::move(devtools_client)); 844 devtools_server_->AttachClient(std::move(devtools_client));
837 } 845 }
838 846
839 if (config == Config::MASH)
840 app_list_delegate_impl_ = base::MakeUnique<AppListDelegateImpl>();
841
842 // TODO(sky): move creation to ShellPort. 847 // TODO(sky): move creation to ShellPort.
843 if (config != Config::MASH) 848 if (config != Config::MASH)
844 immersive_handler_factory_ = base::MakeUnique<ImmersiveHandlerFactoryAsh>(); 849 immersive_handler_factory_ = base::MakeUnique<ImmersiveHandlerFactoryAsh>();
845 850
846 window_positioner_ = base::MakeUnique<WindowPositioner>(); 851 window_positioner_ = base::MakeUnique<WindowPositioner>();
847 852
848 if (config == Config::CLASSIC) { 853 if (config == Config::CLASSIC) {
849 // TODO: needs to work in mus. http://crbug.com/705592. 854 // TODO: needs to work in mus. http://crbug.com/705592.
850 native_cursor_manager_ = new AshNativeCursorManager; 855 native_cursor_manager_ = new AshNativeCursorManager;
851 cursor_manager_.reset( 856 cursor_manager_.reset(
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
1211 } 1216 }
1212 1217
1213 void Shell::OnWindowActivated( 1218 void Shell::OnWindowActivated(
1214 ::wm::ActivationChangeObserver::ActivationReason reason, 1219 ::wm::ActivationChangeObserver::ActivationReason reason,
1215 aura::Window* gained_active, 1220 aura::Window* gained_active,
1216 aura::Window* lost_active) { 1221 aura::Window* lost_active) {
1217 if (gained_active) 1222 if (gained_active)
1218 root_window_for_new_windows_ = gained_active->GetRootWindow(); 1223 root_window_for_new_windows_ = gained_active->GetRootWindow();
1219 } 1224 }
1220 1225
1226 void Shell::OnAppListVisibilityChanged(bool visible, int64_t display_id) {
1227 NotifyAppListVisibilityChanged(
1228 visible, ShellPort::Get()->GetRootWindowForDisplayId(display_id));
1229 }
1230
1221 void Shell::OnSessionStateChanged(session_manager::SessionState state) { 1231 void Shell::OnSessionStateChanged(session_manager::SessionState state) {
1222 // Initialize the shelf when a session becomes active. It's safe to do this 1232 // Initialize the shelf when a session becomes active. It's safe to do this
1223 // multiple times (e.g. initial login vs. multiprofile add session). 1233 // multiple times (e.g. initial login vs. multiprofile add session).
1224 if (state == session_manager::SessionState::ACTIVE) { 1234 if (state == session_manager::SessionState::ACTIVE) {
1225 InitializeShelf(); 1235 InitializeShelf();
1226 if (GetAshConfig() != Config::MASH) { 1236 if (GetAshConfig() != Config::MASH) {
1227 // Recreate the keyboard after initial login and after multiprofile login. 1237 // Recreate the keyboard after initial login and after multiprofile login.
1228 CreateKeyboard(); 1238 CreateKeyboard();
1229 } 1239 }
1230 } 1240 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1265 void Shell::OnPrefServiceInitialized( 1275 void Shell::OnPrefServiceInitialized(
1266 std::unique_ptr<::PrefService> pref_service) { 1276 std::unique_ptr<::PrefService> pref_service) {
1267 if (!instance_) 1277 if (!instance_)
1268 return; 1278 return;
1269 // |pref_service_| is null if can't connect to Chrome (as happens when 1279 // |pref_service_| is null if can't connect to Chrome (as happens when
1270 // running mash outside of chrome --mash and chrome isn't built). 1280 // running mash outside of chrome --mash and chrome isn't built).
1271 pref_service_ = std::move(pref_service); 1281 pref_service_ = std::move(pref_service);
1272 } 1282 }
1273 1283
1274 } // namespace ash 1284 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698