OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 for (int i = 0; i < model->GetItemCount(); ++i) { | 82 for (int i = 0; i < model->GetItemCount(); ++i) { |
83 ui::MenuModel::ItemType type = model->GetTypeAt(i); | 83 ui::MenuModel::ItemType type = model->GetTypeAt(i); |
84 int id; | 84 int id; |
85 if (type == ui::MenuModel::TYPE_SEPARATOR) | 85 if (type == ui::MenuModel::TYPE_SEPARATOR) |
86 id = -2; | 86 id = -2; |
87 else | 87 else |
88 id = model->GetCommandIdAt(i); | 88 id = model->GetCommandIdAt(i); |
89 base::DictionaryValue* item = new base::DictionaryValue(); | 89 base::DictionaryValue* item = new base::DictionaryValue(); |
90 item->SetInteger("id", id); | 90 item->SetInteger("id", id); |
91 base::string16 label = model->GetLabelAt(i); | 91 base::string16 label = model->GetLabelAt(i); |
92 ReplaceSubstringsAfterOffset(&label, 0, base::ASCIIToUTF16("&&"), | 92 base::ReplaceSubstringsAfterOffset(&label, 0, base::ASCIIToUTF16("&&"), |
93 base::ASCIIToUTF16("&")); | 93 base::ASCIIToUTF16("&")); |
94 item->SetString("label", label); | 94 item->SetString("label", label); |
95 gfx::Image icon; | 95 gfx::Image icon; |
96 if (model->GetIconAt(i, &icon)) { | 96 if (model->GetIconAt(i, &icon)) { |
97 SkBitmap icon_bitmap = icon.ToImageSkia()->GetRepresentation( | 97 SkBitmap icon_bitmap = icon.ToImageSkia()->GetRepresentation( |
98 web_ui_->GetDeviceScaleFactor()).sk_bitmap(); | 98 web_ui_->GetDeviceScaleFactor()).sk_bitmap(); |
99 item->SetString("icon", webui::GetBitmapDataUrl(icon_bitmap)); | 99 item->SetString("icon", webui::GetBitmapDataUrl(icon_bitmap)); |
100 } | 100 } |
101 if (id >= 0) { | 101 if (id >= 0) { |
102 item->SetBoolean("enabled", model->IsEnabledAt(i)); | 102 item->SetBoolean("enabled", model->IsEnabledAt(i)); |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 web_ui_->CallJavascriptFunction("cr.ui.DropDown.updateNetworkTitle", | 203 web_ui_->CallJavascriptFunction("cr.ui.DropDown.updateNetworkTitle", |
204 title, icon); | 204 title, icon); |
205 } | 205 } |
206 | 206 |
207 void NetworkDropdown::RequestNetworkScan() { | 207 void NetworkDropdown::RequestNetworkScan() { |
208 NetworkHandler::Get()->network_state_handler()->RequestScan(); | 208 NetworkHandler::Get()->network_state_handler()->RequestScan(); |
209 Refresh(); | 209 Refresh(); |
210 } | 210 } |
211 | 211 |
212 } // namespace chromeos | 212 } // namespace chromeos |
OLD | NEW |