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

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

Issue 3166028: Replace network combobox with network dropdown button (Closed)
Patch Set: Removed trailing spaces Created 10 years, 3 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/chromeos/status/network_dropdown_button.h"
6
7 #include "app/l10n_util.h"
8 #include "app/resource_bundle.h"
9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/chromeos/cros/cros_library.h"
11 #include "chrome/browser/chromeos/options/network_config_view.h"
12 #include "chrome/browser/chromeos/status/status_area_host.h"
13 #include "gfx/canvas_skia.h"
14 #include "grit/generated_resources.h"
15 #include "grit/theme_resources.h"
16 #include "views/window/window.h"
17
18 namespace chromeos {
19
20 ////////////////////////////////////////////////////////////////////////////////
21 // NetworkDropdownButton
22
23 NetworkDropdownButton::NetworkDropdownButton(bool browser_mode,
24 gfx::NativeWindow parent_window)
25 : MenuButton(NULL,
26 l10n_util::GetString(IDS_STATUSBAR_NO_NETWORKS_MESSAGE),
27 this,
28 true),
29 browser_mode_(browser_mode),
30 parent_window_(parent_window) {
31 NetworkChanged(CrosLibrary::Get()->GetNetworkLibrary());
32 CrosLibrary::Get()->GetNetworkLibrary()->AddObserver(this);
33 }
34
35 NetworkDropdownButton::~NetworkDropdownButton() {
36 CrosLibrary::Get()->GetNetworkLibrary()->RemoveObserver(this);
37 }
38
39 ////////////////////////////////////////////////////////////////////////////////
40 // NetworkDropdownButton, NetworkLibrary::Observer implementation:
41
42 void NetworkDropdownButton::NetworkChanged(NetworkLibrary* cros) {
43 // Show network that we will actually use. It could be another network than
44 // user selected. For example user selected WiFi network but we have Ethernet
45 // connection and Chrome OS device will actually use Ethernet.
46
47 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
48 if (CrosLibrary::Get()->EnsureLoaded()) {
49 // Always show the higher priority connection first. Ethernet then wifi.
50 if (cros->ethernet_connected()) {
51 SetIcon(*rb.GetBitmapNamed(IDR_STATUSBAR_WIRED));
52 SetText(l10n_util::GetString(IDS_STATUSBAR_NETWORK_DEVICE_ETHERNET));
53 } else if (cros->wifi_connected() || cros->wifi_connecting()) {
54 SetIcon(IconForNetworkStrength(cros->wifi_strength(), true));
55 SetText(ASCIIToWide(cros->wifi_name()));
56 } else if (cros->cellular_connected() || cros->cellular_connecting()) {
57 SetIcon(IconForNetworkStrength(cros->cellular_strength(), false));
58 SetText(ASCIIToWide(cros->cellular_name()));
59 }
60
61 if (!cros->Connected() && !cros->Connecting()) {
62 SetIcon(SkBitmap());
63 SetText(l10n_util::GetString(IDS_NETWORK_SELECTION_NONE));
64 }
65 } else {
66 SetIcon(SkBitmap());
67 SetText(l10n_util::GetString(IDS_STATUSBAR_NO_NETWORKS_MESSAGE));
68 }
69
70 SchedulePaint();
71 }
72
73 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/status/network_dropdown_button.h ('k') | chrome/browser/chromeos/status/network_menu.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698