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

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

Issue 6811025: Change status button menu implementation from Menu2 to MenuItemView. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Mainly updates to newer coding style. Created 9 years, 8 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/network_dropdown_button.h" 5 #include "chrome/browser/chromeos/status/network_dropdown_button.h"
6 6
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "chrome/browser/chromeos/cros/cros_library.h" 8 #include "chrome/browser/chromeos/cros/cros_library.h"
9 #include "chrome/browser/chromeos/options/network_config_view.h" 9 #include "chrome/browser/chromeos/options/network_config_view.h"
10 #include "chrome/browser/chromeos/status/status_area_host.h" 10 #include "chrome/browser/chromeos/status/status_area_host.h"
11 #include "grit/generated_resources.h" 11 #include "grit/generated_resources.h"
12 #include "grit/theme_resources.h" 12 #include "grit/theme_resources.h"
13 #include "ui/base/l10n/l10n_util.h" 13 #include "ui/base/l10n/l10n_util.h"
14 #include "ui/base/resource/resource_bundle.h" 14 #include "ui/base/resource/resource_bundle.h"
15 #include "ui/gfx/canvas_skia.h" 15 #include "ui/gfx/canvas_skia.h"
16 #include "views/window/window.h" 16 #include "views/window/window.h"
17 17
18 namespace chromeos { 18 namespace chromeos {
19 19
20 //////////////////////////////////////////////////////////////////////////////// 20 // NetworkDropdownButton ------------------------------------------------------
21 // NetworkDropdownButton
22 21
23 // static 22 // static
24 const int NetworkDropdownButton::kThrobDuration = 1000; 23 const int NetworkDropdownButton::kThrobDuration = 1000;
25 24
26 NetworkDropdownButton::NetworkDropdownButton(bool browser_mode, 25 NetworkDropdownButton::NetworkDropdownButton(bool browser_mode,
27 gfx::NativeWindow parent_window) 26 gfx::NativeWindow parent_window)
28 : DropDownButton(NULL, 27 : DropDownButton(NULL,
29 UTF16ToWide(l10n_util::GetStringUTF16( 28 UTF16ToWide(l10n_util::GetStringUTF16(
30 IDS_STATUSBAR_NO_NETWORKS_MESSAGE)), 29 IDS_STATUSBAR_NO_NETWORKS_MESSAGE)),
31 this, 30 this,
32 true), 31 true),
33 browser_mode_(browser_mode), 32 browser_mode_(browser_mode),
34 ALLOW_THIS_IN_INITIALIZER_LIST(animation_connecting_(this)), 33 ALLOW_THIS_IN_INITIALIZER_LIST(animation_connecting_(this)),
35 parent_window_(parent_window) { 34 parent_window_(parent_window) {
36 animation_connecting_.SetThrobDuration(kThrobDuration); 35 animation_connecting_.SetThrobDuration(kThrobDuration);
37 animation_connecting_.SetTweenType(ui::Tween::EASE_IN_OUT); 36 animation_connecting_.SetTweenType(ui::Tween::EASE_IN_OUT);
38 CrosLibrary::Get()->GetNetworkLibrary()->AddNetworkManagerObserver(this); 37 CrosLibrary::Get()->GetNetworkLibrary()->AddNetworkManagerObserver(this);
39 // The initial state will be updated on Refresh. 38 // The initial state will be updated on Refresh.
40 // See network_selection_view.cc. 39 // See network_selection_view.cc.
41 } 40 }
42 41
43 NetworkDropdownButton::~NetworkDropdownButton() { 42 NetworkDropdownButton::~NetworkDropdownButton() {
44 CrosLibrary::Get()->GetNetworkLibrary()->RemoveNetworkManagerObserver(this); 43 CrosLibrary::Get()->GetNetworkLibrary()->RemoveNetworkManagerObserver(this);
45 } 44 }
46 45
47 //////////////////////////////////////////////////////////////////////////////// 46 // NetworkMenuButton, ui::AnimationDelegate implementation: -------------------
48 // NetworkMenuButton, ui::AnimationDelegate implementation:
49 47
50 void NetworkDropdownButton::AnimationProgressed( 48 void NetworkDropdownButton::AnimationProgressed(
51 const ui::Animation* animation) { 49 const ui::Animation* animation) {
52 if (animation == &animation_connecting_) { 50 if (animation == &animation_connecting_) {
53 SetIcon(*IconForNetworkConnecting(animation_connecting_.GetCurrentValue(), 51 SetIcon(*IconForNetworkConnecting(animation_connecting_.GetCurrentValue(),
54 true)); 52 true));
55 SchedulePaint(); 53 SchedulePaint();
56 } else { 54 } else {
57 MenuButton::AnimationProgressed(animation); 55 MenuButton::AnimationProgressed(animation);
58 } 56 }
59 } 57 }
60 58
61 void NetworkDropdownButton::Refresh() { 59 void NetworkDropdownButton::Refresh() {
62 OnNetworkManagerChanged(CrosLibrary::Get()->GetNetworkLibrary()); 60 OnNetworkManagerChanged(CrosLibrary::Get()->GetNetworkLibrary());
63 } 61 }
64 62
65 //////////////////////////////////////////////////////////////////////////////// 63 // NetworkDropdownButton, NetworkMenu implementation: -------------------------
64 bool NetworkDropdownButton::IsBrowserMode() const OVERRIDE {
65 return browser_mode_;
66 }
67
68 views::MenuButton* NetworkDropdownButton::GetMenuButton() OVERRIDE {
69 return this;
70 }
71
72 gfx::NativeWindow NetworkDropdownButton::GetNativeWindow() OVERRIDE const {
73 return parent_window_;
74 }
75
76 void NetworkDropdownButton::OpenButtonOptions() OVERRIDE {
77 }
78
79 bool NetworkDropdownButton::ShouldOpenButtonOptions() OVERRIDE const {
80 return false;
81 }
82
66 // NetworkDropdownButton, NetworkLibrary::NetworkManagerObserver implementation: 83 // NetworkDropdownButton, NetworkLibrary::NetworkManagerObserver implementation:
67 84
68 void NetworkDropdownButton::OnNetworkManagerChanged(NetworkLibrary* cros) { 85 void NetworkDropdownButton::OnNetworkManagerChanged(NetworkLibrary* cros) {
69 // Show network that we will actually use. It could be another network than 86 // Show network that we will actually use. It could be another network than
70 // user selected. For example user selected WiFi network but we have Ethernet 87 // user selected. For example user selected WiFi network but we have Ethernet
71 // connection and Chrome OS device will actually use Ethernet. 88 // connection and Chrome OS device will actually use Ethernet.
72 89
73 // This gets called on initialization, so any changes should be reflected 90 // This gets called on initialization, so any changes should be reflected
74 // in CrosMock::SetNetworkLibraryStatusAreaExpectations(). 91 // in CrosMock::SetNetworkLibraryStatusAreaExpectations().
75 92
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 SetIcon(SkBitmap()); 136 SetIcon(SkBitmap());
120 SetText(UTF16ToWide( 137 SetText(UTF16ToWide(
121 l10n_util::GetStringUTF16(IDS_STATUSBAR_NO_NETWORKS_MESSAGE))); 138 l10n_util::GetStringUTF16(IDS_STATUSBAR_NO_NETWORKS_MESSAGE)));
122 } 139 }
123 140
124 SchedulePaint(); 141 SchedulePaint();
125 UpdateMenu(); 142 UpdateMenu();
126 } 143 }
127 144
128 } // namespace chromeos 145 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698