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

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

Issue 7633055: base: Fix the TODO in string_util.h (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix chrome_mini_installer.cc Created 9 years, 4 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/power_menu_button.h" 5 #include "chrome/browser/chromeos/status/power_menu_button.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/string_number_conversions.h" 9 #include "base/string_number_conversions.h"
10 #include "base/stringprintf.h"
10 #include "base/time.h" 11 #include "base/time.h"
11 #include "base/utf_string_conversions.h" 12 #include "base/utf_string_conversions.h"
12 #include "chrome/browser/chromeos/cros/cros_library.h" 13 #include "chrome/browser/chromeos/cros/cros_library.h"
13 #include "grit/generated_resources.h" 14 #include "grit/generated_resources.h"
14 #include "grit/theme_resources.h" 15 #include "grit/theme_resources.h"
15 #include "ui/base/l10n/l10n_util.h" 16 #include "ui/base/l10n/l10n_util.h"
16 #include "ui/base/resource/resource_bundle.h" 17 #include "ui/base/resource/resource_bundle.h"
17 #include "ui/gfx/canvas.h" 18 #include "ui/gfx/canvas.h"
18 #include "ui/gfx/canvas_skia.h" 19 #include "ui/gfx/canvas_skia.h"
19 #include "ui/gfx/font.h" 20 #include "ui/gfx/font.h"
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 menu_button_->battery_index_); 170 menu_button_->battery_index_);
170 if (menu_button_->battery_percentage_ < 100 || 171 if (menu_button_->battery_percentage_ < 100 ||
171 !menu_button_->line_power_on_) { 172 !menu_button_->line_power_on_) {
172 draw_percentage_text = true; 173 draw_percentage_text = true;
173 } 174 }
174 } 175 }
175 int image_x = kPadLeftX, image_y = (height() - image.height()) / 2; 176 int image_x = kPadLeftX, image_y = (height() - image.height()) / 2;
176 canvas->DrawBitmapInt(image, image_x, image_y); 177 canvas->DrawBitmapInt(image, image_x, image_y);
177 178
178 if (draw_percentage_text) { 179 if (draw_percentage_text) {
179 string16 text = UTF8ToUTF16(StringPrintf( 180 string16 text = UTF8ToUTF16(base::StringPrintf(
180 "%d%%", 181 "%d%%",
181 static_cast<int>(menu_button_->battery_percentage_))); 182 static_cast<int>(menu_button_->battery_percentage_)));
182 int text_h = percentage_font_.GetHeight(); 183 int text_h = percentage_font_.GetHeight();
183 int text_y = ((height() - text_h) / 2); 184 int text_y = ((height() - text_h) / 2);
184 canvas->DrawStringInt( 185 canvas->DrawStringInt(
185 text, percentage_font_, kPercentageShadowColor, 186 text, percentage_font_, kPercentageShadowColor,
186 image_x, text_y + 1, image.width(), text_h, 187 image_x, text_y + 1, image.width(), text_h,
187 gfx::Canvas::TEXT_ALIGN_CENTER | gfx::Canvas::NO_ELLIPSIS); 188 gfx::Canvas::TEXT_ALIGN_CENTER | gfx::Canvas::NO_ELLIPSIS);
188 canvas->DrawStringInt( 189 canvas->DrawStringInt(
189 text, percentage_font_, kPercentageColor, 190 text, percentage_font_, kPercentageColor,
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 // If previous is 0, then it either was never set (initial condition) 414 // If previous is 0, then it either was never set (initial condition)
414 // or got down to 0. 415 // or got down to 0.
415 if (*previous == TimeDelta::FromMicroseconds(kInitialMS) || 416 if (*previous == TimeDelta::FromMicroseconds(kInitialMS) ||
416 diff < kMinDiff || 417 diff < kMinDiff ||
417 diff > kMaxDiff) { 418 diff > kMaxDiff) {
418 *previous = current; 419 *previous = current;
419 } 420 }
420 } 421 }
421 422
422 } // namespace chromeos 423 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/input_method/xkeyboard.cc ('k') | chrome/browser/chromeos/system/syslogs_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698