OLD | NEW |
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/system/locale/tray_locale.h" | 5 #include "ash/system/locale/tray_locale.h" |
6 | 6 |
7 #include "ash/system/tray/tray_constants.h" | 7 #include "ash/system/tray/tray_constants.h" |
| 8 #include "ash/system/tray/tray_notification_view.h" |
8 #include "ash/system/tray/tray_views.h" | 9 #include "ash/system/tray/tray_views.h" |
9 #include "base/string16.h" | 10 #include "base/string16.h" |
10 #include "grit/ash_strings.h" | 11 #include "grit/ash_strings.h" |
11 #include "grit/ui_resources_standard.h" | 12 #include "grit/ui_resources_standard.h" |
12 #include "ui/base/l10n/l10n_util.h" | 13 #include "ui/base/l10n/l10n_util.h" |
13 #include "ui/base/resource/resource_bundle.h" | 14 #include "ui/base/resource/resource_bundle.h" |
14 #include "ui/views/view.h" | 15 #include "ui/views/view.h" |
15 #include "ui/views/controls/label.h" | 16 #include "ui/views/controls/label.h" |
16 #include "ui/views/controls/link.h" | 17 #include "ui/views/controls/link.h" |
17 #include "ui/views/controls/link_listener.h" | 18 #include "ui/views/controls/link_listener.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 DISALLOW_COPY_AND_ASSIGN(LocaleMessageView); | 71 DISALLOW_COPY_AND_ASSIGN(LocaleMessageView); |
71 }; | 72 }; |
72 | 73 |
73 class LocaleNotificationView : public TrayNotificationView { | 74 class LocaleNotificationView : public TrayNotificationView { |
74 public: | 75 public: |
75 LocaleNotificationView(TrayLocale* tray, | 76 LocaleNotificationView(TrayLocale* tray, |
76 LocaleObserver::Delegate* delegate, | 77 LocaleObserver::Delegate* delegate, |
77 const std::string& cur_locale, | 78 const std::string& cur_locale, |
78 const std::string& from_locale, | 79 const std::string& from_locale, |
79 const std::string& to_locale) | 80 const std::string& to_locale) |
80 : TrayNotificationView(IDR_AURA_UBER_TRAY_LOCALE), | 81 : TrayNotificationView(tray, IDR_AURA_UBER_TRAY_LOCALE), |
81 tray_(tray), | |
82 delegate_(delegate) { | 82 delegate_(delegate) { |
83 views::View* container = new LocaleMessageView( | 83 views::View* container = new LocaleMessageView( |
84 delegate, cur_locale, from_locale, to_locale); | 84 delegate, cur_locale, from_locale, to_locale); |
85 InitView(container); | 85 InitView(container); |
86 } | 86 } |
87 | 87 |
88 void Update(LocaleObserver::Delegate* delegate, | 88 void Update(LocaleObserver::Delegate* delegate, |
89 const std::string& cur_locale, | 89 const std::string& cur_locale, |
90 const std::string& from_locale, | 90 const std::string& from_locale, |
91 const std::string& to_locale) { | 91 const std::string& to_locale) { |
92 delegate_ = delegate; | 92 delegate_ = delegate; |
93 views::View* container = new LocaleMessageView( | 93 views::View* container = new LocaleMessageView( |
94 delegate, cur_locale, from_locale, to_locale); | 94 delegate, cur_locale, from_locale, to_locale); |
95 UpdateView(container); | 95 UpdateView(container); |
96 } | 96 } |
97 | 97 |
98 // Overridden from TrayNotificationView. | 98 // Overridden from TrayNotificationView. |
99 virtual void OnClose() OVERRIDE { | 99 virtual void OnClose() OVERRIDE { |
100 if (delegate_) | 100 if (delegate_) |
101 delegate_->AcceptLocaleChange(); | 101 delegate_->AcceptLocaleChange(); |
102 tray_->HideNotificationView(); | |
103 } | 102 } |
104 | 103 |
105 private: | 104 private: |
106 TrayLocale* tray_; | |
107 LocaleObserver::Delegate* delegate_; | 105 LocaleObserver::Delegate* delegate_; |
108 | 106 |
109 DISALLOW_COPY_AND_ASSIGN(LocaleNotificationView); | 107 DISALLOW_COPY_AND_ASSIGN(LocaleNotificationView); |
110 }; | 108 }; |
111 | 109 |
112 } // namespace tray | 110 } // namespace tray |
113 | 111 |
114 TrayLocale::TrayLocale() | 112 TrayLocale::TrayLocale() |
115 : notification_(NULL), | 113 : notification_(NULL), |
116 delegate_(NULL) { | 114 delegate_(NULL) { |
(...skipping 24 matching lines...) Expand all Loading... |
141 from_locale_ = from_locale; | 139 from_locale_ = from_locale; |
142 to_locale_ = to_locale; | 140 to_locale_ = to_locale; |
143 if (notification_) | 141 if (notification_) |
144 notification_->Update(delegate, cur_locale_, from_locale_, to_locale_); | 142 notification_->Update(delegate, cur_locale_, from_locale_, to_locale_); |
145 else | 143 else |
146 ShowNotificationView(); | 144 ShowNotificationView(); |
147 } | 145 } |
148 | 146 |
149 } // namespace internal | 147 } // namespace internal |
150 } // namespace ash | 148 } // namespace ash |
OLD | NEW |