OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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_area_view.h" | 5 #include "chrome/browser/chromeos/status_area_view.h" |
6 | 6 |
| 7 #include <dlfcn.h> |
| 8 |
7 #include <algorithm> | 9 #include <algorithm> |
8 #include <dlfcn.h> | |
9 | 10 |
10 #include "app/gfx/canvas.h" | 11 #include "app/gfx/canvas.h" |
11 #include "app/gfx/font.h" | 12 #include "app/gfx/font.h" |
12 #include "app/l10n_util.h" | 13 #include "app/l10n_util.h" |
13 #include "app/resource_bundle.h" | 14 #include "app/resource_bundle.h" |
14 #include "app/theme_provider.h" | 15 #include "app/theme_provider.h" |
15 #include "base/path_service.h" | 16 #include "base/path_service.h" |
16 #include "base/string_util.h" | 17 #include "base/string_util.h" |
17 #include "base/time.h" | 18 #include "base/time.h" |
18 #include "base/timer.h" | 19 #include "base/timer.h" |
19 #include "chrome/app/chrome_dll_resource.h" | 20 #include "chrome/app/chrome_dll_resource.h" |
20 #include "chrome/browser/browser.h" | 21 #include "chrome/browser/browser.h" |
21 #include "chrome/browser/browser_window.h" | 22 #include "chrome/browser/browser_window.h" |
22 #include "chrome/common/chrome_paths.h" | 23 #include "chrome/browser/chromeos/network_menu_button.h" |
23 #include "chrome/browser/gtk/browser_window_gtk.h" | 24 #include "chrome/browser/gtk/browser_window_gtk.h" |
24 #include "chrome/browser/profile.h" | 25 #include "chrome/browser/profile.h" |
| 26 #include "chrome/common/chrome_paths.h" |
25 #include "grit/chromium_strings.h" | 27 #include "grit/chromium_strings.h" |
26 #include "grit/generated_resources.h" | 28 #include "grit/generated_resources.h" |
27 #include "grit/theme_resources.h" | 29 #include "grit/theme_resources.h" |
28 #include "views/controls/button/menu_button.h" | 30 #include "views/controls/button/menu_button.h" |
29 #include "views/controls/image_view.h" | 31 #include "views/controls/image_view.h" |
30 #include "views/controls/menu/menu.h" | 32 #include "views/controls/menu/menu.h" |
31 #include "views/controls/menu/simple_menu_model.h" | 33 #include "views/controls/menu/simple_menu_model.h" |
32 | 34 |
33 namespace { | 35 namespace { |
34 | 36 |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 // Default to opening new tabs on the left. | 199 // Default to opening new tabs on the left. |
198 StatusAreaView::OpenTabsMode StatusAreaView::open_tabs_mode_ = | 200 StatusAreaView::OpenTabsMode StatusAreaView::open_tabs_mode_ = |
199 StatusAreaView::OPEN_TABS_ON_LEFT; | 201 StatusAreaView::OPEN_TABS_ON_LEFT; |
200 | 202 |
201 // static | 203 // static |
202 void* StatusAreaView::power_library_ = NULL; | 204 void* StatusAreaView::power_library_ = NULL; |
203 bool StatusAreaView::power_library_error_ = false; | 205 bool StatusAreaView::power_library_error_ = false; |
204 | 206 |
205 StatusAreaView::StatusAreaView(Browser* browser) | 207 StatusAreaView::StatusAreaView(Browser* browser) |
206 : browser_(browser), | 208 : browser_(browser), |
| 209 network_view_(NULL), |
207 battery_view_(NULL), | 210 battery_view_(NULL), |
208 menu_view_(NULL), | 211 menu_view_(NULL), |
209 power_status_connection_(NULL) { | 212 power_status_connection_(NULL) { |
210 } | 213 } |
211 | 214 |
212 StatusAreaView::~StatusAreaView() { | 215 StatusAreaView::~StatusAreaView() { |
213 if (power_status_connection_) | 216 if (power_status_connection_) |
214 chromeos::DisconnectPowerStatus(power_status_connection_); | 217 chromeos::DisconnectPowerStatus(power_status_connection_); |
215 } | 218 } |
216 | 219 |
217 void StatusAreaView::Init() { | 220 void StatusAreaView::Init() { |
218 LoadPowerLibrary(); | 221 LoadPowerLibrary(); |
219 ThemeProvider* theme = browser_->profile()->GetThemeProvider(); | 222 ThemeProvider* theme = browser_->profile()->GetThemeProvider(); |
220 | 223 |
221 // Clock. | 224 // Clock. |
222 AddChildView(new ClockView); | 225 AddChildView(new ClockView); |
223 | 226 |
| 227 // Network. |
| 228 network_view_ = new NetworkMenuButton(browser_); |
| 229 AddChildView(network_view_); |
| 230 |
224 // Battery. | 231 // Battery. |
225 battery_view_ = new views::ImageView; | 232 battery_view_ = new views::ImageView; |
226 battery_view_->SetImage(theme->GetBitmapNamed(IDR_STATUSBAR_BATTERY_UNKNOWN)); | 233 battery_view_->SetImage(theme->GetBitmapNamed(IDR_STATUSBAR_BATTERY_UNKNOWN)); |
227 AddChildView(battery_view_); | 234 AddChildView(battery_view_); |
228 | 235 |
229 // Menu. | 236 // Menu. |
230 menu_view_ = new views::MenuButton(NULL, std::wstring(), this, false); | 237 menu_view_ = new views::MenuButton(NULL, std::wstring(), this, false); |
231 menu_view_->SetIcon(*theme->GetBitmapNamed(IDR_STATUSBAR_MENU)); | 238 menu_view_->SetIcon(*theme->GetBitmapNamed(IDR_STATUSBAR_MENU)); |
232 AddChildView(menu_view_); | 239 AddChildView(menu_view_); |
233 | 240 |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
408 IDR_STATUSBAR_BATTERY_DISCHARGING_1; | 415 IDR_STATUSBAR_BATTERY_DISCHARGING_1; |
409 double percentage = status.battery_percentage; | 416 double percentage = status.battery_percentage; |
410 int offset = floor(percentage / (100.0 / kNumBatteryImages)); | 417 int offset = floor(percentage / (100.0 / kNumBatteryImages)); |
411 // This can happen if the battery is 100% full. | 418 // This can happen if the battery is 100% full. |
412 if (offset == kNumBatteryImages) | 419 if (offset == kNumBatteryImages) |
413 offset--; | 420 offset--; |
414 image_index += offset; | 421 image_index += offset; |
415 } | 422 } |
416 battery_view_->SetImage(theme->GetBitmapNamed(image_index)); | 423 battery_view_->SetImage(theme->GetBitmapNamed(image_index)); |
417 } | 424 } |
OLD | NEW |