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 "chrome/browser/chromeos/status/network_menu.h" | 5 #include "chrome/browser/chromeos/status/network_menu.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
15 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
16 #include "chrome/browser/chromeos/mobile_config.h" | 16 #include "chrome/browser/chromeos/mobile_config.h" |
17 #include "chrome/browser/chromeos/options/network_config_view.h" | 17 #include "chrome/browser/chromeos/options/network_config_view.h" |
18 #include "chrome/browser/chromeos/sim_dialog_delegate.h" | 18 #include "chrome/browser/chromeos/sim_dialog_delegate.h" |
19 #include "chrome/browser/chromeos/ui/choose_mobile_network_dialog.h" | 19 #include "chrome/browser/chromeos/ui/choose_mobile_network_dialog.h" |
20 #include "chrome/browser/defaults.h" | 20 #include "chrome/browser/defaults.h" |
21 #include "chrome/browser/profiles/profile_manager.h" | 21 #include "chrome/browser/profiles/profile_manager.h" |
22 #include "chrome/common/url_constants.h" | 22 #include "chrome/common/url_constants.h" |
23 #include "chrome/grit/generated_resources.h" | 23 #include "chrome/grit/generated_resources.h" |
24 #include "chromeos/network/device_state.h" | 24 #include "chromeos/network/device_state.h" |
| 25 #include "chromeos/network/network_connect.h" |
25 #include "chromeos/network/network_state.h" | 26 #include "chromeos/network/network_state.h" |
26 #include "chromeos/network/network_state_handler.h" | 27 #include "chromeos/network/network_state_handler.h" |
27 #include "third_party/cros_system_api/dbus/service_constants.h" | 28 #include "third_party/cros_system_api/dbus/service_constants.h" |
28 #include "ui/base/l10n/l10n_util.h" | 29 #include "ui/base/l10n/l10n_util.h" |
29 #include "ui/base/models/menu_model.h" | 30 #include "ui/base/models/menu_model.h" |
30 #include "ui/base/resource/resource_bundle.h" | 31 #include "ui/base/resource/resource_bundle.h" |
31 #include "ui/chromeos/network/network_connect.h" | |
32 #include "ui/chromeos/network/network_icon.h" | 32 #include "ui/chromeos/network/network_icon.h" |
33 #include "ui/chromeos/strings/grit/ui_chromeos_strings.h" | 33 #include "ui/chromeos/strings/grit/ui_chromeos_strings.h" |
34 #include "ui/gfx/image/image_skia.h" | 34 #include "ui/gfx/image/image_skia.h" |
35 | 35 |
36 namespace chromeos { | 36 namespace chromeos { |
37 | 37 |
38 namespace { | 38 namespace { |
39 | 39 |
40 // Offsets for views menu ids (main menu and submenu ids use the same | 40 // Offsets for views menu ids (main menu and submenu ids use the same |
41 // namespace). | 41 // namespace). |
(...skipping 15 matching lines...) Expand all Loading... |
57 } | 57 } |
58 | 58 |
59 // Highlight any connected or connecting networks in the UI. | 59 // Highlight any connected or connecting networks in the UI. |
60 bool ShouldHighlightNetwork(const NetworkState* network) { | 60 bool ShouldHighlightNetwork(const NetworkState* network) { |
61 return network->IsConnectedState() || network->IsConnectingState(); | 61 return network->IsConnectedState() || network->IsConnectingState(); |
62 } | 62 } |
63 | 63 |
64 void ToggleTechnology(const NetworkTypePattern& technology) { | 64 void ToggleTechnology(const NetworkTypePattern& technology) { |
65 NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler(); | 65 NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler(); |
66 bool is_enabled = handler->IsTechnologyEnabled(technology); | 66 bool is_enabled = handler->IsTechnologyEnabled(technology); |
67 ui::NetworkConnect::Get()->SetTechnologyEnabled(technology, !is_enabled); | 67 NetworkConnect::Get()->SetTechnologyEnabled(technology, !is_enabled); |
68 } | 68 } |
69 | 69 |
70 } // namespace | 70 } // namespace |
71 | 71 |
72 class NetworkMenuModel : public ui::MenuModel { | 72 class NetworkMenuModel : public ui::MenuModel { |
73 public: | 73 public: |
74 struct MenuItem { | 74 struct MenuItem { |
75 MenuItem() | 75 MenuItem() |
76 : type(ui::MenuModel::TYPE_SEPARATOR), | 76 : type(ui::MenuModel::TYPE_SEPARATOR), |
77 sub_menu_model(NULL), | 77 sub_menu_model(NULL), |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 std::unique_ptr<MoreMenuModel> more_menu_model_; | 211 std::unique_ptr<MoreMenuModel> more_menu_model_; |
212 | 212 |
213 DISALLOW_COPY_AND_ASSIGN(MainMenuModel); | 213 DISALLOW_COPY_AND_ASSIGN(MainMenuModel); |
214 }; | 214 }; |
215 | 215 |
216 //////////////////////////////////////////////////////////////////////////////// | 216 //////////////////////////////////////////////////////////////////////////////// |
217 // NetworkMenuModel, public methods: | 217 // NetworkMenuModel, public methods: |
218 | 218 |
219 void NetworkMenuModel::ConnectToNetworkAt(int index) { | 219 void NetworkMenuModel::ConnectToNetworkAt(int index) { |
220 const std::string& service_path = menu_items_[index].service_path; | 220 const std::string& service_path = menu_items_[index].service_path; |
221 ui::NetworkConnect::Get()->ConnectToNetwork(service_path); | 221 NetworkConnect::Get()->ConnectToNetwork(service_path); |
222 } | 222 } |
223 | 223 |
224 //////////////////////////////////////////////////////////////////////////////// | 224 //////////////////////////////////////////////////////////////////////////////// |
225 // NetworkMenuModel, ui::MenuModel implementation: | 225 // NetworkMenuModel, ui::MenuModel implementation: |
226 | 226 |
227 bool NetworkMenuModel::HasIcons() const { | 227 bool NetworkMenuModel::HasIcons() const { |
228 return true; | 228 return true; |
229 } | 229 } |
230 | 230 |
231 int NetworkMenuModel::GetItemCount() const { | 231 int NetworkMenuModel::GetItemCount() const { |
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
673 return main_menu_model_.get(); | 673 return main_menu_model_.get(); |
674 } | 674 } |
675 | 675 |
676 void NetworkMenu::UpdateMenu() { | 676 void NetworkMenu::UpdateMenu() { |
677 refreshing_menu_ = true; | 677 refreshing_menu_ = true; |
678 main_menu_model_->InitMenuItems(delegate_->ShouldOpenButtonOptions()); | 678 main_menu_model_->InitMenuItems(delegate_->ShouldOpenButtonOptions()); |
679 refreshing_menu_ = false; | 679 refreshing_menu_ = false; |
680 } | 680 } |
681 | 681 |
682 } // namespace chromeos | 682 } // namespace chromeos |
OLD | NEW |