OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ash/system/network/tray_network.h" | 5 #include "ash/system/network/tray_network.h" |
6 | 6 |
7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
8 #include "ash/shell_window_ids.h" | 8 #include "ash/shell_window_ids.h" |
9 #include "ash/system/tray/system_tray.h" | 9 #include "ash/system/tray/system_tray.h" |
10 #include "ash/system/tray/system_tray_delegate.h" | 10 #include "ash/system/tray/system_tray_delegate.h" |
11 #include "ash/system/tray/tray_constants.h" | 11 #include "ash/system/tray/tray_constants.h" |
12 #include "ash/system/tray/tray_item_more.h" | 12 #include "ash/system/tray/tray_item_more.h" |
| 13 #include "ash/system/tray/tray_item_view.h" |
13 #include "ash/system/tray/tray_views.h" | 14 #include "ash/system/tray/tray_views.h" |
14 #include "base/utf_string_conversions.h" | 15 #include "base/utf_string_conversions.h" |
15 #include "grit/ash_strings.h" | 16 #include "grit/ash_strings.h" |
16 #include "grit/ui_resources.h" | 17 #include "grit/ui_resources.h" |
17 #include "third_party/skia/include/core/SkColor.h" | 18 #include "third_party/skia/include/core/SkColor.h" |
18 #include "ui/aura/window.h" | 19 #include "ui/aura/window.h" |
19 #include "ui/base/resource/resource_bundle.h" | 20 #include "ui/base/resource/resource_bundle.h" |
20 #include "ui/gfx/canvas.h" | 21 #include "ui/gfx/canvas.h" |
21 #include "ui/gfx/font.h" | 22 #include "ui/gfx/font.h" |
22 #include "ui/gfx/image/image.h" | 23 #include "ui/gfx/image/image.h" |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 namespace ash { | 92 namespace ash { |
92 namespace internal { | 93 namespace internal { |
93 | 94 |
94 namespace tray { | 95 namespace tray { |
95 | 96 |
96 enum ColorTheme { | 97 enum ColorTheme { |
97 LIGHT, | 98 LIGHT, |
98 DARK, | 99 DARK, |
99 }; | 100 }; |
100 | 101 |
101 class NetworkTrayView : public views::View { | 102 class NetworkTrayView : public TrayItemView { |
102 public: | 103 public: |
103 NetworkTrayView(ColorTheme size, bool tray_icon) | 104 NetworkTrayView(ColorTheme size, bool tray_icon) |
104 : color_theme_(size), tray_icon_(tray_icon) { | 105 : color_theme_(size), tray_icon_(tray_icon) { |
105 SetLayoutManager(new views::FillLayout()); | 106 SetLayoutManager(new views::FillLayout()); |
106 | 107 |
107 image_view_ = color_theme_ == DARK ? | 108 image_view_ = color_theme_ == DARK ? |
108 new FixedSizedImageView(0, kTrayPopupItemHeight) : | 109 new FixedSizedImageView(0, kTrayPopupItemHeight) : |
109 new views::ImageView; | 110 new views::ImageView; |
110 AddChildView(image_view_); | 111 AddChildView(image_view_); |
111 | 112 |
(...skipping 17 matching lines...) Expand all Loading... |
129 ColorTheme color_theme_; | 130 ColorTheme color_theme_; |
130 bool tray_icon_; | 131 bool tray_icon_; |
131 | 132 |
132 DISALLOW_COPY_AND_ASSIGN(NetworkTrayView); | 133 DISALLOW_COPY_AND_ASSIGN(NetworkTrayView); |
133 }; | 134 }; |
134 | 135 |
135 class NetworkDefaultView : public TrayItemMore { | 136 class NetworkDefaultView : public TrayItemMore { |
136 public: | 137 public: |
137 explicit NetworkDefaultView(SystemTrayItem* owner) | 138 explicit NetworkDefaultView(SystemTrayItem* owner) |
138 : TrayItemMore(owner) { | 139 : TrayItemMore(owner) { |
139 icon_ = new NetworkTrayView(DARK, false /* tray_icon */); | |
140 ReplaceIcon(icon_); | |
141 Update(); | 140 Update(); |
142 } | 141 } |
143 | 142 |
144 virtual ~NetworkDefaultView() {} | 143 virtual ~NetworkDefaultView() {} |
145 | 144 |
146 void Update() { | 145 void Update() { |
147 NetworkIconInfo info; | 146 NetworkIconInfo info; |
148 Shell::GetInstance()->tray_delegate()-> | 147 Shell::GetInstance()->tray_delegate()-> |
149 GetMostRelevantNetworkIcon(&info, true); | 148 GetMostRelevantNetworkIcon(&info, true); |
150 icon_->Update(info); | 149 SetImage(&info.image); |
151 SetLabel(info.description); | 150 SetLabel(info.description); |
152 SetAccessibleName(info.description); | 151 SetAccessibleName(info.description); |
153 } | 152 } |
154 | 153 |
155 private: | 154 private: |
156 NetworkTrayView* icon_; | |
157 | |
158 DISALLOW_COPY_AND_ASSIGN(NetworkDefaultView); | 155 DISALLOW_COPY_AND_ASSIGN(NetworkDefaultView); |
159 }; | 156 }; |
160 | 157 |
161 class NetworkDetailedView : public views::View, | 158 class NetworkDetailedView : public views::View, |
162 public views::ButtonListener, | 159 public views::ButtonListener, |
163 public ViewClickListener { | 160 public ViewClickListener { |
164 public: | 161 public: |
165 explicit NetworkDetailedView(user::LoginStatus login) | 162 explicit NetworkDetailedView(user::LoginStatus login) |
166 : login_(login), | 163 : login_(login), |
167 header_(NULL), | 164 header_(NULL), |
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
524 if (tray_.get()) | 521 if (tray_.get()) |
525 tray_->Update(info); | 522 tray_->Update(info); |
526 if (default_.get()) | 523 if (default_.get()) |
527 default_->Update(); | 524 default_->Update(); |
528 if (detailed_.get()) | 525 if (detailed_.get()) |
529 detailed_->Update(); | 526 detailed_->Update(); |
530 } | 527 } |
531 | 528 |
532 } // namespace internal | 529 } // namespace internal |
533 } // namespace ash | 530 } // namespace ash |
OLD | NEW |