| 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/time.h" | 9 #include "base/time.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| 11 #include "chrome/browser/chromeos/cros/cros_library.h" | 11 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 12 #include "chrome/browser/chromeos/login/base_login_display_host.h" | 12 #include "chrome/browser/chromeos/login/base_login_display_host.h" |
| 13 #include "chrome/browser/chromeos/login/login_display_host.h" | 13 #include "chrome/browser/chromeos/login/login_display_host.h" |
| 14 #include "chrome/browser/ui/webui/web_ui_util.h" | 14 #include "chrome/browser/ui/webui/web_ui_util.h" |
| 15 #include "content/public/browser/web_ui.h" | 15 #include "content/public/browser/web_ui.h" |
| 16 #include "ui/base/models/menu_model.h" | 16 #include "ui/base/models/menu_model.h" |
| 17 #include "ui/gfx/font.h" | 17 #include "ui/gfx/font.h" |
| 18 #include "ui/gfx/image/image.h" |
| 18 #include "ui/gfx/image/image_skia.h" | 19 #include "ui/gfx/image/image_skia.h" |
| 19 | 20 |
| 20 namespace { | 21 namespace { |
| 21 | 22 |
| 22 // Timeout between consecutive requests to network library for network | 23 // Timeout between consecutive requests to network library for network |
| 23 // scan. | 24 // scan. |
| 24 const int kNetworkScanIntervalSecs = 60; | 25 const int kNetworkScanIntervalSecs = 60; |
| 25 | 26 |
| 26 } // namespace | 27 } // namespace |
| 27 | 28 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 for (int i = 0; i < model->GetItemCount(); ++i) { | 78 for (int i = 0; i < model->GetItemCount(); ++i) { |
| 78 ui::MenuModel::ItemType type = model->GetTypeAt(i); | 79 ui::MenuModel::ItemType type = model->GetTypeAt(i); |
| 79 int id; | 80 int id; |
| 80 if (type == ui::MenuModel::TYPE_SEPARATOR) | 81 if (type == ui::MenuModel::TYPE_SEPARATOR) |
| 81 id = -2; | 82 id = -2; |
| 82 else | 83 else |
| 83 id = model->GetCommandIdAt(i); | 84 id = model->GetCommandIdAt(i); |
| 84 base::DictionaryValue* item = new base::DictionaryValue(); | 85 base::DictionaryValue* item = new base::DictionaryValue(); |
| 85 item->SetInteger("id", id); | 86 item->SetInteger("id", id); |
| 86 item->SetString("label", model->GetLabelAt(i)); | 87 item->SetString("label", model->GetLabelAt(i)); |
| 87 gfx::ImageSkia icon; | 88 gfx::Image icon; |
| 88 if (model->GetIconAt(i, &icon)) { | 89 if (model->GetIconAt(i, &icon)) { |
| 89 SkBitmap icon_bitmap = icon.GetRepresentation( | 90 SkBitmap icon_bitmap = icon.ToImageSkia()->GetRepresentation( |
| 90 ui::GetScaleFactorFromScale(web_ui_->GetDeviceScale())).sk_bitmap(); | 91 ui::GetScaleFactorFromScale(web_ui_->GetDeviceScale())).sk_bitmap(); |
| 91 item->SetString("icon", web_ui_util::GetImageDataUrl(icon_bitmap)); | 92 item->SetString("icon", web_ui_util::GetImageDataUrl(icon_bitmap)); |
| 92 } | 93 } |
| 93 if (id >= 0) { | 94 if (id >= 0) { |
| 94 item->SetBoolean("enabled", model->IsEnabledAt(i)); | 95 item->SetBoolean("enabled", model->IsEnabledAt(i)); |
| 95 const gfx::Font* font = model->GetLabelFontAt(i); | 96 const gfx::Font* font = model->GetLabelFontAt(i); |
| 96 if (font) { | 97 if (font) { |
| 97 item->SetBoolean("bold", font->GetStyle() == gfx::Font::BOLD); | 98 item->SetBoolean("bold", font->GetStyle() == gfx::Font::BOLD); |
| 98 } | 99 } |
| 99 } | 100 } |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 web_ui_->CallJavascriptFunction("cr.ui.DropDown.updateNetworkTitle", | 172 web_ui_->CallJavascriptFunction("cr.ui.DropDown.updateNetworkTitle", |
| 172 title, icon); | 173 title, icon); |
| 173 } | 174 } |
| 174 | 175 |
| 175 void NetworkDropdown::ForceNetworkScan() { | 176 void NetworkDropdown::ForceNetworkScan() { |
| 176 CrosLibrary::Get()->GetNetworkLibrary()->RequestNetworkScan(); | 177 CrosLibrary::Get()->GetNetworkLibrary()->RequestNetworkScan(); |
| 177 Refresh(); | 178 Refresh(); |
| 178 } | 179 } |
| 179 | 180 |
| 180 } // namespace chromeos | 181 } // namespace chromeos |
| OLD | NEW |