Skip to content

Commit

Permalink
mash: Migrate locale observer and notification to common.
Browse files Browse the repository at this point in the history
tools/git/move_source_file.py ash/system/locale/* ash/common/system/locale
Move LocaleObserver and Notify functions to WmSystemTrayNotifier.
Add locale_observer.h to the build config. Fix some IWYU issues.

BUG=619636
TEST=compiles, no regressions (had to hack for manual testing...)
R=jamescook@chromium.org,stevenjb@chromium.org

Review-Url: https://codereview.chromium.org/2082193002
Cr-Commit-Position: refs/heads/master@{#401191}
  • Loading branch information
msw authored and Commit bot committed Jun 22, 2016
1 parent 465606b commit 6784963
Show file tree
Hide file tree
Showing 11 changed files with 53 additions and 53 deletions.
5 changes: 3 additions & 2 deletions ash/ash.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@
'common/system/ime/ime_observer.h',
'common/system/ime/tray_ime_chromeos.cc',
'common/system/ime/tray_ime_chromeos.h',
'common/system/locale/locale_notification_controller.cc',
'common/system/locale/locale_notification_controller.h',
'common/system/locale/locale_observer.h',
'common/system/networking_config_delegate.cc',
'common/system/networking_config_delegate.h',
'common/system/system_notifier.cc',
Expand Down Expand Up @@ -574,8 +577,6 @@
'system/chromeos/virtual_keyboard/virtual_keyboard_tray.cc',
'system/chromeos/virtual_keyboard/virtual_keyboard_tray.h',
'system/keyboard_brightness/keyboard_brightness_control_delegate.h',
'system/locale/locale_notification_controller.cc',
'system/locale/locale_notification_controller.h',
'system/overview/overview_button_tray.cc',
'system/overview/overview_button_tray.h',
'system/status_area_widget.cc',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "ash/system/locale/locale_notification_controller.h"
#include "ash/common/system/locale/locale_notification_controller.h"

#include <utility>

#include "ash/common/system/system_notifier.h"
#include "ash/shell.h"
#include "ash/system/tray/system_tray_notifier.h"
#include "ash/common/system/tray/wm_system_tray_notifier.h"
#include "ash/common/wm_shell.h"
#include "base/strings/string16.h"
#include "grit/ash_resources.h"
#include "grit/ash_strings.h"
Expand Down Expand Up @@ -47,12 +47,11 @@ class LocaleNotificationDelegate : public message_center::NotificationDelegate {

LocaleNotificationDelegate::LocaleNotificationDelegate(
LocaleObserver::Delegate* delegate)
: delegate_(delegate) {
: delegate_(delegate) {
DCHECK(delegate_);
}

LocaleNotificationDelegate::~LocaleNotificationDelegate() {
}
LocaleNotificationDelegate::~LocaleNotificationDelegate() {}

void LocaleNotificationDelegate::Close(bool by_user) {
delegate_->AcceptLocaleChange();
Expand All @@ -74,11 +73,11 @@ void LocaleNotificationDelegate::ButtonClick(int button_index) {
} // namespace

LocaleNotificationController::LocaleNotificationController() {
Shell::GetInstance()->system_tray_notifier()->AddLocaleObserver(this);
WmShell::Get()->system_tray_notifier()->AddLocaleObserver(this);
}

LocaleNotificationController::~LocaleNotificationController() {
Shell::GetInstance()->system_tray_notifier()->RemoveLocaleObserver(this);
WmShell::Get()->system_tray_notifier()->RemoveLocaleObserver(this);
}

void LocaleNotificationController::OnLocaleChanged(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef ASH_SYSTEM_LOCALE_LOCALE_NOTIFICATION_CONTROLLER_H_
#define ASH_SYSTEM_LOCALE_LOCALE_NOTIFICATION_CONTROLLER_H_
#ifndef ASH_COMMON_SYSTEM_LOCALE_LOCALE_NOTIFICATION_CONTROLLER_H_
#define ASH_COMMON_SYSTEM_LOCALE_LOCALE_NOTIFICATION_CONTROLLER_H_

#include <string>

#include "ash/system/locale/locale_observer.h"
#include "base/compiler_specific.h"
#include "ash/common/system/locale/locale_observer.h"
#include "base/macros.h"

namespace ash {
Expand All @@ -35,4 +34,4 @@ class LocaleNotificationController : public LocaleObserver {

} // namespace ash

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

#ifndef ASH_SYSTEM_LOCALE_LOCALE_OBSERVER_H_
#define ASH_SYSTEM_LOCALE_LOCALE_OBSERVER_H_
#ifndef ASH_COMMON_SYSTEM_LOCALE_LOCALE_OBSERVER_H_
#define ASH_COMMON_SYSTEM_LOCALE_LOCALE_OBSERVER_H_

#include <string>

#include "ash/ash_export.h"

Expand All @@ -29,4 +31,4 @@ class ASH_EXPORT LocaleObserver {

} // namespace ash

#endif // ASH_SYSTEM_LOCALE_LOCALE_OBSERVER_H_
#endif // ASH_COMMON_SYSTEM_LOCALE_LOCALE_OBSERVER_H_
18 changes: 18 additions & 0 deletions ash/common/system/tray/wm_system_tray_notifier.cc
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,24 @@ void WmSystemTrayNotifier::NotifyRefreshIMEMenu(bool is_active) {
OnIMEMenuActivationChanged(is_active));
}

void WmSystemTrayNotifier::AddLocaleObserver(LocaleObserver* observer) {
locale_observers_.AddObserver(observer);
}

void WmSystemTrayNotifier::RemoveLocaleObserver(LocaleObserver* observer) {
locale_observers_.RemoveObserver(observer);
}

void WmSystemTrayNotifier::NotifyLocaleChanged(
LocaleObserver::Delegate* delegate,
const std::string& cur_locale,
const std::string& from_locale,
const std::string& to_locale) {
FOR_EACH_OBSERVER(
LocaleObserver, locale_observers_,
OnLocaleChanged(delegate, cur_locale, from_locale, to_locale));
}

void WmSystemTrayNotifier::AddUpdateObserver(UpdateObserver* observer) {
update_observers_.AddObserver(observer);
}
Expand Down
12 changes: 11 additions & 1 deletion ash/common/system/tray/wm_system_tray_notifier.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include "ash/ash_export.h"
#include "ash/common/accessibility_types.h"
#include "ash/common/system/locale/locale_observer.h"
#include "base/macros.h"
#include "base/observer_list.h"

Expand Down Expand Up @@ -52,6 +53,14 @@ class ASH_EXPORT WmSystemTrayNotifier {
void NotifyRefreshIME();
void NotifyRefreshIMEMenu(bool is_active);

// Locale.
void AddLocaleObserver(LocaleObserver* observer);
void RemoveLocaleObserver(LocaleObserver* observer);
void NotifyLocaleChanged(LocaleObserver::Delegate* delegate,
const std::string& cur_locale,
const std::string& from_locale,
const std::string& to_locale);

// OS updates.
void AddUpdateObserver(UpdateObserver* observer);
void RemoveUpdateObserver(UpdateObserver* observer);
Expand All @@ -66,8 +75,9 @@ class ASH_EXPORT WmSystemTrayNotifier {

private:
base::ObserverList<AccessibilityObserver> accessibility_observers_;
base::ObserverList<IMEObserver> ime_observers_;
base::ObserverList<ClockObserver> clock_observers_;
base::ObserverList<IMEObserver> ime_observers_;
base::ObserverList<LocaleObserver> locale_observers_;
base::ObserverList<UpdateObserver> update_observers_;

#if defined(OS_CHROMEOS)
Expand Down
2 changes: 1 addition & 1 deletion ash/shell.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "ash/common/shelf/shelf_item_delegate_manager.h"
#include "ash/common/shelf/shelf_model.h"
#include "ash/common/shell_window_ids.h"
#include "ash/common/system/locale/locale_notification_controller.h"
#include "ash/common/system/tray/system_tray_delegate.h"
#include "ash/common/wm/mru_window_tracker.h"
#include "ash/common/wm/root_window_finder.h"
Expand Down Expand Up @@ -60,7 +61,6 @@
#include "ash/shell_delegate.h"
#include "ash/shell_factory.h"
#include "ash/shell_init_params.h"
#include "ash/system/locale/locale_notification_controller.h"
#include "ash/system/status_area_widget.h"
#include "ash/system/toast/toast_manager.h"
#include "ash/system/tray/system_tray_notifier.h"
Expand Down
19 changes: 0 additions & 19 deletions ash/system/tray/system_tray_notifier.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,6 @@ void SystemTrayNotifier::RemoveAudioObserver(AudioObserver* observer) {
audio_observers_.RemoveObserver(observer);
}

void SystemTrayNotifier::AddLocaleObserver(LocaleObserver* observer) {
locale_observers_.AddObserver(observer);
}

void SystemTrayNotifier::RemoveLocaleObserver(LocaleObserver* observer) {
locale_observers_.RemoveObserver(observer);
}

void SystemTrayNotifier::AddTracingObserver(TracingObserver* observer) {
tracing_observers_.AddObserver(observer);
}
Expand Down Expand Up @@ -184,17 +176,6 @@ void SystemTrayNotifier::NotifyTracingModeChanged(bool value) {
OnTracingModeChanged(value));
}

void SystemTrayNotifier::NotifyLocaleChanged(
LocaleObserver::Delegate* delegate,
const std::string& cur_locale,
const std::string& from_locale,
const std::string& to_locale) {
FOR_EACH_OBSERVER(
LocaleObserver,
locale_observers_,
OnLocaleChanged(delegate, cur_locale, from_locale, to_locale));
}

void SystemTrayNotifier::NotifyUserUpdate() {
FOR_EACH_OBSERVER(UserObserver,
user_observers_,
Expand Down
9 changes: 0 additions & 9 deletions ash/system/tray/system_tray_notifier.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include "ash/ash_export.h"
#include "ash/system/audio/audio_observer.h"
#include "ash/system/chromeos/tray_tracing.h"
#include "ash/system/locale/locale_observer.h"
#include "ash/system/user/user_observer.h"
#include "base/macros.h"
#include "base/observer_list.h"
Expand Down Expand Up @@ -46,9 +45,6 @@ class ASH_EXPORT SystemTrayNotifier {
void AddAudioObserver(AudioObserver* observer);
void RemoveAudioObserver(AudioObserver* observer);

void AddLocaleObserver(LocaleObserver* observer);
void RemoveLocaleObserver(LocaleObserver* observer);

void AddTracingObserver(TracingObserver* observer);
void RemoveTracingObserver(TracingObserver* observer);

Expand Down Expand Up @@ -95,10 +91,6 @@ class ASH_EXPORT SystemTrayNotifier {
void NotifyAudioActiveOutputNodeChanged();
void NotifyAudioActiveInputNodeChanged();
void NotifyTracingModeChanged(bool value);
void NotifyLocaleChanged(LocaleObserver::Delegate* delegate,
const std::string& cur_locale,
const std::string& from_locale,
const std::string& to_locale);
void NotifyUserUpdate();
void NotifyUserAddedToSession();
#if defined(OS_CHROMEOS)
Expand All @@ -123,7 +115,6 @@ class ASH_EXPORT SystemTrayNotifier {

private:
base::ObserverList<AudioObserver> audio_observers_;
base::ObserverList<LocaleObserver> locale_observers_;
base::ObserverList<TracingObserver> tracing_observers_;
base::ObserverList<UserObserver> user_observers_;
#if defined(OS_CHROMEOS)
Expand Down
7 changes: 3 additions & 4 deletions chrome/browser/chromeos/locale_change_guard.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@

#include <algorithm>

#include "ash/shell.h"
#include "ash/system/tray/system_tray.h"
#include "ash/system/tray/system_tray_notifier.h"
#include "ash/common/system/tray/wm_system_tray_notifier.h"
#include "ash/common/wm_shell.h"
#include "base/bind.h"
#include "base/macros.h"
#include "base/strings/utf_string_conversions.h"
Expand Down Expand Up @@ -177,7 +176,7 @@ void LocaleChangeGuard::Check() {
PrepareChangingLocale(from_locale, to_locale);
}

ash::Shell::GetInstance()->system_tray_notifier()->NotifyLocaleChanged(
ash::WmShell::Get()->system_tray_notifier()->NotifyLocaleChanged(
this, cur_locale, from_locale_, to_locale_);
}

Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/chromeos/locale_change_guard.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <memory>
#include <string>

#include "ash/system/locale/locale_observer.h"
#include "ash/common/system/locale/locale_observer.h"
#include "base/compiler_specific.h"
#include "base/gtest_prod_util.h"
#include "base/lazy_instance.h"
Expand Down

0 comments on commit 6784963

Please sign in to comment.