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" |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 if (type == ui::MenuModel::TYPE_SUBMENU) | 86 if (type == ui::MenuModel::TYPE_SUBMENU) |
87 item->Set("sub", ConvertMenuModel(model->GetSubmenuModelAt(i))); | 87 item->Set("sub", ConvertMenuModel(model->GetSubmenuModelAt(i))); |
88 list->Append(item); | 88 list->Append(item); |
89 } | 89 } |
90 return list; | 90 return list; |
91 } | 91 } |
92 | 92 |
93 // NetworkDropdown ------------------------------------------------------------- | 93 // NetworkDropdown ------------------------------------------------------------- |
94 | 94 |
95 NetworkDropdown::NetworkDropdown(WebUI* web_ui, | 95 NetworkDropdown::NetworkDropdown(WebUI* web_ui, |
96 gfx::NativeWindow parent_window, bool oobe) | 96 gfx::NativeWindow parent_window, |
| 97 bool oobe) |
97 : parent_window_(parent_window), | 98 : parent_window_(parent_window), |
98 web_ui_(web_ui), | 99 web_ui_(web_ui), |
99 oobe_(oobe) { | 100 oobe_(oobe) { |
100 network_menu_.reset(new NetworkMenuWebUI(this, web_ui)); | 101 network_menu_.reset(new NetworkMenuWebUI(this, web_ui)); |
101 network_icon_.reset( | 102 network_icon_.reset( |
102 new NetworkMenuIcon(this, NetworkMenuIcon::DROPDOWN_MODE)); | 103 new NetworkMenuIcon(this, NetworkMenuIcon::DROPDOWN_MODE)); |
103 CrosLibrary::Get()->GetNetworkLibrary()->AddNetworkManagerObserver(this); | 104 CrosLibrary::Get()->GetNetworkLibrary()->AddNetworkManagerObserver(this); |
104 Refresh(); | 105 Refresh(); |
105 } | 106 } |
106 | 107 |
107 NetworkDropdown::~NetworkDropdown() { | 108 NetworkDropdown::~NetworkDropdown() { |
108 CrosLibrary::Get()->GetNetworkLibrary()->RemoveNetworkManagerObserver(this); | 109 CrosLibrary::Get()->GetNetworkLibrary()->RemoveNetworkManagerObserver(this); |
109 } | 110 } |
110 | 111 |
| 112 void NetworkDropdown::SetLastNetworkType(ConnectionType last_network_type) { |
| 113 network_icon_->set_last_network_type(last_network_type); |
| 114 } |
| 115 |
111 void NetworkDropdown::OnItemChosen(int id) { | 116 void NetworkDropdown::OnItemChosen(int id) { |
112 network_menu_->OnItemChosen(id); | 117 network_menu_->OnItemChosen(id); |
113 } | 118 } |
114 | 119 |
115 views::MenuButton* NetworkDropdown::GetMenuButton() { | 120 views::MenuButton* NetworkDropdown::GetMenuButton() { |
116 NOTREACHED(); | 121 NOTREACHED(); |
117 return NULL; | 122 return NULL; |
118 } | 123 } |
119 | 124 |
120 gfx::NativeWindow NetworkDropdown::GetNativeWindow() const { | 125 gfx::NativeWindow NetworkDropdown::GetNativeWindow() const { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 std::string icon_str = | 160 std::string icon_str = |
156 icon_bitmap.empty() ? | 161 icon_bitmap.empty() ? |
157 std::string() : web_ui_util::GetImageDataUrl(icon_bitmap); | 162 std::string() : web_ui_util::GetImageDataUrl(icon_bitmap); |
158 base::StringValue title(text); | 163 base::StringValue title(text); |
159 base::StringValue icon(icon_str); | 164 base::StringValue icon(icon_str); |
160 web_ui_->CallJavascriptFunction("cr.ui.DropDown.updateNetworkTitle", | 165 web_ui_->CallJavascriptFunction("cr.ui.DropDown.updateNetworkTitle", |
161 title, icon); | 166 title, icon); |
162 } | 167 } |
163 | 168 |
164 } // namespace chromeos | 169 } // namespace chromeos |
OLD | NEW |