OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_button.h" | 5 #include "chrome/browser/chromeos/status/network_menu_button.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
10 #include "app/resource_bundle.h" | 10 #include "app/resource_bundle.h" |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 } else if (flags & FLAG_TOGGLE_ETHERNET) { | 93 } else if (flags & FLAG_TOGGLE_ETHERNET) { |
94 cros->EnableEthernetNetworkDevice(!cros->ethernet_enabled()); | 94 cros->EnableEthernetNetworkDevice(!cros->ethernet_enabled()); |
95 } else if (flags & FLAG_TOGGLE_WIFI) { | 95 } else if (flags & FLAG_TOGGLE_WIFI) { |
96 cros->EnableWifiNetworkDevice(!cros->wifi_enabled()); | 96 cros->EnableWifiNetworkDevice(!cros->wifi_enabled()); |
97 } else if (flags & FLAG_TOGGLE_CELLULAR) { | 97 } else if (flags & FLAG_TOGGLE_CELLULAR) { |
98 cros->EnableCellularNetworkDevice(!cros->cellular_enabled()); | 98 cros->EnableCellularNetworkDevice(!cros->cellular_enabled()); |
99 } else if (flags & FLAG_TOGGLE_OFFLINE) { | 99 } else if (flags & FLAG_TOGGLE_OFFLINE) { |
100 cros->EnableOfflineMode(!cros->offline_mode()); | 100 cros->EnableOfflineMode(!cros->offline_mode()); |
101 } else if (flags & FLAG_OTHER_NETWORK) { | 101 } else if (flags & FLAG_OTHER_NETWORK) { |
102 NetworkConfigView* view = new NetworkConfigView(); | 102 NetworkConfigView* view = new NetworkConfigView(); |
| 103 view->set_browser_mode(host_->IsBrowserMode()); |
103 views::Window* window = views::Window::CreateChromeWindow( | 104 views::Window* window = views::Window::CreateChromeWindow( |
104 host_->GetNativeWindow(), gfx::Rect(), view); | 105 host_->GetNativeWindow(), gfx::Rect(), view); |
105 window->SetIsAlwaysOnTop(true); | 106 window->SetIsAlwaysOnTop(true); |
106 window->Show(); | 107 window->Show(); |
107 view->SetLoginTextfieldFocus(); | 108 view->SetLoginTextfieldFocus(); |
108 } else if (flags & FLAG_ETHERNET) { | 109 } else if (flags & FLAG_ETHERNET) { |
109 if (cros->ethernet_connected()) { | 110 if (cros->ethernet_connected()) { |
110 NetworkConfigView* view = new NetworkConfigView(cros->ethernet_network()); | 111 NetworkConfigView* view = new NetworkConfigView(cros->ethernet_network()); |
| 112 view->set_browser_mode(host_->IsBrowserMode()); |
111 views::Window* window = views::Window::CreateChromeWindow( | 113 views::Window* window = views::Window::CreateChromeWindow( |
112 host_->GetNativeWindow(), gfx::Rect(), view); | 114 host_->GetNativeWindow(), gfx::Rect(), view); |
113 window->SetIsAlwaysOnTop(true); | 115 window->SetIsAlwaysOnTop(true); |
114 window->Show(); | 116 window->Show(); |
115 } | 117 } |
116 } else if (flags & FLAG_WIFI) { | 118 } else if (flags & FLAG_WIFI) { |
117 WifiNetwork wifi = menu_items_[index].wifi_network; | 119 WifiNetwork wifi = menu_items_[index].wifi_network; |
118 | 120 |
119 // If clicked on a network that we are already connected to or we are | 121 // If clicked on a network that we are already connected to or we are |
120 // currently trying to connect to, then open config dialog. | 122 // currently trying to connect to, then open config dialog. |
121 if (wifi.name() == cros->wifi_name()) { | 123 if (wifi.name() == cros->wifi_name()) { |
122 if (cros->wifi_connected()) { | 124 if (cros->wifi_connected()) { |
123 NetworkConfigView* view = new NetworkConfigView(wifi, false); | 125 NetworkConfigView* view = new NetworkConfigView(wifi, false); |
| 126 view->set_browser_mode(host_->IsBrowserMode()); |
124 views::Window* window = views::Window::CreateChromeWindow( | 127 views::Window* window = views::Window::CreateChromeWindow( |
125 host_->GetNativeWindow(), gfx::Rect(), view); | 128 host_->GetNativeWindow(), gfx::Rect(), view); |
126 window->SetIsAlwaysOnTop(true); | 129 window->SetIsAlwaysOnTop(true); |
127 window->Show(); | 130 window->Show(); |
128 } | 131 } |
129 } else { | 132 } else { |
130 // If wifi network is not encrypted, then directly connect. | 133 // If wifi network is not encrypted, then directly connect. |
131 // Otherwise, we open password dialog window. | 134 // Otherwise, we open password dialog window. |
132 if (!wifi.encrypted()) { | 135 if (!wifi.encrypted()) { |
133 cros->ConnectToWifiNetwork(wifi, string16(), string16(), string16()); | 136 cros->ConnectToWifiNetwork(wifi, string16(), string16(), string16()); |
134 } else { | 137 } else { |
135 NetworkConfigView* view = new NetworkConfigView(wifi, true); | 138 NetworkConfigView* view = new NetworkConfigView(wifi, true); |
| 139 view->set_browser_mode(host_->IsBrowserMode()); |
136 views::Window* window = views::Window::CreateChromeWindow( | 140 views::Window* window = views::Window::CreateChromeWindow( |
137 host_->GetNativeWindow(), gfx::Rect(), view); | 141 host_->GetNativeWindow(), gfx::Rect(), view); |
138 window->SetIsAlwaysOnTop(true); | 142 window->SetIsAlwaysOnTop(true); |
139 window->Show(); | 143 window->Show(); |
140 view->SetLoginTextfieldFocus(); | 144 view->SetLoginTextfieldFocus(); |
141 } | 145 } |
142 } | 146 } |
143 } else if (flags & FLAG_CELLULAR) { | 147 } else if (flags & FLAG_CELLULAR) { |
144 CellularNetwork cellular = menu_items_[index].cellular_network; | 148 CellularNetwork cellular = menu_items_[index].cellular_network; |
145 | 149 |
146 // If clicked on a network that we are already connected to or we are | 150 // If clicked on a network that we are already connected to or we are |
147 // currently trying to connect to, then open config dialog. | 151 // currently trying to connect to, then open config dialog. |
148 if (cellular.name() == cros->cellular_name()) { | 152 if (cellular.name() == cros->cellular_name()) { |
149 if (cros->cellular_connected()) { | 153 if (cros->cellular_connected()) { |
150 NetworkConfigView* view = new NetworkConfigView(cellular); | 154 NetworkConfigView* view = new NetworkConfigView(cellular); |
| 155 view->set_browser_mode(host_->IsBrowserMode()); |
151 views::Window* window = views::Window::CreateChromeWindow( | 156 views::Window* window = views::Window::CreateChromeWindow( |
152 host_->GetNativeWindow(), gfx::Rect(), view); | 157 host_->GetNativeWindow(), gfx::Rect(), view); |
153 window->SetIsAlwaysOnTop(true); | 158 window->SetIsAlwaysOnTop(true); |
154 window->Show(); | 159 window->Show(); |
155 } | 160 } |
156 } else { | 161 } else { |
157 cros->ConnectToCellularNetwork(cellular); | 162 cros->ConnectToCellularNetwork(cellular); |
158 } | 163 } |
159 } | 164 } |
160 } | 165 } |
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
511 if (host_->ShouldOpenButtonOptions(this)) { | 516 if (host_->ShouldOpenButtonOptions(this)) { |
512 label = | 517 label = |
513 l10n_util::GetStringUTF16(IDS_STATUSBAR_NETWORK_OPEN_OPTIONS_DIALOG); | 518 l10n_util::GetStringUTF16(IDS_STATUSBAR_NETWORK_OPEN_OPTIONS_DIALOG); |
514 menu_items_.push_back(MenuItem(menus::MenuModel::TYPE_COMMAND, label, | 519 menu_items_.push_back(MenuItem(menus::MenuModel::TYPE_COMMAND, label, |
515 SkBitmap(), WifiNetwork(), CellularNetwork(), FLAG_OPTIONS)); | 520 SkBitmap(), WifiNetwork(), CellularNetwork(), FLAG_OPTIONS)); |
516 } | 521 } |
517 } | 522 } |
518 } | 523 } |
519 | 524 |
520 } // namespace chromeos | 525 } // namespace chromeos |
OLD | NEW |