| 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 "ash/system/chromeos/network/network_icon.h" | 9 #include "ash/system/chromeos/network/network_icon.h" |
| 10 #include "ash/system/chromeos/network/network_icon_animation.h" | 10 #include "ash/system/chromeos/network/network_icon_animation.h" |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 if (type == ui::MenuModel::TYPE_SEPARATOR) | 83 if (type == ui::MenuModel::TYPE_SEPARATOR) |
| 84 id = -2; | 84 id = -2; |
| 85 else | 85 else |
| 86 id = model->GetCommandIdAt(i); | 86 id = model->GetCommandIdAt(i); |
| 87 base::DictionaryValue* item = new base::DictionaryValue(); | 87 base::DictionaryValue* item = new base::DictionaryValue(); |
| 88 item->SetInteger("id", id); | 88 item->SetInteger("id", id); |
| 89 item->SetString("label", model->GetLabelAt(i)); | 89 item->SetString("label", model->GetLabelAt(i)); |
| 90 gfx::Image icon; | 90 gfx::Image icon; |
| 91 if (model->GetIconAt(i, &icon)) { | 91 if (model->GetIconAt(i, &icon)) { |
| 92 SkBitmap icon_bitmap = icon.ToImageSkia()->GetRepresentation( | 92 SkBitmap icon_bitmap = icon.ToImageSkia()->GetRepresentation( |
| 93 ui::GetImageScale( | 93 web_ui_->GetDeviceScaleFactor()).sk_bitmap(); |
| 94 web_ui_->GetDeviceScaleFactor())).sk_bitmap(); | |
| 95 item->SetString("icon", webui::GetBitmapDataUrl(icon_bitmap)); | 94 item->SetString("icon", webui::GetBitmapDataUrl(icon_bitmap)); |
| 96 } | 95 } |
| 97 if (id >= 0) { | 96 if (id >= 0) { |
| 98 item->SetBoolean("enabled", model->IsEnabledAt(i)); | 97 item->SetBoolean("enabled", model->IsEnabledAt(i)); |
| 99 const gfx::FontList* font_list = model->GetLabelFontListAt(i); | 98 const gfx::FontList* font_list = model->GetLabelFontListAt(i); |
| 100 if (font_list) | 99 if (font_list) |
| 101 item->SetBoolean("bold", font_list->GetFontStyle() == gfx::Font::BOLD); | 100 item->SetBoolean("bold", font_list->GetFontStyle() == gfx::Font::BOLD); |
| 102 } | 101 } |
| 103 if (type == ui::MenuModel::TYPE_SUBMENU) | 102 if (type == ui::MenuModel::TYPE_SUBMENU) |
| 104 item->Set("sub", ConvertMenuModel(model->GetSubmenuModelAt(i))); | 103 item->Set("sub", ConvertMenuModel(model->GetSubmenuModelAt(i))); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 bool animating = false; | 184 bool animating = false; |
| 186 ash::network_icon::GetDefaultNetworkImageAndLabel( | 185 ash::network_icon::GetDefaultNetworkImageAndLabel( |
| 187 ash::network_icon::ICON_TYPE_LIST, &icon_image, &text, &animating); | 186 ash::network_icon::ICON_TYPE_LIST, &icon_image, &text, &animating); |
| 188 if (animating) { | 187 if (animating) { |
| 189 ash::network_icon::NetworkIconAnimation::GetInstance()->AddObserver(this); | 188 ash::network_icon::NetworkIconAnimation::GetInstance()->AddObserver(this); |
| 190 } else { | 189 } else { |
| 191 ash::network_icon::NetworkIconAnimation::GetInstance()-> | 190 ash::network_icon::NetworkIconAnimation::GetInstance()-> |
| 192 RemoveObserver(this); | 191 RemoveObserver(this); |
| 193 } | 192 } |
| 194 SkBitmap icon_bitmap = icon_image.GetRepresentation( | 193 SkBitmap icon_bitmap = icon_image.GetRepresentation( |
| 195 ui::GetImageScale(web_ui_->GetDeviceScaleFactor())).sk_bitmap(); | 194 web_ui_->GetDeviceScaleFactor()).sk_bitmap(); |
| 196 std::string icon_str; | 195 std::string icon_str; |
| 197 if (!icon_image.isNull()) | 196 if (!icon_image.isNull()) |
| 198 icon_str = webui::GetBitmapDataUrl(icon_bitmap); | 197 icon_str = webui::GetBitmapDataUrl(icon_bitmap); |
| 199 base::StringValue title(text); | 198 base::StringValue title(text); |
| 200 base::StringValue icon(icon_str); | 199 base::StringValue icon(icon_str); |
| 201 web_ui_->CallJavascriptFunction("cr.ui.DropDown.updateNetworkTitle", | 200 web_ui_->CallJavascriptFunction("cr.ui.DropDown.updateNetworkTitle", |
| 202 title, icon); | 201 title, icon); |
| 203 } | 202 } |
| 204 | 203 |
| 205 void NetworkDropdown::RequestNetworkScan() { | 204 void NetworkDropdown::RequestNetworkScan() { |
| 206 NetworkHandler::Get()->network_state_handler()->RequestScan(); | 205 NetworkHandler::Get()->network_state_handler()->RequestScan(); |
| 207 Refresh(); | 206 Refresh(); |
| 208 } | 207 } |
| 209 | 208 |
| 210 } // namespace chromeos | 209 } // namespace chromeos |
| OLD | NEW |