| 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 owner_->delegate()->OnConnectToNetworkRequested(service_path); | 224 owner_->delegate()->OnConnectToNetworkRequested(service_path); |
| 226 if (result == network_connect::NETWORK_NOT_FOUND) { | |
| 227 // If we are attempting to connect to a network that no longer exists, | |
| 228 // display a notification. | |
| 229 LOG(WARNING) << "Network does not exist to connect to: " | |
| 230 << service_path; | |
| 231 // TODO(stevenjb): Show notification. | |
| 232 } | |
| 233 } | 225 } |
| 234 | 226 |
| 235 //////////////////////////////////////////////////////////////////////////////// | 227 //////////////////////////////////////////////////////////////////////////////// |
| 236 // NetworkMenuModel, ui::MenuModel implementation: | 228 // NetworkMenuModel, ui::MenuModel implementation: |
| 237 | 229 |
| 238 bool NetworkMenuModel::HasIcons() const { | 230 bool NetworkMenuModel::HasIcons() const { |
| 239 return true; | 231 return true; |
| 240 } | 232 } |
| 241 | 233 |
| 242 int NetworkMenuModel::GetItemCount() const { | 234 int NetworkMenuModel::GetItemCount() const { |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 } | 335 } |
| 344 | 336 |
| 345 //////////////////////////////////////////////////////////////////////////////// | 337 //////////////////////////////////////////////////////////////////////////////// |
| 346 // NetworkMenuModel, private methods: | 338 // NetworkMenuModel, private methods: |
| 347 | 339 |
| 348 void NetworkMenuModel::ShowOther(const std::string& type) const { | 340 void NetworkMenuModel::ShowOther(const std::string& type) const { |
| 349 gfx::NativeWindow native_window = owner_->delegate()->GetNativeWindow(); | 341 gfx::NativeWindow native_window = owner_->delegate()->GetNativeWindow(); |
| 350 if (type == flimflam::kTypeCellular) | 342 if (type == flimflam::kTypeCellular) |
| 351 ChooseMobileNetworkDialog::ShowDialog(native_window); | 343 ChooseMobileNetworkDialog::ShowDialog(native_window); |
| 352 else | 344 else |
| 353 NetworkConfigView::ShowForType(chromeos::TYPE_WIFI, native_window); | 345 NetworkConfigView::ShowForType(flimflam::kTypeWifi, native_window); |
| 354 } | 346 } |
| 355 | 347 |
| 356 //////////////////////////////////////////////////////////////////////////////// | 348 //////////////////////////////////////////////////////////////////////////////// |
| 357 // MainMenuModel | 349 // MainMenuModel |
| 358 | 350 |
| 359 void MainMenuModel::AddWirelessNetworkMenuItem(const NetworkState* network, | 351 void MainMenuModel::AddWirelessNetworkMenuItem(const NetworkState* network, |
| 360 int flag) { | 352 int flag) { |
| 361 string16 label; | 353 string16 label; |
| 362 // Ampersand is a valid character in an SSID, but menu2 uses it to mark | 354 // Ampersand is a valid character in an SSID, but menu2 uses it to mark |
| 363 // "mnemonics" for keyboard shortcuts. | 355 // "mnemonics" for keyboard shortcuts. |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 687 return main_menu_model_.get(); | 679 return main_menu_model_.get(); |
| 688 } | 680 } |
| 689 | 681 |
| 690 void NetworkMenu::UpdateMenu() { | 682 void NetworkMenu::UpdateMenu() { |
| 691 refreshing_menu_ = true; | 683 refreshing_menu_ = true; |
| 692 main_menu_model_->InitMenuItems(delegate_->ShouldOpenButtonOptions()); | 684 main_menu_model_->InitMenuItems(delegate_->ShouldOpenButtonOptions()); |
| 693 refreshing_menu_ = false; | 685 refreshing_menu_ = false; |
| 694 } | 686 } |
| 695 | 687 |
| 696 } // namespace chromeos | 688 } // namespace chromeos |
| OLD | NEW |