Skip to content

Commit

Permalink
Move SessionObserver to ash/public
Browse files Browse the repository at this point in the history
so that CL like this (crrev.com/c/2214761) can use it.

Bug: None
Change-Id: I685819c89b87603a542324431ba0a6d9a80eb1e5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2283504
Commit-Queue: Mitsuru Oshima <oshima@chromium.org>
Reviewed-by: Toni Baržić <tbarzic@chromium.org>
Cr-Commit-Position: refs/heads/master@{#785832}
  • Loading branch information
mitoshima authored and Commit Bot committed Jul 7, 2020
1 parent b8c6a7b commit e3e29b3
Show file tree
Hide file tree
Showing 76 changed files with 96 additions and 85 deletions.
2 changes: 0 additions & 2 deletions ash/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -647,8 +647,6 @@ component("ash") {
"session/session_activation_observer_holder.h",
"session/session_controller_impl.cc",
"session/session_controller_impl.h",
"session/session_observer.cc",
"session/session_observer.h",
"session/teleport_warning_dialog.cc",
"session/teleport_warning_dialog.h",
"shelf/assistant_overlay.cc",
Expand Down
2 changes: 1 addition & 1 deletion ash/accessibility/accessibility_controller_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
#include "ash/public/cpp/ash_constants.h"
#include "ash/public/cpp/ash_pref_names.h"
#include "ash/public/cpp/notification_utils.h"
#include "ash/public/cpp/session/session_observer.h"
#include "ash/public/cpp/shell_window_ids.h"
#include "ash/resources/vector_icons/vector_icons.h"
#include "ash/session/session_controller_impl.h"
#include "ash/session/session_observer.h"
#include "ash/shell.h"
#include "ash/sticky_keys/sticky_keys_controller.h"
#include "ash/strings/grit/ash_strings.h"
Expand Down
2 changes: 1 addition & 1 deletion ash/accessibility/accessibility_controller_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
#include "ash/ash_export.h"
#include "ash/public/cpp/accessibility_controller.h"
#include "ash/public/cpp/ash_constants.h"
#include "ash/public/cpp/session/session_observer.h"
#include "ash/public/cpp/tablet_mode_observer.h"
#include "ash/session/session_observer.h"
#include "base/callback_forward.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
Expand Down
2 changes: 1 addition & 1 deletion ash/ambient/ambient_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include "ash/ambient/ui/ambient_view_delegate.h"
#include "ash/ash_export.h"
#include "ash/public/cpp/ambient/ambient_ui_model.h"
#include "ash/session/session_observer.h"
#include "ash/public/cpp/session/session_observer.h"
#include "ash/system/power/power_status.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
Expand Down
2 changes: 1 addition & 1 deletion ash/app_list/app_list_controller_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
#include "ash/public/cpp/app_list/app_list_controller.h"
#include "ash/public/cpp/assistant/controller/assistant_controller_observer.h"
#include "ash/public/cpp/keyboard/keyboard_controller_observer.h"
#include "ash/public/cpp/session/session_observer.h"
#include "ash/public/cpp/shelf_types.h"
#include "ash/public/cpp/tablet_mode_observer.h"
#include "ash/public/cpp/wallpaper_controller_observer.h"
#include "ash/session/session_observer.h"
#include "ash/shelf/shelf_layout_manager.h"
#include "ash/shell_observer.h"
#include "ash/wm/mru_window_tracker.h"
Expand Down
2 changes: 1 addition & 1 deletion ash/assistant/assistant_state_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#include "ash/ash_export.h"
#include "ash/public/cpp/assistant/assistant_state.h"
#include "ash/session/session_observer.h"
#include "ash/public/cpp/session/session_observer.h"
#include "base/macros.h"

namespace ash {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "ash/ash_export.h"
#include "ash/detachable_base/detachable_base_handler.h"
#include "ash/detachable_base/detachable_base_observer.h"
#include "ash/session/session_observer.h"
#include "ash/public/cpp/session/session_observer.h"
#include "base/scoped_observer.h"

namespace ash {
Expand Down
2 changes: 1 addition & 1 deletion ash/display/display_alignment_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#include "ash/ash_export.h"
#include "ash/display/window_tree_host_manager.h"
#include "ash/session/session_observer.h"
#include "ash/public/cpp/session/session_observer.h"
#include "base/containers/flat_map.h"
#include "ui/events/event_handler.h"

Expand Down
2 changes: 1 addition & 1 deletion ash/display/display_highlight_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#include "ash/ash_export.h"
#include "ash/display/window_tree_host_manager.h"
#include "ash/session/session_observer.h"
#include "ash/public/cpp/session/session_observer.h"
#include "ui/views/widget/widget.h"

namespace ash {
Expand Down
2 changes: 1 addition & 1 deletion ash/display/display_prefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <array>

#include "ash/ash_export.h"
#include "ash/session/session_observer.h"
#include "ash/public/cpp/session/session_observer.h"
#include "base/optional.h"
#include "third_party/cros_system_api/dbus/service_constants.h"
#include "ui/display/display.h"
Expand Down
2 changes: 1 addition & 1 deletion ash/display/display_shutdown_observer.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#ifndef ASH_DISPLAY_DISPLAY_SHUTDOWN_OBSERVER_H_
#define ASH_DISPLAY_DISPLAY_SHUTDOWN_OBSERVER_H_

#include "ash/session/session_observer.h"
#include "ash/public/cpp/session/session_observer.h"
#include "base/macros.h"

namespace display {
Expand Down
2 changes: 1 addition & 1 deletion ash/display/privacy_screen_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <memory>

#include "ash/ash_export.h"
#include "ash/session/session_observer.h"
#include "ash/public/cpp/session/session_observer.h"
#include "base/observer_list.h"
#include "ui/display/manager/display_configurator.h"

Expand Down
2 changes: 1 addition & 1 deletion ash/first_run/first_run_helper_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#include "ash/ash_export.h"
#include "ash/public/cpp/first_run_helper.h"
#include "ash/session/session_observer.h"
#include "ash/public/cpp/session/session_observer.h"
#include "base/callback.h"
#include "base/macros.h"

Expand Down
2 changes: 1 addition & 1 deletion ash/keyboard/keyboard_controller_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include "ash/keyboard/ui/keyboard_ui_controller.h"
#include "ash/public/cpp/keyboard/keyboard_controller.h"
#include "ash/public/cpp/keyboard/keyboard_controller_observer.h"
#include "ash/session/session_observer.h"
#include "ash/public/cpp/session/session_observer.h"
#include "base/macros.h"
#include "base/optional.h"
#include "base/time/time.h"
Expand Down
2 changes: 1 addition & 1 deletion ash/keyboard/virtual_keyboard_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
#include "ash/ash_export.h"
#include "ash/bluetooth_devices_observer.h"
#include "ash/public/cpp/keyboard/keyboard_controller_observer.h"
#include "ash/public/cpp/session/session_observer.h"
#include "ash/public/cpp/tablet_mode_observer.h"
#include "ash/session/session_observer.h"
#include "base/macros.h"
#include "ui/base/ime/chromeos/ime_keyset.h"
#include "ui/events/devices/input_device_event_observer.h"
Expand Down
2 changes: 1 addition & 1 deletion ash/login/ui/lock_screen.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#include "ash/ash_export.h"
#include "ash/public/cpp/login_types.h"
#include "ash/session/session_observer.h"
#include "ash/public/cpp/session/session_observer.h"
#include "ash/tray_action/tray_action.h"
#include "ash/tray_action/tray_action_observer.h"
#include "base/macros.h"
Expand Down
2 changes: 1 addition & 1 deletion ash/magnifier/docked_magnifier_controller_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include "ash/ash_export.h"
#include "ash/display/window_tree_host_manager.h"
#include "ash/public/cpp/docked_magnifier_controller.h"
#include "ash/session/session_observer.h"
#include "ash/public/cpp/session/session_observer.h"
#include "ui/base/ime/ime_bridge_observer.h"
#include "ui/base/ime/input_method_observer.h"
#include "ui/events/event_handler.h"
Expand Down
2 changes: 1 addition & 1 deletion ash/media/media_notification_controller_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
#include "ash/media/media_notification_constants.h"
#include "ash/media/media_notification_container_impl.h"
#include "ash/public/cpp/notification_utils.h"
#include "ash/public/cpp/session/session_observer.h"
#include "ash/session/session_controller_impl.h"
#include "ash/session/session_observer.h"
#include "ash/shell.h"
#include "ash/shell_delegate.h"
#include "base/bind.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <string>

#include "ash/ash_export.h"
#include "ash/session/session_observer.h"
#include "ash/public/cpp/session/session_observer.h"
#include "base/callback.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
Expand Down
2 changes: 1 addition & 1 deletion ash/multi_user/multi_user_window_manager_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

#include "ash/ash_export.h"
#include "ash/public/cpp/multi_user_window_manager.h"
#include "ash/public/cpp/session/session_observer.h"
#include "ash/public/cpp/tablet_mode_observer.h"
#include "ash/session/session_observer.h"
#include "base/containers/flat_map.h"
#include "base/macros.h"
#include "base/observer_list.h"
Expand Down
2 changes: 1 addition & 1 deletion ash/policy/policy_recommendation_restorer.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <set>
#include <string>

#include "ash/session/session_observer.h"
#include "ash/public/cpp/session/session_observer.h"
#include "base/macros.h"
#include "base/timer/timer.h"
#include "ui/base/user_activity/user_activity_observer.h"
Expand Down
2 changes: 2 additions & 0 deletions ash/public/cpp/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,8 @@ component("cpp") {
"session/session_controller.cc",
"session/session_controller.h",
"session/session_controller_client.h",
"session/session_observer.cc",
"session/session_observer.h",
"session/session_types.cc",
"session/session_types.h",
"session/user_info.cc",
Expand Down
5 changes: 5 additions & 0 deletions ash/public/cpp/session/session_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class AccountId;

namespace ash {

class SessionObserver;
class SessionControllerClient;
class SessionActivationObserver;

Expand Down Expand Up @@ -115,6 +116,10 @@ class ASH_PUBLIC_EXPORT SessionController {
const AccountId& account_id,
SessionActivationObserver* observer) = 0;

// Adds/remove session observer.
virtual void AddObserver(SessionObserver* observer) = 0;
virtual void RemoveObserver(SessionObserver* observer) = 0;

protected:
SessionController();
virtual ~SessionController();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,21 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "ash/session/session_observer.h"
#include "ash/public/cpp/session/session_observer.h"

#include "ash/session/session_controller_impl.h"
#include "ash/shell.h"
#include "ash/public/cpp/session/session_controller.h"

namespace ash {

ScopedSessionObserver::ScopedSessionObserver(SessionObserver* observer)
: observer_(observer) {
DCHECK(Shell::HasInstance());
Shell::Get()->session_controller()->AddObserver(observer_);
DCHECK(SessionController::Get());
SessionController::Get()->AddObserver(observer_);
}

ScopedSessionObserver::~ScopedSessionObserver() {
DCHECK(Shell::HasInstance());
Shell::Get()->session_controller()->RemoveObserver(observer_);
DCHECK(SessionController::Get());
SessionController::Get()->RemoveObserver(observer_);
}

} // namespace ash
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef ASH_SESSION_SESSION_OBSERVER_H_
#define ASH_SESSION_SESSION_OBSERVER_H_
#ifndef ASH_PUBLIC_CPP_SESSION_SESSION_OBSERVER_H_
#define ASH_PUBLIC_CPP_SESSION_SESSION_OBSERVER_H_

#include "ash/ash_export.h"
#include "ash/public/cpp/ash_public_export.h"
#include "base/macros.h"
#include "base/observer_list_types.h"
#include "components/session_manager/session_manager_types.h"
Expand All @@ -17,7 +17,7 @@ namespace ash {

enum class LoginStatus;

class ASH_EXPORT SessionObserver : public base::CheckedObserver {
class ASH_PUBLIC_EXPORT SessionObserver : public base::CheckedObserver {
public:
// Called when the active user session has changed.
virtual void OnActiveUserSessionChanged(const AccountId& account_id) {}
Expand Down Expand Up @@ -64,7 +64,7 @@ class ASH_EXPORT SessionObserver : public base::CheckedObserver {
//
// NOTE: Both ash::Shell and ash::SessionControllerImpl must outlive your
// object. You may find it clearer to manually add and remove your observer.
class ASH_EXPORT ScopedSessionObserver {
class ASH_PUBLIC_EXPORT ScopedSessionObserver {
public:
explicit ScopedSessionObserver(SessionObserver* observer);
virtual ~ScopedSessionObserver();
Expand All @@ -77,4 +77,4 @@ class ASH_EXPORT ScopedSessionObserver {

} // namespace ash

#endif // ASH_SESSION_SESSION_OBSERVER_H_
#endif // ASH_PUBLIC_CPP_SESSION_SESSION_OBSERVER_H_
2 changes: 1 addition & 1 deletion ash/session/session_controller_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
#include "ash/metrics/user_metrics_recorder.h"
#include "ash/public/cpp/session/session_activation_observer.h"
#include "ash/public/cpp/session/session_controller_client.h"
#include "ash/public/cpp/session/session_observer.h"
#include "ash/public/cpp/session/user_info.h"
#include "ash/session/fullscreen_controller.h"
#include "ash/session/multiprofiles_intro_dialog.h"
#include "ash/session/session_aborted_dialog.h"
#include "ash/session/session_observer.h"
#include "ash/session/teleport_warning_dialog.h"
#include "ash/shell.h"
#include "ash/system/power/power_event_observer.h"
Expand Down
5 changes: 2 additions & 3 deletions ash/session/session_controller_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,6 @@ class ASH_EXPORT SessionControllerImpl : public SessionController {
// the active user profile prefs. Returns null early during startup.
PrefService* GetActivePrefService() const;

void AddObserver(SessionObserver* observer);
void RemoveObserver(SessionObserver* observer);

// Returns the ash notion of login status.
// NOTE: Prefer GetSessionState() in new code because the concept of
// SessionState more closes matches the state in chrome.
Expand Down Expand Up @@ -208,6 +205,8 @@ class ASH_EXPORT SessionControllerImpl : public SessionController {
void RemoveSessionActivationObserverForAccountId(
const AccountId& account_id,
SessionActivationObserver* observer) override;
void AddObserver(SessionObserver* observer) override;
void RemoveObserver(SessionObserver* observer) override;

// Test helpers.
void ClearUserSessionsForTest();
Expand Down
2 changes: 1 addition & 1 deletion ash/session/session_controller_impl_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

#include "ash/login_status.h"
#include "ash/public/cpp/ash_prefs.h"
#include "ash/session/session_observer.h"
#include "ash/public/cpp/session/session_observer.h"
#include "ash/session/test_session_controller_client.h"
#include "ash/shell.h"
#include "ash/system/tray/system_tray_notifier.h"
Expand Down
2 changes: 1 addition & 1 deletion ash/shelf/shelf_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

#include "ash/ash_export.h"
#include "ash/display/window_tree_host_manager.h"
#include "ash/public/cpp/session/session_observer.h"
#include "ash/public/cpp/shelf_model.h"
#include "ash/public/cpp/tablet_mode_observer.h"
#include "ash/session/session_observer.h"
#include "base/scoped_observer.h"
#include "ui/message_center/message_center.h"
#include "ui/message_center/message_center_observer.h"
Expand Down
2 changes: 1 addition & 1 deletion ash/shelf/shelf_layout_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
#include "ash/ash_export.h"
#include "ash/home_screen/drag_window_from_shelf_controller.h"
#include "ash/public/cpp/app_list/app_list_controller_observer.h"
#include "ash/public/cpp/session/session_observer.h"
#include "ash/public/cpp/shelf_config.h"
#include "ash/public/cpp/shelf_types.h"
#include "ash/public/cpp/tablet_mode_observer.h"
#include "ash/public/cpp/wallpaper_controller.h"
#include "ash/public/cpp/wallpaper_controller_observer.h"
#include "ash/session/session_observer.h"
#include "ash/shelf/shelf.h"
#include "ash/shelf/shelf_metrics.h"
#include "ash/shelf/shelf_widget.h"
Expand Down
2 changes: 1 addition & 1 deletion ash/shelf/shelf_locking_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
#define ASH_SHELF_SHELF_LOCKING_MANAGER_H_

#include "ash/ash_export.h"
#include "ash/public/cpp/session/session_observer.h"
#include "ash/public/cpp/shelf_types.h"
#include "ash/session/session_observer.h"
#include "ash/wm/lock_state_observer.h"

namespace ash {
Expand Down
2 changes: 1 addition & 1 deletion ash/shelf/shelf_widget.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

#include "ash/accessibility/accessibility_observer.h"
#include "ash/ash_export.h"
#include "ash/public/cpp/session/session_observer.h"
#include "ash/public/cpp/shelf_types.h"
#include "ash/session/session_observer.h"
#include "ash/shelf/contextual_tooltip.h"
#include "ash/shelf/hotseat_transition_animator.h"
#include "ash/shelf/hotseat_widget.h"
Expand Down
2 changes: 1 addition & 1 deletion ash/shell.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

#include "ash/ash_export.h"
#include "ash/metrics/user_metrics_recorder.h"
#include "ash/public/cpp/session/session_observer.h"
#include "ash/public/cpp/shelf_types.h"
#include "ash/session/session_observer.h"
#include "ash/wm/system_modal_container_event_filter_delegate.h"
#include "base/gtest_prod_util.h"
#include "base/macros.h"
Expand Down
2 changes: 1 addition & 1 deletion ash/system/accessibility/dictation_button_tray.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "ash/accelerators/accelerator_controller_impl.h"
#include "ash/accessibility/accessibility_observer.h"
#include "ash/ash_export.h"
#include "ash/session/session_observer.h"
#include "ash/public/cpp/session/session_observer.h"
#include "ash/shell_observer.h"
#include "ash/system/tray/tray_background_view.h"
#include "base/macros.h"
Expand Down

0 comments on commit e3e29b3

Please sign in to comment.