| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/system/locale/locale_notification_controller.h" | 5 #include "ash/common/system/locale/locale_notification_controller.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "ash/common/system/system_notifier.h" | 9 #include "ash/common/system/system_notifier.h" |
| 10 #include "ash/shell.h" | 10 #include "ash/common/system/tray/wm_system_tray_notifier.h" |
| 11 #include "ash/system/tray/system_tray_notifier.h" | 11 #include "ash/common/wm_shell.h" |
| 12 #include "base/strings/string16.h" | 12 #include "base/strings/string16.h" |
| 13 #include "grit/ash_resources.h" | 13 #include "grit/ash_resources.h" |
| 14 #include "grit/ash_strings.h" | 14 #include "grit/ash_strings.h" |
| 15 #include "ui/base/l10n/l10n_util.h" | 15 #include "ui/base/l10n/l10n_util.h" |
| 16 #include "ui/base/resource/resource_bundle.h" | 16 #include "ui/base/resource/resource_bundle.h" |
| 17 #include "ui/message_center/message_center.h" | 17 #include "ui/message_center/message_center.h" |
| 18 #include "ui/message_center/notification.h" | 18 #include "ui/message_center/notification.h" |
| 19 #include "ui/message_center/notification_delegate.h" | 19 #include "ui/message_center/notification_delegate.h" |
| 20 #include "ui/message_center/notification_types.h" | 20 #include "ui/message_center/notification_types.h" |
| 21 | 21 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 40 void ButtonClick(int button_index) override; | 40 void ButtonClick(int button_index) override; |
| 41 | 41 |
| 42 private: | 42 private: |
| 43 LocaleObserver::Delegate* delegate_; | 43 LocaleObserver::Delegate* delegate_; |
| 44 | 44 |
| 45 DISALLOW_COPY_AND_ASSIGN(LocaleNotificationDelegate); | 45 DISALLOW_COPY_AND_ASSIGN(LocaleNotificationDelegate); |
| 46 }; | 46 }; |
| 47 | 47 |
| 48 LocaleNotificationDelegate::LocaleNotificationDelegate( | 48 LocaleNotificationDelegate::LocaleNotificationDelegate( |
| 49 LocaleObserver::Delegate* delegate) | 49 LocaleObserver::Delegate* delegate) |
| 50 : delegate_(delegate) { | 50 : delegate_(delegate) { |
| 51 DCHECK(delegate_); | 51 DCHECK(delegate_); |
| 52 } | 52 } |
| 53 | 53 |
| 54 LocaleNotificationDelegate::~LocaleNotificationDelegate() { | 54 LocaleNotificationDelegate::~LocaleNotificationDelegate() {} |
| 55 } | |
| 56 | 55 |
| 57 void LocaleNotificationDelegate::Close(bool by_user) { | 56 void LocaleNotificationDelegate::Close(bool by_user) { |
| 58 delegate_->AcceptLocaleChange(); | 57 delegate_->AcceptLocaleChange(); |
| 59 } | 58 } |
| 60 | 59 |
| 61 bool LocaleNotificationDelegate::HasClickedListener() { | 60 bool LocaleNotificationDelegate::HasClickedListener() { |
| 62 return true; | 61 return true; |
| 63 } | 62 } |
| 64 | 63 |
| 65 void LocaleNotificationDelegate::Click() { | 64 void LocaleNotificationDelegate::Click() { |
| 66 delegate_->AcceptLocaleChange(); | 65 delegate_->AcceptLocaleChange(); |
| 67 } | 66 } |
| 68 | 67 |
| 69 void LocaleNotificationDelegate::ButtonClick(int button_index) { | 68 void LocaleNotificationDelegate::ButtonClick(int button_index) { |
| 70 DCHECK_EQ(0, button_index); | 69 DCHECK_EQ(0, button_index); |
| 71 delegate_->RevertLocaleChange(); | 70 delegate_->RevertLocaleChange(); |
| 72 } | 71 } |
| 73 | 72 |
| 74 } // namespace | 73 } // namespace |
| 75 | 74 |
| 76 LocaleNotificationController::LocaleNotificationController() { | 75 LocaleNotificationController::LocaleNotificationController() { |
| 77 Shell::GetInstance()->system_tray_notifier()->AddLocaleObserver(this); | 76 WmShell::Get()->system_tray_notifier()->AddLocaleObserver(this); |
| 78 } | 77 } |
| 79 | 78 |
| 80 LocaleNotificationController::~LocaleNotificationController() { | 79 LocaleNotificationController::~LocaleNotificationController() { |
| 81 Shell::GetInstance()->system_tray_notifier()->RemoveLocaleObserver(this); | 80 WmShell::Get()->system_tray_notifier()->RemoveLocaleObserver(this); |
| 82 } | 81 } |
| 83 | 82 |
| 84 void LocaleNotificationController::OnLocaleChanged( | 83 void LocaleNotificationController::OnLocaleChanged( |
| 85 LocaleObserver::Delegate* delegate, | 84 LocaleObserver::Delegate* delegate, |
| 86 const std::string& cur_locale, | 85 const std::string& cur_locale, |
| 87 const std::string& from_locale, | 86 const std::string& from_locale, |
| 88 const std::string& to_locale) { | 87 const std::string& to_locale) { |
| 89 if (!delegate) | 88 if (!delegate) |
| 90 return; | 89 return; |
| 91 | 90 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 109 bundle.GetImageNamed(IDR_AURA_UBER_TRAY_LOCALE), | 108 bundle.GetImageNamed(IDR_AURA_UBER_TRAY_LOCALE), |
| 110 base::string16() /* display_source */, GURL(), | 109 base::string16() /* display_source */, GURL(), |
| 111 message_center::NotifierId(message_center::NotifierId::SYSTEM_COMPONENT, | 110 message_center::NotifierId(message_center::NotifierId::SYSTEM_COMPONENT, |
| 112 system_notifier::kNotifierLocale), | 111 system_notifier::kNotifierLocale), |
| 113 optional, new LocaleNotificationDelegate(delegate))); | 112 optional, new LocaleNotificationDelegate(delegate))); |
| 114 message_center::MessageCenter::Get()->AddNotification( | 113 message_center::MessageCenter::Get()->AddNotification( |
| 115 std::move(notification)); | 114 std::move(notification)); |
| 116 } | 115 } |
| 117 | 116 |
| 118 } // namespace ash | 117 } // namespace ash |
| OLD | NEW |