Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(327)

Side by Side Diff: chrome/browser/ui/webui/chromeos/login/network_dropdown.cc

Issue 24175004: Remove dependency on ui::ScaleFactor from ui/gfx (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rename methods and vars to make image_scale more clear Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 web_ui_->GetDeviceScaleFactor()).sk_bitmap(); 93 ui::GetImageScale(
94 web_ui_->GetDeviceScaleFactor())).sk_bitmap();
94 item->SetString("icon", webui::GetBitmapDataUrl(icon_bitmap)); 95 item->SetString("icon", webui::GetBitmapDataUrl(icon_bitmap));
95 } 96 }
96 if (id >= 0) { 97 if (id >= 0) {
97 item->SetBoolean("enabled", model->IsEnabledAt(i)); 98 item->SetBoolean("enabled", model->IsEnabledAt(i));
98 const gfx::Font* font = model->GetLabelFontAt(i); 99 const gfx::Font* font = model->GetLabelFontAt(i);
99 if (font) { 100 if (font) {
100 item->SetBoolean("bold", font->GetStyle() == gfx::Font::BOLD); 101 item->SetBoolean("bold", font->GetStyle() == gfx::Font::BOLD);
101 } 102 }
102 } 103 }
103 if (type == ui::MenuModel::TYPE_SUBMENU) 104 if (type == ui::MenuModel::TYPE_SUBMENU)
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 bool animating = false; 186 bool animating = false;
186 ash::network_icon::GetDefaultNetworkImageAndLabel( 187 ash::network_icon::GetDefaultNetworkImageAndLabel(
187 ash::network_icon::ICON_TYPE_LIST, &icon_image, &text, &animating); 188 ash::network_icon::ICON_TYPE_LIST, &icon_image, &text, &animating);
188 if (animating) { 189 if (animating) {
189 ash::network_icon::NetworkIconAnimation::GetInstance()->AddObserver(this); 190 ash::network_icon::NetworkIconAnimation::GetInstance()->AddObserver(this);
190 } else { 191 } else {
191 ash::network_icon::NetworkIconAnimation::GetInstance()-> 192 ash::network_icon::NetworkIconAnimation::GetInstance()->
192 RemoveObserver(this); 193 RemoveObserver(this);
193 } 194 }
194 SkBitmap icon_bitmap = icon_image.GetRepresentation( 195 SkBitmap icon_bitmap = icon_image.GetRepresentation(
195 web_ui_->GetDeviceScaleFactor()).sk_bitmap(); 196 ui::GetImageScale(web_ui_->GetDeviceScaleFactor())).sk_bitmap();
196 std::string icon_str; 197 std::string icon_str;
197 if (!icon_image.isNull()) 198 if (!icon_image.isNull())
198 icon_str = webui::GetBitmapDataUrl(icon_bitmap); 199 icon_str = webui::GetBitmapDataUrl(icon_bitmap);
199 base::StringValue title(text); 200 base::StringValue title(text);
200 base::StringValue icon(icon_str); 201 base::StringValue icon(icon_str);
201 web_ui_->CallJavascriptFunction("cr.ui.DropDown.updateNetworkTitle", 202 web_ui_->CallJavascriptFunction("cr.ui.DropDown.updateNetworkTitle",
202 title, icon); 203 title, icon);
203 } 204 }
204 205
205 void NetworkDropdown::RequestNetworkScan() { 206 void NetworkDropdown::RequestNetworkScan() {
206 NetworkHandler::Get()->network_state_handler()->RequestScan(); 207 NetworkHandler::Get()->network_state_handler()->RequestScan();
207 Refresh(); 208 Refresh();
208 } 209 }
209 210
210 } // namespace chromeos 211 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698