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/system/chromeos/network/network_connect.h" |
11 #include "ash/system/chromeos/network/network_icon.h" | 12 #include "ash/system/chromeos/network/network_icon.h" |
12 #include "base/bind.h" | 13 #include "base/bind.h" |
13 #include "base/logging.h" | 14 #include "base/logging.h" |
14 #include "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
15 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
16 #include "chrome/browser/chromeos/choose_mobile_network_dialog.h" | 17 #include "chrome/browser/chromeos/choose_mobile_network_dialog.h" |
17 #include "chrome/browser/chromeos/login/user_manager.h" | 18 #include "chrome/browser/chromeos/login/user_manager.h" |
18 #include "chrome/browser/chromeos/mobile_config.h" | 19 #include "chrome/browser/chromeos/mobile_config.h" |
19 #include "chrome/browser/chromeos/options/network_config_view.h" | 20 #include "chrome/browser/chromeos/options/network_config_view.h" |
20 #include "chrome/browser/chromeos/options/network_connect.h" | |
21 #include "chrome/browser/defaults.h" | 21 #include "chrome/browser/defaults.h" |
22 #include "chrome/browser/profiles/profile_manager.h" | 22 #include "chrome/browser/profiles/profile_manager.h" |
23 #include "chrome/common/url_constants.h" | 23 #include "chrome/common/url_constants.h" |
24 #include "chromeos/network/device_state.h" | 24 #include "chromeos/network/device_state.h" |
25 #include "chromeos/network/network_state.h" | 25 #include "chromeos/network/network_state.h" |
26 #include "chromeos/network/network_state_handler.h" | 26 #include "chromeos/network/network_state_handler.h" |
27 #include "grit/ash_resources.h" | 27 #include "grit/ash_resources.h" |
28 #include "grit/ash_strings.h" | 28 #include "grit/ash_strings.h" |
29 #include "grit/generated_resources.h" | 29 #include "grit/generated_resources.h" |
30 #include "third_party/cros_system_api/dbus/service_constants.h" | 30 #include "third_party/cros_system_api/dbus/service_constants.h" |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 scoped_ptr<MoreMenuModel> more_menu_model_; | 212 scoped_ptr<MoreMenuModel> more_menu_model_; |
213 | 213 |
214 DISALLOW_COPY_AND_ASSIGN(MainMenuModel); | 214 DISALLOW_COPY_AND_ASSIGN(MainMenuModel); |
215 }; | 215 }; |
216 | 216 |
217 //////////////////////////////////////////////////////////////////////////////// | 217 //////////////////////////////////////////////////////////////////////////////// |
218 // NetworkMenuModel, public methods: | 218 // NetworkMenuModel, public methods: |
219 | 219 |
220 void NetworkMenuModel::ConnectToNetworkAt(int index) { | 220 void NetworkMenuModel::ConnectToNetworkAt(int index) { |
221 const std::string& service_path = menu_items_[index].service_path; | 221 const std::string& service_path = menu_items_[index].service_path; |
222 network_connect::ConnectResult result = | 222 gfx::NativeWindow native_window = owner_->delegate()->GetNativeWindow(); |
223 network_connect::ConnectToNetwork( | 223 ash::network_connect::ConnectToNetwork(service_path, native_window); |
224 service_path, owner_->delegate()->GetNativeWindow()); | |
225 if (result == network_connect::NETWORK_NOT_FOUND) { | |
226 // If we are attempting to connect to a network that no longer exists, | |
227 // display a notification. | |
228 LOG(WARNING) << "Network does not exist to connect to: " | |
229 << service_path; | |
230 // TODO(stevenjb): Show notification. | |
231 } | |
232 } | 224 } |
233 | 225 |
234 //////////////////////////////////////////////////////////////////////////////// | 226 //////////////////////////////////////////////////////////////////////////////// |
235 // NetworkMenuModel, ui::MenuModel implementation: | 227 // NetworkMenuModel, ui::MenuModel implementation: |
236 | 228 |
237 bool NetworkMenuModel::HasIcons() const { | 229 bool NetworkMenuModel::HasIcons() const { |
238 return true; | 230 return true; |
239 } | 231 } |
240 | 232 |
241 int NetworkMenuModel::GetItemCount() const { | 233 int NetworkMenuModel::GetItemCount() const { |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 } | 334 } |
343 | 335 |
344 //////////////////////////////////////////////////////////////////////////////// | 336 //////////////////////////////////////////////////////////////////////////////// |
345 // NetworkMenuModel, private methods: | 337 // NetworkMenuModel, private methods: |
346 | 338 |
347 void NetworkMenuModel::ShowOther(const std::string& type) const { | 339 void NetworkMenuModel::ShowOther(const std::string& type) const { |
348 gfx::NativeWindow native_window = owner_->delegate()->GetNativeWindow(); | 340 gfx::NativeWindow native_window = owner_->delegate()->GetNativeWindow(); |
349 if (type == flimflam::kTypeCellular) | 341 if (type == flimflam::kTypeCellular) |
350 ChooseMobileNetworkDialog::ShowDialog(native_window); | 342 ChooseMobileNetworkDialog::ShowDialog(native_window); |
351 else | 343 else |
352 NetworkConfigView::ShowForType(chromeos::TYPE_WIFI, native_window); | 344 NetworkConfigView::ShowForType(flimflam::kTypeWifi, native_window); |
353 } | 345 } |
354 | 346 |
355 //////////////////////////////////////////////////////////////////////////////// | 347 //////////////////////////////////////////////////////////////////////////////// |
356 // MainMenuModel | 348 // MainMenuModel |
357 | 349 |
358 void MainMenuModel::AddWirelessNetworkMenuItem(const NetworkState* network, | 350 void MainMenuModel::AddWirelessNetworkMenuItem(const NetworkState* network, |
359 int flag) { | 351 int flag) { |
360 string16 label; | 352 string16 label; |
361 // Ampersand is a valid character in an SSID, but menu2 uses it to mark | 353 // Ampersand is a valid character in an SSID, but menu2 uses it to mark |
362 // "mnemonics" for keyboard shortcuts. | 354 // "mnemonics" for keyboard shortcuts. |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
683 return main_menu_model_.get(); | 675 return main_menu_model_.get(); |
684 } | 676 } |
685 | 677 |
686 void NetworkMenu::UpdateMenu() { | 678 void NetworkMenu::UpdateMenu() { |
687 refreshing_menu_ = true; | 679 refreshing_menu_ = true; |
688 main_menu_model_->InitMenuItems(delegate_->ShouldOpenButtonOptions()); | 680 main_menu_model_->InitMenuItems(delegate_->ShouldOpenButtonOptions()); |
689 refreshing_menu_ = false; | 681 refreshing_menu_ = false; |
690 } | 682 } |
691 | 683 |
692 } // namespace chromeos | 684 } // namespace chromeos |
OLD | NEW |