| 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/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 NetworkMenuWebUI::NetworkMenuWebUI(NetworkMenu::Delegate* delegate, | 58 NetworkMenuWebUI::NetworkMenuWebUI(NetworkMenu::Delegate* delegate, |
| 59 content::WebUI* web_ui) | 59 content::WebUI* web_ui) |
| 60 : NetworkMenu(delegate), | 60 : NetworkMenu(delegate), |
| 61 web_ui_(web_ui) { | 61 web_ui_(web_ui) { |
| 62 } | 62 } |
| 63 | 63 |
| 64 void NetworkMenuWebUI::UpdateMenu() { | 64 void NetworkMenuWebUI::UpdateMenu() { |
| 65 NetworkMenu::UpdateMenu(); | 65 NetworkMenu::UpdateMenu(); |
| 66 if (web_ui_) { | 66 if (web_ui_) { |
| 67 std::unique_ptr<base::ListValue> list(ConvertMenuModel(GetMenuModel())); | 67 std::unique_ptr<base::ListValue> list(ConvertMenuModel(GetMenuModel())); |
| 68 web_ui_->CallJavascriptFunction("cr.ui.DropDown.updateNetworks", *list); | 68 web_ui_->CallJavascriptFunctionUnsafe("cr.ui.DropDown.updateNetworks", |
| 69 *list); |
| 69 } | 70 } |
| 70 } | 71 } |
| 71 | 72 |
| 72 void NetworkMenuWebUI::OnItemChosen(int id) { | 73 void NetworkMenuWebUI::OnItemChosen(int id) { |
| 73 int index; | 74 int index; |
| 74 ui::MenuModel* model = GetMenuModel(); | 75 ui::MenuModel* model = GetMenuModel(); |
| 75 if (!ui::MenuModel::GetModelAndIndexForCommandId(id, &model, &index)) | 76 if (!ui::MenuModel::GetModelAndIndexForCommandId(id, &model, &index)) |
| 76 return; | 77 return; |
| 77 model->ActivatedAt(index); | 78 model->ActivatedAt(index); |
| 78 } | 79 } |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 } else { | 194 } else { |
| 194 ui::network_icon::NetworkIconAnimation::GetInstance()->RemoveObserver(this); | 195 ui::network_icon::NetworkIconAnimation::GetInstance()->RemoveObserver(this); |
| 195 } | 196 } |
| 196 SkBitmap icon_bitmap = icon_image.GetRepresentation( | 197 SkBitmap icon_bitmap = icon_image.GetRepresentation( |
| 197 web_ui_->GetDeviceScaleFactor()).sk_bitmap(); | 198 web_ui_->GetDeviceScaleFactor()).sk_bitmap(); |
| 198 std::string icon_str; | 199 std::string icon_str; |
| 199 if (!icon_image.isNull()) | 200 if (!icon_image.isNull()) |
| 200 icon_str = webui::GetBitmapDataUrl(icon_bitmap); | 201 icon_str = webui::GetBitmapDataUrl(icon_bitmap); |
| 201 base::StringValue title(text); | 202 base::StringValue title(text); |
| 202 base::StringValue icon(icon_str); | 203 base::StringValue icon(icon_str); |
| 203 web_ui_->CallJavascriptFunction("cr.ui.DropDown.updateNetworkTitle", | 204 web_ui_->CallJavascriptFunctionUnsafe("cr.ui.DropDown.updateNetworkTitle", |
| 204 title, icon); | 205 title, icon); |
| 205 } | 206 } |
| 206 | 207 |
| 207 void NetworkDropdown::RequestNetworkScan() { | 208 void NetworkDropdown::RequestNetworkScan() { |
| 208 NetworkHandler::Get()->network_state_handler()->RequestScan(); | 209 NetworkHandler::Get()->network_state_handler()->RequestScan(); |
| 209 Refresh(); | 210 Refresh(); |
| 210 } | 211 } |
| 211 | 212 |
| 212 } // namespace chromeos | 213 } // namespace chromeos |
| OLD | NEW |