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 <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
10 #include "ash/shell_delegate.h" | 10 #include "ash/shell_delegate.h" |
11 #include "ash/strings/grit/ash_strings.h" | 11 #include "ash/strings/grit/ash_strings.h" |
12 #include "ash/system/chromeos/network/network_connect.h" | |
13 #include "base/bind.h" | 12 #include "base/bind.h" |
14 #include "base/logging.h" | 13 #include "base/logging.h" |
15 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
16 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
17 #include "chrome/browser/chromeos/mobile_config.h" | 16 #include "chrome/browser/chromeos/mobile_config.h" |
18 #include "chrome/browser/chromeos/options/network_config_view.h" | 17 #include "chrome/browser/chromeos/options/network_config_view.h" |
19 #include "chrome/browser/chromeos/sim_dialog_delegate.h" | 18 #include "chrome/browser/chromeos/sim_dialog_delegate.h" |
20 #include "chrome/browser/chromeos/ui/choose_mobile_network_dialog.h" | 19 #include "chrome/browser/chromeos/ui/choose_mobile_network_dialog.h" |
21 #include "chrome/browser/defaults.h" | 20 #include "chrome/browser/defaults.h" |
22 #include "chrome/browser/profiles/profile_manager.h" | 21 #include "chrome/browser/profiles/profile_manager.h" |
23 #include "chrome/common/url_constants.h" | 22 #include "chrome/common/url_constants.h" |
24 #include "chrome/grit/generated_resources.h" | 23 #include "chrome/grit/generated_resources.h" |
25 #include "chromeos/network/device_state.h" | 24 #include "chromeos/network/device_state.h" |
26 #include "chromeos/network/network_state.h" | 25 #include "chromeos/network/network_state.h" |
27 #include "chromeos/network/network_state_handler.h" | 26 #include "chromeos/network/network_state_handler.h" |
28 #include "third_party/cros_system_api/dbus/service_constants.h" | 27 #include "third_party/cros_system_api/dbus/service_constants.h" |
29 #include "ui/base/l10n/l10n_util.h" | 28 #include "ui/base/l10n/l10n_util.h" |
30 #include "ui/base/models/menu_model.h" | 29 #include "ui/base/models/menu_model.h" |
31 #include "ui/base/resource/resource_bundle.h" | 30 #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 12 matching lines...) Expand all Loading... |
54 } | 54 } |
55 | 55 |
56 // Highlight any connected or connecting networks in the UI. | 56 // Highlight any connected or connecting networks in the UI. |
57 bool ShouldHighlightNetwork(const NetworkState* network) { | 57 bool ShouldHighlightNetwork(const NetworkState* network) { |
58 return network->IsConnectedState() || network->IsConnectingState(); | 58 return network->IsConnectedState() || network->IsConnectingState(); |
59 } | 59 } |
60 | 60 |
61 void ToggleTechnology(const NetworkTypePattern& technology) { | 61 void ToggleTechnology(const NetworkTypePattern& technology) { |
62 NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler(); | 62 NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler(); |
63 bool is_enabled = handler->IsTechnologyEnabled(technology); | 63 bool is_enabled = handler->IsTechnologyEnabled(technology); |
64 ash::NetworkConnect::Get()->SetTechnologyEnabled(technology, !is_enabled); | 64 ui::NetworkConnect::Get()->SetTechnologyEnabled(technology, !is_enabled); |
65 } | 65 } |
66 | 66 |
67 } // namespace | 67 } // namespace |
68 | 68 |
69 class NetworkMenuModel : public ui::MenuModel { | 69 class NetworkMenuModel : public ui::MenuModel { |
70 public: | 70 public: |
71 struct MenuItem { | 71 struct MenuItem { |
72 MenuItem() | 72 MenuItem() |
73 : type(ui::MenuModel::TYPE_SEPARATOR), | 73 : type(ui::MenuModel::TYPE_SEPARATOR), |
74 sub_menu_model(NULL), | 74 sub_menu_model(NULL), |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 scoped_ptr<MoreMenuModel> more_menu_model_; | 210 scoped_ptr<MoreMenuModel> more_menu_model_; |
211 | 211 |
212 DISALLOW_COPY_AND_ASSIGN(MainMenuModel); | 212 DISALLOW_COPY_AND_ASSIGN(MainMenuModel); |
213 }; | 213 }; |
214 | 214 |
215 //////////////////////////////////////////////////////////////////////////////// | 215 //////////////////////////////////////////////////////////////////////////////// |
216 // NetworkMenuModel, public methods: | 216 // NetworkMenuModel, public methods: |
217 | 217 |
218 void NetworkMenuModel::ConnectToNetworkAt(int index) { | 218 void NetworkMenuModel::ConnectToNetworkAt(int index) { |
219 const std::string& service_path = menu_items_[index].service_path; | 219 const std::string& service_path = menu_items_[index].service_path; |
220 ash::NetworkConnect::Get()->ConnectToNetwork(service_path); | 220 ui::NetworkConnect::Get()->ConnectToNetwork(service_path); |
221 } | 221 } |
222 | 222 |
223 //////////////////////////////////////////////////////////////////////////////// | 223 //////////////////////////////////////////////////////////////////////////////// |
224 // NetworkMenuModel, ui::MenuModel implementation: | 224 // NetworkMenuModel, ui::MenuModel implementation: |
225 | 225 |
226 bool NetworkMenuModel::HasIcons() const { | 226 bool NetworkMenuModel::HasIcons() const { |
227 return true; | 227 return true; |
228 } | 228 } |
229 | 229 |
230 int NetworkMenuModel::GetItemCount() const { | 230 int NetworkMenuModel::GetItemCount() const { |
(...skipping 442 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 |