Commit 269b579a authored by Tetsui Ohkubo's avatar Tetsui Ohkubo Committed by Commit Bot

Add owner class of notification controllers.

This CL adds SystemNotificationController that owns notification
controllers that are recently splitted from SystemTrayItems.
This CL also fixes initialization and destruction ordering of
SystemTrayModel and SystemNoticationController.

Other notification controllers might be added to
SystemNotificationController later.

TEST=ash_unittests
BUG=none

Change-Id: I13ac5e4f77ca7afbfe6f53753d207f29861448bf
Reviewed-on: https://chromium-review.googlesource.com/1025433Reviewed-by: default avatarJames Cook <jamescook@chromium.org>
Reviewed-by: default avatarSteven Bennetts <stevenjb@chromium.org>
Reviewed-by: default avatarYoshiki Iguchi <yoshiki@chromium.org>
Commit-Queue: Tetsui Ohkubo <tetsui@chromium.org>
Cr-Commit-Position: refs/heads/master@{#553861}
parent 9c83c84e
......@@ -736,6 +736,8 @@ component("ash") {
"system/supervised/supervised_notification_controller.h",
"system/supervised/tray_supervised_user.cc",
"system/supervised/tray_supervised_user.h",
"system/system_notification_controller.cc",
"system/system_notification_controller.h",
"system/system_tray_focus_observer.h",
"system/tiles/tiles_default_view.cc",
"system/tiles/tiles_default_view.h",
......
......@@ -100,20 +100,17 @@
#include "ash/system/power/peripheral_battery_notifier.h"
#include "ash/system/power/power_button_controller.h"
#include "ash/system/power/power_event_observer.h"
#include "ash/system/power/power_notification_controller.h"
#include "ash/system/power/power_prefs.h"
#include "ash/system/power/power_status.h"
#include "ash/system/power/video_activity_notifier.h"
#include "ash/system/screen_layout_observer.h"
#include "ash/system/screen_security/screen_security_notification_controller.h"
#include "ash/system/session/logout_button_tray.h"
#include "ash/system/session/logout_confirmation_controller.h"
#include "ash/system/status_area_widget.h"
#include "ash/system/supervised/supervised_notification_controller.h"
#include "ash/system/system_notification_controller.h"
#include "ash/system/toast/toast_manager.h"
#include "ash/system/tray/system_tray_controller.h"
#include "ash/system/tray/system_tray_notifier.h"
#include "ash/system/tray_caps_lock.h"
#include "ash/touch/ash_touch_transform_controller.h"
#include "ash/touch/touch_devices_controller.h"
#include "ash/tray_action/tray_action.h"
......@@ -198,7 +195,6 @@
#include "ui/keyboard/keyboard_switches.h"
#include "ui/keyboard/keyboard_ui.h"
#include "ui/keyboard/keyboard_util.h"
#include "ui/message_center/message_center.h"
#include "ui/views/corewm/tooltip_aura.h"
#include "ui/views/corewm/tooltip_controller.h"
#include "ui/views/focus/focus_manager_factory.h"
......@@ -804,6 +800,10 @@ Shell::~Shell() {
// Close all widgets (including the shelf) and destroy all window containers.
CloseAllRootWindowChildWindows();
system_notification_controller_.reset();
// Should be destroyed after Shelf and |system_notification_controller_|.
system_tray_model_.reset();
// MruWindowTracker must be destroyed after all windows have been deleted to
// avoid a possible crash when Shell is destroyed from a non-normal shutdown
// path. (crbug.com/485438).
......@@ -828,12 +828,8 @@ Shell::~Shell() {
screen_pinning_controller_.reset();
caps_lock_notification_controller_.reset();
power_notification_controller_.reset();
resolution_notification_controller_.reset();
screen_security_notification_controller_.reset();
screenshot_controller_.reset();
supervised_notification_controller_.reset();
mouse_cursor_filter_.reset();
modality_filter_.reset();
......@@ -917,8 +913,6 @@ Shell::~Shell() {
// Destroys the MessageCenter singleton, so must happen late.
message_center_controller_.reset();
system_tray_model_.reset();
local_state_.reset();
shell_delegate_.reset();
......@@ -943,19 +937,10 @@ void Shell::Init(ui::ContextFactory* context_factory,
night_light_controller_ = std::make_unique<NightLightController>();
touch_devices_controller_ = std::make_unique<TouchDevicesController>();
bluetooth_power_controller_ = std::make_unique<BluetoothPowerController>();
caps_lock_notification_controller_ =
std::make_unique<CapsLockNotificationController>();
detachable_base_handler_ = std::make_unique<DetachableBaseHandler>(this);
detachable_base_notification_controller_ =
std::make_unique<DetachableBaseNotificationController>(
detachable_base_handler_.get());
power_notification_controller_ =
std::make_unique<PowerNotificationController>(
message_center::MessageCenter::Get());
screen_security_notification_controller_ =
std::make_unique<ScreenSecurityNotificationController>();
supervised_notification_controller_ =
std::make_unique<SupervisedNotificationController>();
// Connector can be null in tests.
if (shell_delegate_->GetShellConnector()) {
......@@ -1052,8 +1037,6 @@ void Shell::Init(ui::ContextFactory* context_factory,
display::Screen::GetScreen()->GetPrimaryDisplay());
}
system_tray_model_ = std::make_unique<SystemTrayModel>();
accelerator_controller_ = shell_port_->CreateAcceleratorController();
tablet_mode_controller_ = std::make_unique<TabletModeController>();
......@@ -1202,6 +1185,13 @@ void Shell::Init(ui::ContextFactory* context_factory,
keyboard_ui_ = shell_port_->CreateKeyboardUI();
// |system_tray_model_| should be available before
// |system_notification_controller_| is initialized and Shelf is created by
// WindowTreeHostManager::InitHosts.
system_tray_model_ = std::make_unique<SystemTrayModel>();
system_notification_controller_ =
std::make_unique<SystemNotificationController>();
window_tree_host_manager_->InitHosts();
shell_port_->OnHostsInitialized();
......
......@@ -94,7 +94,6 @@ class BacklightsForcedOffSetter;
class BluetoothNotificationController;
class BluetoothPowerController;
class BrightnessControlDelegate;
class CapsLockNotificationController;
class CastConfigController;
class DetachableBaseHandler;
class DetachableBaseNotificationController;
......@@ -138,7 +137,6 @@ class PeripheralBatteryNotifier;
class PersistentWindowController;
class PowerButtonController;
class PowerEventObserver;
class PowerNotificationController;
class PowerPrefs;
class ProjectingObserver;
class ResizeShadowController;
......@@ -150,7 +148,6 @@ class ScreenOrientationController;
class ScreenshotController;
class ScreenPinningController;
class ScreenPositionController;
class ScreenSecurityNotificationController;
class SessionController;
class ShelfController;
class ShelfModel;
......@@ -162,9 +159,9 @@ class ShutdownController;
class SmsObserver;
class SplitViewController;
class StickyKeysController;
class SupervisedNotificationController;
class SystemGestureEventFilter;
class SystemModalContainerEventFilter;
class SystemNotificationController;
class SystemTray;
class SystemTrayController;
class SystemTrayModel;
......@@ -699,8 +696,6 @@ class ASH_EXPORT Shell : public SessionObserver,
std::unique_ptr<AshDisplayController> ash_display_controller_;
std::unique_ptr<BacklightsForcedOffSetter> backlights_forced_off_setter_;
std::unique_ptr<BrightnessControlDelegate> brightness_control_delegate_;
std::unique_ptr<CapsLockNotificationController>
caps_lock_notification_controller_;
std::unique_ptr<CastConfigController> cast_config_;
std::unique_ptr<DetachableBaseHandler> detachable_base_handler_;
std::unique_ptr<DetachableBaseNotificationController>
......@@ -724,15 +719,11 @@ class ASH_EXPORT Shell : public SessionObserver,
std::unique_ptr<SessionController> session_controller_;
std::unique_ptr<NightLightController> night_light_controller_;
std::unique_ptr<NoteTakingController> note_taking_controller_;
std::unique_ptr<PowerNotificationController> power_notification_controller_;
std::unique_ptr<ScreenSecurityNotificationController>
screen_security_notification_controller_;
std::unique_ptr<SupervisedNotificationController>
supervised_notification_controller_;
std::unique_ptr<ShelfController> shelf_controller_;
std::unique_ptr<ShelfWindowWatcher> shelf_window_watcher_;
std::unique_ptr<ShellDelegate> shell_delegate_;
std::unique_ptr<ShutdownController> shutdown_controller_;
std::unique_ptr<SystemNotificationController> system_notification_controller_;
std::unique_ptr<SystemTrayController> system_tray_controller_;
std::unique_ptr<SystemTrayModel> system_tray_model_;
std::unique_ptr<SystemTrayNotifier> system_tray_notifier_;
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/system/system_notification_controller.h"
#include "ash/system/caps_lock_notification_controller.h"
#include "ash/system/power/power_notification_controller.h"
#include "ash/system/screen_security/screen_security_notification_controller.h"
#include "ash/system/supervised/supervised_notification_controller.h"
#include "ui/message_center/message_center.h"
namespace ash {
SystemNotificationController::SystemNotificationController()
: caps_lock_(std::make_unique<CapsLockNotificationController>()),
power_(std::make_unique<PowerNotificationController>(
message_center::MessageCenter::Get())),
screen_security_(
std::make_unique<ScreenSecurityNotificationController>()),
supervised_(std::make_unique<SupervisedNotificationController>()) {}
SystemNotificationController::~SystemNotificationController() = default;
} // namespace ash
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ASH_SYSTEM_SYSTEM_NOTIFICATION_CONTROLLER_H_
#define ASH_SYSTEM_SYSTEM_NOTIFICATION_CONTROLLER_H_
#include <memory>
#include "base/macros.h"
namespace ash {
class CapsLockNotificationController;
class PowerNotificationController;
class ScreenSecurityNotificationController;
class SupervisedNotificationController;
// Class that owns individual notification controllers.
class SystemNotificationController {
public:
SystemNotificationController();
~SystemNotificationController();
private:
const std::unique_ptr<CapsLockNotificationController> caps_lock_;
const std::unique_ptr<PowerNotificationController> power_;
const std::unique_ptr<ScreenSecurityNotificationController> screen_security_;
const std::unique_ptr<SupervisedNotificationController> supervised_;
DISALLOW_COPY_AND_ASSIGN(SystemNotificationController);
};
} // namespace ash
#endif // ASH_SYSTEM_SYSTEM_NOTIFICATION_CONTROLLER_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment