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" |
11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
12 #include "base/values.h" | 12 #include "base/values.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/chromeos/login/login_display_host_impl.h" | 14 #include "chrome/browser/chromeos/login/login_display_host_impl.h" |
15 #include "chromeos/network/network_state_handler.h" | 15 #include "chromeos/network/network_state_handler.h" |
16 #include "content/public/browser/web_ui.h" | 16 #include "content/public/browser/web_ui.h" |
17 #include "ui/base/models/menu_model.h" | 17 #include "ui/base/models/menu_model.h" |
18 #include "ui/base/webui/web_ui_util.h" | 18 #include "ui/base/webui/web_ui_util.h" |
19 #include "ui/gfx/font.h" | 19 #include "ui/gfx/font_list.h" |
20 #include "ui/gfx/image/image.h" | 20 #include "ui/gfx/image/image.h" |
21 #include "ui/gfx/image/image_skia.h" | 21 #include "ui/gfx/image/image_skia.h" |
22 | 22 |
23 namespace { | 23 namespace { |
24 | 24 |
25 // Timeout between consecutive requests to network library for network | 25 // Timeout between consecutive requests to network library for network |
26 // scan. | 26 // scan. |
27 const int kNetworkScanIntervalSecs = 60; | 27 const int kNetworkScanIntervalSecs = 60; |
28 | 28 |
29 } // namespace | 29 } // namespace |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 ui::GetImageScale( |
94 web_ui_->GetDeviceScaleFactor())).sk_bitmap(); | 94 web_ui_->GetDeviceScaleFactor())).sk_bitmap(); |
95 item->SetString("icon", webui::GetBitmapDataUrl(icon_bitmap)); | 95 item->SetString("icon", webui::GetBitmapDataUrl(icon_bitmap)); |
96 } | 96 } |
97 if (id >= 0) { | 97 if (id >= 0) { |
98 item->SetBoolean("enabled", model->IsEnabledAt(i)); | 98 item->SetBoolean("enabled", model->IsEnabledAt(i)); |
99 const gfx::Font* font = model->GetLabelFontAt(i); | 99 const gfx::FontList* font_list = model->GetLabelFontListAt(i); |
100 if (font) { | 100 if (font_list) |
101 item->SetBoolean("bold", font->GetStyle() == gfx::Font::BOLD); | 101 item->SetBoolean("bold", font_list->GetFontStyle() == gfx::Font::BOLD); |
102 } | |
103 } | 102 } |
104 if (type == ui::MenuModel::TYPE_SUBMENU) | 103 if (type == ui::MenuModel::TYPE_SUBMENU) |
105 item->Set("sub", ConvertMenuModel(model->GetSubmenuModelAt(i))); | 104 item->Set("sub", ConvertMenuModel(model->GetSubmenuModelAt(i))); |
106 list->Append(item); | 105 list->Append(item); |
107 } | 106 } |
108 return list; | 107 return list; |
109 } | 108 } |
110 | 109 |
111 // NetworkDropdown ------------------------------------------------------------- | 110 // NetworkDropdown ------------------------------------------------------------- |
112 | 111 |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 web_ui_->CallJavascriptFunction("cr.ui.DropDown.updateNetworkTitle", | 201 web_ui_->CallJavascriptFunction("cr.ui.DropDown.updateNetworkTitle", |
203 title, icon); | 202 title, icon); |
204 } | 203 } |
205 | 204 |
206 void NetworkDropdown::RequestNetworkScan() { | 205 void NetworkDropdown::RequestNetworkScan() { |
207 NetworkHandler::Get()->network_state_handler()->RequestScan(); | 206 NetworkHandler::Get()->network_state_handler()->RequestScan(); |
208 Refresh(); | 207 Refresh(); |
209 } | 208 } |
210 | 209 |
211 } // namespace chromeos | 210 } // namespace chromeos |
OLD | NEW |