| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/stringprintf.h" | 11 #include "base/stringprintf.h" |
| 12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
| 13 #include "chrome/browser/chromeos/choose_mobile_network_dialog.h" | 13 #include "chrome/browser/chromeos/choose_mobile_network_dialog.h" |
| 14 #include "chrome/browser/chromeos/cros/cros_library.h" | 14 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 15 #include "chrome/browser/chromeos/mobile_config.h" | 15 #include "chrome/browser/chromeos/mobile_config.h" |
| 16 #include "chrome/browser/chromeos/options/network_config_view.h" | 16 #include "chrome/browser/chromeos/options/network_config_view.h" |
| 17 #include "chrome/browser/chromeos/sim_dialog_delegate.h" | 17 #include "chrome/browser/chromeos/sim_dialog_delegate.h" |
| 18 #include "chrome/browser/chromeos/status/network_menu_icon.h" | 18 #include "chrome/browser/chromeos/status/network_menu_icon.h" |
| 19 #include "chrome/browser/defaults.h" | 19 #include "chrome/browser/defaults.h" |
| 20 #include "chrome/browser/prefs/pref_service.h" | |
| 21 #include "chrome/browser/profiles/profile_manager.h" | |
| 22 #include "chrome/browser/ui/browser.h" | 20 #include "chrome/browser/ui/browser.h" |
| 23 #include "chrome/browser/ui/browser_list.h" | 21 #include "chrome/browser/ui/browser_list.h" |
| 24 #include "chrome/browser/ui/views/window.h" | 22 #include "chrome/browser/ui/views/window.h" |
| 25 #include "chrome/common/url_constants.h" | 23 #include "chrome/common/url_constants.h" |
| 26 #include "chrome/common/chrome_switches.h" | 24 #include "chrome/common/chrome_switches.h" |
| 27 #include "chrome/common/pref_names.h" | |
| 28 #include "content/browser/browser_thread.h" | 25 #include "content/browser/browser_thread.h" |
| 29 #include "grit/generated_resources.h" | 26 #include "grit/generated_resources.h" |
| 30 #include "grit/theme_resources.h" | 27 #include "grit/theme_resources.h" |
| 31 #include "net/base/escape.h" | 28 #include "net/base/escape.h" |
| 32 #include "third_party/skia/include/core/SkBitmap.h" | 29 #include "third_party/skia/include/core/SkBitmap.h" |
| 33 #include "ui/base/l10n/l10n_util.h" | 30 #include "ui/base/l10n/l10n_util.h" |
| 34 #include "ui/base/models/menu_model.h" | 31 #include "ui/base/models/menu_model.h" |
| 35 #include "ui/base/resource/resource_bundle.h" | 32 #include "ui/base/resource/resource_bundle.h" |
| 36 #include "ui/gfx/canvas_skia.h" | 33 #include "ui/gfx/canvas_skia.h" |
| 37 #include "ui/gfx/skbitmap_operations.h" | 34 #include "ui/gfx/skbitmap_operations.h" |
| (...skipping 865 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 903 // in CrosMock::SetNetworkLibraryStatusAreaExpectations(). | 900 // in CrosMock::SetNetworkLibraryStatusAreaExpectations(). |
| 904 | 901 |
| 905 menu_items_.clear(); | 902 menu_items_.clear(); |
| 906 MenuItemVector link_items; | 903 MenuItemVector link_items; |
| 907 MenuItemVector address_items; | 904 MenuItemVector address_items; |
| 908 | 905 |
| 909 NetworkLibrary* cros = CrosLibrary::Get()->GetNetworkLibrary(); | 906 NetworkLibrary* cros = CrosLibrary::Get()->GetNetworkLibrary(); |
| 910 bool oobe = !should_open_button_options; // we don't show options for OOBE. | 907 bool oobe = !should_open_button_options; // we don't show options for OOBE. |
| 911 bool connected = cros->Connected(); // always call for test expectations. | 908 bool connected = cros->Connected(); // always call for test expectations. |
| 912 if (!oobe) { | 909 if (!oobe) { |
| 913 int flags = FLAG_OPTIONS; | |
| 914 int message_id = -1; | 910 int message_id = -1; |
| 915 if (is_browser_mode) { | 911 if (is_browser_mode) |
| 916 message_id = IDS_STATUSBAR_NETWORK_OPEN_OPTIONS_DIALOG; | 912 message_id = IDS_STATUSBAR_NETWORK_OPEN_OPTIONS_DIALOG; |
| 917 } else if (connected) { | 913 else if (connected) |
| 918 const PrefService::Preference* proxy_pref = | 914 message_id = IDS_STATUSBAR_NETWORK_OPEN_PROXY_SETTINGS_DIALOG; |
| 919 ProfileManager::GetDefaultProfile()->GetPrefs()->FindPreference( | |
| 920 prefs::kProxy); | |
| 921 if (proxy_pref && (!proxy_pref->IsUserModifiable() || | |
| 922 proxy_pref->HasUserSetting())) { | |
| 923 flags |= FLAG_DISABLED; | |
| 924 if (proxy_pref->IsManaged()) { | |
| 925 message_id = | |
| 926 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_POLICY_MANAGED_PROXY_TEXT; | |
| 927 } else if (proxy_pref->IsExtensionControlled()) { | |
| 928 message_id = | |
| 929 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_EXTENSION_MANAGED_PROXY_TEXT; | |
| 930 } else { | |
| 931 message_id = | |
| 932 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_UNMODIFIABLE_PROXY_TEXT; | |
| 933 } | |
| 934 } else { | |
| 935 message_id = IDS_STATUSBAR_NETWORK_OPEN_PROXY_SETTINGS_DIALOG; | |
| 936 } | |
| 937 } | |
| 938 if (message_id != -1) { | 915 if (message_id != -1) { |
| 939 link_items.push_back(MenuItem(ui::MenuModel::TYPE_COMMAND, | 916 link_items.push_back(MenuItem(ui::MenuModel::TYPE_COMMAND, |
| 940 l10n_util::GetStringUTF16(message_id), | 917 l10n_util::GetStringUTF16(message_id), |
| 941 SkBitmap(), std::string(), flags)); | 918 SkBitmap(), std::string(), FLAG_OPTIONS)); |
| 942 } | 919 } |
| 943 } | 920 } |
| 944 | 921 |
| 945 if (connected) { | 922 if (connected) { |
| 946 std::string ip_address = cros->IPAddress(); | 923 std::string ip_address = cros->IPAddress(); |
| 947 if (!ip_address.empty()) { | 924 if (!ip_address.empty()) { |
| 948 address_items.push_back(MenuItem(ui::MenuModel::TYPE_COMMAND, | 925 address_items.push_back(MenuItem(ui::MenuModel::TYPE_COMMAND, |
| 949 ASCIIToUTF16(cros->IPAddress()), SkBitmap(), std::string(), | 926 ASCIIToUTF16(cros->IPAddress()), SkBitmap(), std::string(), |
| 950 FLAG_DISABLED)); | 927 FLAG_DISABLED)); |
| 951 } | 928 } |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1065 std::string page = StringPrintf( | 1042 std::string page = StringPrintf( |
| 1066 "%s?servicePath=%s&networkType=%d&networkName=%s", | 1043 "%s?servicePath=%s&networkType=%d&networkName=%s", |
| 1067 chrome::kInternetOptionsSubPage, | 1044 chrome::kInternetOptionsSubPage, |
| 1068 EscapeUrlEncodedData(network->service_path(), true).c_str(), | 1045 EscapeUrlEncodedData(network->service_path(), true).c_str(), |
| 1069 network->type(), | 1046 network->type(), |
| 1070 EscapeUrlEncodedData(network_name, false).c_str()); | 1047 EscapeUrlEncodedData(network_name, false).c_str()); |
| 1071 browser->ShowOptionsTab(page); | 1048 browser->ShowOptionsTab(page); |
| 1072 } | 1049 } |
| 1073 | 1050 |
| 1074 } // namespace chromeos | 1051 } // namespace chromeos |
| OLD | NEW |