| 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/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.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/chrome_switches.h" | 23 #include "chrome/common/chrome_switches.h" |
| 26 #include "chrome/common/pref_names.h" | |
| 27 #include "chrome/common/url_constants.h" | 24 #include "chrome/common/url_constants.h" |
| 28 #include "content/public/browser/browser_thread.h" | 25 #include "content/public/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" |
| (...skipping 875 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 912 // in CrosMock::SetNetworkLibraryStatusAreaExpectations(). | 909 // in CrosMock::SetNetworkLibraryStatusAreaExpectations(). |
| 913 | 910 |
| 914 menu_items_.clear(); | 911 menu_items_.clear(); |
| 915 MenuItemVector link_items; | 912 MenuItemVector link_items; |
| 916 MenuItemVector address_items; | 913 MenuItemVector address_items; |
| 917 | 914 |
| 918 NetworkLibrary* cros = CrosLibrary::Get()->GetNetworkLibrary(); | 915 NetworkLibrary* cros = CrosLibrary::Get()->GetNetworkLibrary(); |
| 919 bool oobe = !should_open_button_options; // we don't show options for OOBE. | 916 bool oobe = !should_open_button_options; // we don't show options for OOBE. |
| 920 bool connected = cros->Connected(); // always call for test expectations. | 917 bool connected = cros->Connected(); // always call for test expectations. |
| 921 if (!oobe) { | 918 if (!oobe) { |
| 922 int flags = FLAG_OPTIONS; | |
| 923 int message_id = -1; | 919 int message_id = -1; |
| 924 if (is_browser_mode) { | 920 if (is_browser_mode) |
| 925 message_id = IDS_STATUSBAR_NETWORK_OPEN_OPTIONS_DIALOG; | 921 message_id = IDS_STATUSBAR_NETWORK_OPEN_OPTIONS_DIALOG; |
| 926 } else if (connected) { | 922 else if (connected) |
| 927 const PrefService::Preference* proxy_pref = | 923 message_id = IDS_STATUSBAR_NETWORK_OPEN_PROXY_SETTINGS_DIALOG; |
| 928 ProfileManager::GetDefaultProfile()->GetPrefs()->FindPreference( | |
| 929 prefs::kProxy); | |
| 930 if (proxy_pref && (!proxy_pref->IsUserModifiable() || | |
| 931 proxy_pref->HasUserSetting())) { | |
| 932 flags |= FLAG_DISABLED; | |
| 933 if (proxy_pref->IsManaged()) { | |
| 934 message_id = | |
| 935 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_POLICY_MANAGED_PROXY_TEXT; | |
| 936 } else if (proxy_pref->IsExtensionControlled()) { | |
| 937 message_id = | |
| 938 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_EXTENSION_MANAGED_PROXY_TEXT; | |
| 939 } else { | |
| 940 message_id = | |
| 941 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_UNMODIFIABLE_PROXY_TEXT; | |
| 942 } | |
| 943 } else { | |
| 944 message_id = IDS_STATUSBAR_NETWORK_OPEN_PROXY_SETTINGS_DIALOG; | |
| 945 } | |
| 946 } | |
| 947 if (message_id != -1) { | 924 if (message_id != -1) { |
| 948 link_items.push_back(MenuItem(ui::MenuModel::TYPE_COMMAND, | 925 link_items.push_back(MenuItem(ui::MenuModel::TYPE_COMMAND, |
| 949 l10n_util::GetStringUTF16(message_id), | 926 l10n_util::GetStringUTF16(message_id), |
| 950 SkBitmap(), std::string(), flags)); | 927 SkBitmap(), std::string(), FLAG_OPTIONS)); |
| 951 } | 928 } |
| 952 } | 929 } |
| 953 | 930 |
| 954 if (connected) { | 931 if (connected) { |
| 955 std::string ip_address = cros->IPAddress(); | 932 std::string ip_address = cros->IPAddress(); |
| 956 if (!ip_address.empty()) { | 933 if (!ip_address.empty()) { |
| 957 address_items.push_back(MenuItem(ui::MenuModel::TYPE_COMMAND, | 934 address_items.push_back(MenuItem(ui::MenuModel::TYPE_COMMAND, |
| 958 ASCIIToUTF16(cros->IPAddress()), SkBitmap(), std::string(), | 935 ASCIIToUTF16(cros->IPAddress()), SkBitmap(), std::string(), |
| 959 FLAG_DISABLED)); | 936 FLAG_DISABLED)); |
| 960 } | 937 } |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1074 std::string page = StringPrintf( | 1051 std::string page = StringPrintf( |
| 1075 "%s?servicePath=%s&networkType=%d&networkName=%s", | 1052 "%s?servicePath=%s&networkType=%d&networkName=%s", |
| 1076 chrome::kInternetOptionsSubPage, | 1053 chrome::kInternetOptionsSubPage, |
| 1077 EscapeUrlEncodedData(network->service_path(), true).c_str(), | 1054 EscapeUrlEncodedData(network->service_path(), true).c_str(), |
| 1078 network->type(), | 1055 network->type(), |
| 1079 EscapeUrlEncodedData(network_name, false).c_str()); | 1056 EscapeUrlEncodedData(network_name, false).c_str()); |
| 1080 browser->ShowOptionsTab(page); | 1057 browser->ShowOptionsTab(page); |
| 1081 } | 1058 } |
| 1082 | 1059 |
| 1083 } // namespace chromeos | 1060 } // namespace chromeos |
| OLD | NEW |