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/ui/webui/chromeos/login/network_dropdown.h" | 5 #include "chrome/browser/ui/webui/chromeos/login/network_dropdown.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "chrome/browser/chromeos/cros/cros_library.h" | 10 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 11 #include "chrome/browser/chromeos/login/base_login_display_host.h" |
11 #include "chrome/browser/chromeos/login/proxy_settings_dialog.h" | 12 #include "chrome/browser/chromeos/login/proxy_settings_dialog.h" |
12 #include "chrome/browser/ui/webui/web_ui_util.h" | 13 #include "chrome/browser/ui/webui/web_ui_util.h" |
13 #include "content/browser/webui/web_ui.h" | 14 #include "content/browser/webui/web_ui.h" |
14 #include "ui/base/models/menu_model.h" | 15 #include "ui/base/models/menu_model.h" |
15 #include "ui/gfx/font.h" | 16 #include "ui/gfx/font.h" |
16 | 17 |
17 namespace chromeos { | 18 namespace chromeos { |
18 | 19 |
19 // WebUI specific implementation of the NetworkMenu class. | 20 // WebUI specific implementation of the NetworkMenu class. |
20 class NetworkMenuWebUI : public NetworkMenu { | 21 class NetworkMenuWebUI : public NetworkMenu { |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 if (type == ui::MenuModel::TYPE_SUBMENU) | 87 if (type == ui::MenuModel::TYPE_SUBMENU) |
87 item->Set("sub", ConvertMenuModel(model->GetSubmenuModelAt(i))); | 88 item->Set("sub", ConvertMenuModel(model->GetSubmenuModelAt(i))); |
88 list->Append(item); | 89 list->Append(item); |
89 } | 90 } |
90 return list; | 91 return list; |
91 } | 92 } |
92 | 93 |
93 // NetworkDropdown ------------------------------------------------------------- | 94 // NetworkDropdown ------------------------------------------------------------- |
94 | 95 |
95 NetworkDropdown::NetworkDropdown(WebUI* web_ui, | 96 NetworkDropdown::NetworkDropdown(WebUI* web_ui, |
96 gfx::NativeWindow parent_window, | |
97 bool oobe) | 97 bool oobe) |
98 : parent_window_(parent_window), | 98 : web_ui_(web_ui), |
99 web_ui_(web_ui), | |
100 oobe_(oobe) { | 99 oobe_(oobe) { |
101 network_menu_.reset(new NetworkMenuWebUI(this, web_ui)); | 100 network_menu_.reset(new NetworkMenuWebUI(this, web_ui)); |
102 network_icon_.reset( | 101 network_icon_.reset( |
103 new NetworkMenuIcon(this, NetworkMenuIcon::DROPDOWN_MODE)); | 102 new NetworkMenuIcon(this, NetworkMenuIcon::DROPDOWN_MODE)); |
104 CrosLibrary::Get()->GetNetworkLibrary()->AddNetworkManagerObserver(this); | 103 CrosLibrary::Get()->GetNetworkLibrary()->AddNetworkManagerObserver(this); |
105 Refresh(); | 104 Refresh(); |
106 } | 105 } |
107 | 106 |
108 NetworkDropdown::~NetworkDropdown() { | 107 NetworkDropdown::~NetworkDropdown() { |
109 CrosLibrary::Get()->GetNetworkLibrary()->RemoveNetworkManagerObserver(this); | 108 CrosLibrary::Get()->GetNetworkLibrary()->RemoveNetworkManagerObserver(this); |
110 } | 109 } |
111 | 110 |
112 void NetworkDropdown::SetLastNetworkType(ConnectionType last_network_type) { | 111 void NetworkDropdown::SetLastNetworkType(ConnectionType last_network_type) { |
113 network_icon_->set_last_network_type(last_network_type); | 112 network_icon_->set_last_network_type(last_network_type); |
114 } | 113 } |
115 | 114 |
116 void NetworkDropdown::OnItemChosen(int id) { | 115 void NetworkDropdown::OnItemChosen(int id) { |
117 network_menu_->OnItemChosen(id); | 116 network_menu_->OnItemChosen(id); |
118 } | 117 } |
119 | 118 |
120 views::MenuButton* NetworkDropdown::GetMenuButton() { | 119 views::MenuButton* NetworkDropdown::GetMenuButton() { |
121 NOTREACHED(); | 120 NOTREACHED(); |
122 return NULL; | 121 return NULL; |
123 } | 122 } |
124 | 123 |
125 gfx::NativeWindow NetworkDropdown::GetNativeWindow() const { | 124 gfx::NativeWindow NetworkDropdown::GetNativeWindow() const { |
126 return parent_window_; | 125 return BaseLoginDisplayHost::default_host()->GetNativeWindow(); |
127 } | 126 } |
128 | 127 |
129 void NetworkDropdown::OpenButtonOptions() { | 128 void NetworkDropdown::OpenButtonOptions() { |
130 if (proxy_settings_dialog_.get() == NULL) { | 129 if (proxy_settings_dialog_.get() == NULL) { |
131 proxy_settings_dialog_.reset( | 130 proxy_settings_dialog_.reset( |
132 new ProxySettingsDialog(this, GetNativeWindow())); | 131 new ProxySettingsDialog(this, GetNativeWindow())); |
133 } | 132 } |
134 proxy_settings_dialog_->Show(); | 133 proxy_settings_dialog_->Show(); |
135 } | 134 } |
136 | 135 |
(...skipping 23 matching lines...) Expand all Loading... |
160 std::string icon_str = | 159 std::string icon_str = |
161 icon_bitmap.empty() ? | 160 icon_bitmap.empty() ? |
162 std::string() : web_ui_util::GetImageDataUrl(icon_bitmap); | 161 std::string() : web_ui_util::GetImageDataUrl(icon_bitmap); |
163 base::StringValue title(text); | 162 base::StringValue title(text); |
164 base::StringValue icon(icon_str); | 163 base::StringValue icon(icon_str); |
165 web_ui_->CallJavascriptFunction("cr.ui.DropDown.updateNetworkTitle", | 164 web_ui_->CallJavascriptFunction("cr.ui.DropDown.updateNetworkTitle", |
166 title, icon); | 165 title, icon); |
167 } | 166 } |
168 | 167 |
169 } // namespace chromeos | 168 } // namespace chromeos |
OLD | NEW |