Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(169)

Side by Side Diff: ash/system/ime/tray_ime.cc

Issue 16046007: Shows the display info as a popup when a new display is connected. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: PopupDetailedView -> ShowNotificationView Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ash/system/chromeos/tray_display.cc ('k') | ash/system/tray/tray_notification_view.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/ime/tray_ime.h" 5 #include "ash/system/ime/tray_ime.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "ash/root_window_controller.h" 9 #include "ash/root_window_controller.h"
10 #include "ash/shelf/shelf_widget.h" 10 #include "ash/shelf/shelf_widget.h"
11 #include "ash/shell.h" 11 #include "ash/shell.h"
12 #include "ash/system/tray/hover_highlight_view.h" 12 #include "ash/system/tray/hover_highlight_view.h"
13 #include "ash/system/tray/system_tray.h" 13 #include "ash/system/tray/system_tray.h"
14 #include "ash/system/tray/system_tray_delegate.h" 14 #include "ash/system/tray/system_tray_delegate.h"
15 #include "ash/system/tray/system_tray_notifier.h" 15 #include "ash/system/tray/system_tray_notifier.h"
16 #include "ash/system/tray/tray_constants.h" 16 #include "ash/system/tray/tray_constants.h"
17 #include "ash/system/tray/tray_details_view.h" 17 #include "ash/system/tray/tray_details_view.h"
18 #include "ash/system/tray/tray_item_more.h" 18 #include "ash/system/tray/tray_item_more.h"
19 #include "ash/system/tray/tray_item_view.h" 19 #include "ash/system/tray/tray_item_view.h"
20 #include "ash/system/tray/tray_notification_view.h" 20 #include "ash/system/tray/tray_notification_view.h"
21 #include "ash/system/tray/tray_utils.h" 21 #include "ash/system/tray/tray_utils.h"
22 #include "base/logging.h" 22 #include "base/logging.h"
23 #include "base/timer.h"
24 #include "base/utf_string_conversions.h" 23 #include "base/utf_string_conversions.h"
25 #include "grit/ash_resources.h" 24 #include "grit/ash_resources.h"
26 #include "grit/ash_strings.h" 25 #include "grit/ash_strings.h"
27 #include "ui/base/l10n/l10n_util.h" 26 #include "ui/base/l10n/l10n_util.h"
28 #include "ui/base/resource/resource_bundle.h" 27 #include "ui/base/resource/resource_bundle.h"
29 #include "ui/gfx/font.h" 28 #include "ui/gfx/font.h"
30 #include "ui/gfx/image/image.h" 29 #include "ui/gfx/image/image.h"
31 #include "ui/views/controls/label.h" 30 #include "ui/views/controls/label.h"
32 #include "ui/views/layout/box_layout.h" 31 #include "ui/views/layout/box_layout.h"
33 #include "ui/views/widget/widget.h" 32 #include "ui/views/widget/widget.h"
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 explicit IMENotificationView(TrayIME* owner) 173 explicit IMENotificationView(TrayIME* owner)
175 : TrayNotificationView(owner, IDR_AURA_UBER_TRAY_IME) { 174 : TrayNotificationView(owner, IDR_AURA_UBER_TRAY_IME) {
176 InitView(GetLabel()); 175 InitView(GetLabel());
177 } 176 }
178 177
179 void UpdateLabel() { 178 void UpdateLabel() {
180 RestartAutoCloseTimer(); 179 RestartAutoCloseTimer();
181 UpdateView(GetLabel()); 180 UpdateView(GetLabel());
182 } 181 }
183 182
184 void StartAutoCloseTimer(int seconds) {
185 autoclose_.Stop();
186 autoclose_delay_ = seconds;
187 if (autoclose_delay_) {
188 autoclose_.Start(FROM_HERE,
189 base::TimeDelta::FromSeconds(autoclose_delay_),
190 this, &IMENotificationView::Close);
191 }
192 }
193
194 void StopAutoCloseTimer() {
195 autoclose_.Stop();
196 }
197
198 void RestartAutoCloseTimer() {
199 if (autoclose_delay_)
200 StartAutoCloseTimer(autoclose_delay_);
201 }
202
203 // Overridden from TrayNotificationView. 183 // Overridden from TrayNotificationView.
204 virtual void OnClickAction() OVERRIDE { 184 virtual void OnClickAction() OVERRIDE {
205 owner()->PopupDetailedView(0, true); 185 owner()->PopupDetailedView(0, true);
206 } 186 }
207 187
208 private: 188 private:
209 void Close() {
210 owner()->HideNotificationView();
211 }
212
213 views::Label* GetLabel() { 189 views::Label* GetLabel() {
214 SystemTrayDelegate* delegate = Shell::GetInstance()->system_tray_delegate(); 190 SystemTrayDelegate* delegate = Shell::GetInstance()->system_tray_delegate();
215 IMEInfo current; 191 IMEInfo current;
216 delegate->GetCurrentIME(&current); 192 delegate->GetCurrentIME(&current);
217 193
218 // TODO(zork): Use IDS_ASH_STATUS_TRAY_THIRD_PARTY_IME_TURNED_ON_BUBBLE for 194 // TODO(zork): Use IDS_ASH_STATUS_TRAY_THIRD_PARTY_IME_TURNED_ON_BUBBLE for
219 // third party IMEs 195 // third party IMEs
220 views::Label* label = new views::Label( 196 views::Label* label = new views::Label(
221 l10n_util::GetStringFUTF16( 197 l10n_util::GetStringFUTF16(
222 IDS_ASH_STATUS_TRAY_IME_TURNED_ON_BUBBLE, 198 IDS_ASH_STATUS_TRAY_IME_TURNED_ON_BUBBLE,
223 current.medium_name)); 199 current.medium_name));
224 label->SetMultiLine(true); 200 label->SetMultiLine(true);
225 label->SetHorizontalAlignment(gfx::ALIGN_LEFT); 201 label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
226 return label; 202 return label;
227 } 203 }
228 204
229
230 int autoclose_delay_;
231 base::OneShotTimer<IMENotificationView> autoclose_;
232
233 DISALLOW_COPY_AND_ASSIGN(IMENotificationView); 205 DISALLOW_COPY_AND_ASSIGN(IMENotificationView);
234 }; 206 };
235 207
236 208
237 } // namespace tray 209 } // namespace tray
238 210
239 TrayIME::TrayIME(SystemTray* system_tray) 211 TrayIME::TrayIME(SystemTray* system_tray)
240 : SystemTrayItem(system_tray), 212 : SystemTrayItem(system_tray),
241 tray_label_(NULL), 213 tray_label_(NULL),
242 default_(NULL), 214 default_(NULL),
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 } else if (!Shell::GetPrimaryRootWindowController()->shelf()->IsVisible() || 319 } else if (!Shell::GetPrimaryRootWindowController()->shelf()->IsVisible() ||
348 !message_shown_) { 320 !message_shown_) {
349 ShowNotificationView(); 321 ShowNotificationView();
350 message_shown_ = true; 322 message_shown_ = true;
351 } 323 }
352 } 324 }
353 } 325 }
354 326
355 } // namespace internal 327 } // namespace internal
356 } // namespace ash 328 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/chromeos/tray_display.cc ('k') | ash/system/tray/tray_notification_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698