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

Side by Side Diff: chrome/browser/chromeos/status/clock_menu_button.cc

Issue 6486007: Introducing ResumeLibrary to track system resume signal (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ResumeLibrary removed, its functions moved to PowerLibrary Created 9 years, 10 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "chrome/browser/chromeos/status/clock_menu_button.h" 5 #include "chrome/browser/chromeos/status/clock_menu_button.h"
6 6
7 #include "base/i18n/time_formatting.h" 7 #include "base/i18n/time_formatting.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "base/time.h" 9 #include "base/time.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 15 matching lines...) Expand all
26 const int kFontSizeDelta = 0; 26 const int kFontSizeDelta = 0;
27 #else 27 #else
28 const int kFontSizeDelta = 1; 28 const int kFontSizeDelta = 1;
29 #endif 29 #endif
30 30
31 ClockMenuButton::ClockMenuButton(StatusAreaHost* host) 31 ClockMenuButton::ClockMenuButton(StatusAreaHost* host)
32 : StatusAreaButton(this), 32 : StatusAreaButton(this),
33 host_(host) { 33 host_(host) {
34 // Add as SystemLibrary observer. We update the clock if timezone changes. 34 // Add as SystemLibrary observer. We update the clock if timezone changes.
35 CrosLibrary::Get()->GetSystemLibrary()->AddObserver(this); 35 CrosLibrary::Get()->GetSystemLibrary()->AddObserver(this);
36 CrosLibrary::Get()->GetPowerLibrary()->AddObserver(this);
36 37
37 set_border(NULL); 38 set_border(NULL);
38 set_use_menu_button_paint(true); 39 set_use_menu_button_paint(true);
39 SetFont(ResourceBundle::GetSharedInstance().GetFont( 40 SetFont(ResourceBundle::GetSharedInstance().GetFont(
40 ResourceBundle::BaseFont).DeriveFont(kFontSizeDelta)); 41 ResourceBundle::BaseFont).DeriveFont(kFontSizeDelta));
41 SetEnabledColor(0xB3FFFFFF); // White with 70% Alpha 42 SetEnabledColor(0xB3FFFFFF); // White with 70% Alpha
42 SetShowMultipleIconStates(false); 43 SetShowMultipleIconStates(false);
43 set_alignment(TextButton::ALIGN_CENTER); 44 set_alignment(TextButton::ALIGN_CENTER);
44 UpdateTextAndSetNextTimer(); 45 UpdateTextAndSetNextTimer();
45 } 46 }
46 47
47 ClockMenuButton::~ClockMenuButton() { 48 ClockMenuButton::~ClockMenuButton() {
49 CrosLibrary::Get()->GetPowerLibrary()->RemoveObserver(this);
48 CrosLibrary::Get()->GetSystemLibrary()->RemoveObserver(this); 50 CrosLibrary::Get()->GetSystemLibrary()->RemoveObserver(this);
49 } 51 }
50 52
51 void ClockMenuButton::UpdateTextAndSetNextTimer() { 53 void ClockMenuButton::UpdateTextAndSetNextTimer() {
52 UpdateText(); 54 UpdateText();
53 55
54 // Try to set the timer to go off at the next change of the minute. We don't 56 // Try to set the timer to go off at the next change of the minute. We don't
55 // want to have the timer go off more than necessary since that will cause 57 // want to have the timer go off more than necessary since that will cause
56 // the CPU to wake up and consume power. 58 // the CPU to wake up and consume power.
57 base::Time now = base::Time::Now(); 59 base::Time now = base::Time::Now();
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 bool ClockMenuButton::IsEnabledAt(int index) const { 106 bool ClockMenuButton::IsEnabledAt(int index) const {
105 // The 1st item is the current date, which is disabled. 107 // The 1st item is the current date, which is disabled.
106 return index != 0; 108 return index != 0;
107 } 109 }
108 110
109 void ClockMenuButton::ActivatedAt(int index) { 111 void ClockMenuButton::ActivatedAt(int index) {
110 host_->OpenButtonOptions(this); 112 host_->OpenButtonOptions(this);
111 } 113 }
112 114
113 /////////////////////////////////////////////////////////////////////////////// 115 ///////////////////////////////////////////////////////////////////////////////
116 // ClockMenuButton, PowerLibrary::Observer implementation:
117
118 void ClockMenuButton::SystemResumed() {
119 UpdateText();
120 }
121
122 ///////////////////////////////////////////////////////////////////////////////
114 // ClockMenuButton, SystemLibrary::Observer implementation: 123 // ClockMenuButton, SystemLibrary::Observer implementation:
115 124
116 void ClockMenuButton::TimezoneChanged(const icu::TimeZone& timezone) { 125 void ClockMenuButton::TimezoneChanged(const icu::TimeZone& timezone) {
117 UpdateText(); 126 UpdateText();
118 } 127 }
119 128
120 //////////////////////////////////////////////////////////////////////////////// 129 ////////////////////////////////////////////////////////////////////////////////
121 // ClockMenuButton, views::ViewMenuDelegate implementation: 130 // ClockMenuButton, views::ViewMenuDelegate implementation:
122 131
123 void ClockMenuButton::RunMenu(views::View* source, const gfx::Point& pt) { 132 void ClockMenuButton::RunMenu(views::View* source, const gfx::Point& pt) {
124 if (!clock_menu_.get()) 133 if (!clock_menu_.get())
125 clock_menu_.reset(new views::Menu2(this)); 134 clock_menu_.reset(new views::Menu2(this));
126 else 135 else
127 clock_menu_->Rebuild(); 136 clock_menu_->Rebuild();
128 clock_menu_->UpdateStates(); 137 clock_menu_->UpdateStates();
129 clock_menu_->RunMenuAt(pt, views::Menu2::ALIGN_TOPRIGHT); 138 clock_menu_->RunMenuAt(pt, views::Menu2::ALIGN_TOPRIGHT);
130 } 139 }
131 140
132 } // namespace chromeos 141 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698