| 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 <memory> | 7 #include <memory> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 NetworkMenuWebUI(NetworkMenu::Delegate* delegate, content::WebUI* web_ui); | 41 NetworkMenuWebUI(NetworkMenu::Delegate* delegate, content::WebUI* web_ui); |
| 42 | 42 |
| 43 // NetworkMenu override: | 43 // NetworkMenu override: |
| 44 void UpdateMenu() override; | 44 void UpdateMenu() override; |
| 45 | 45 |
| 46 // Called when item with command |id| is chosen. | 46 // Called when item with command |id| is chosen. |
| 47 void OnItemChosen(int id); | 47 void OnItemChosen(int id); |
| 48 | 48 |
| 49 private: | 49 private: |
| 50 // Converts menu model into the ListValue, ready for passing to WebUI. | 50 // Converts menu model into the ListValue, ready for passing to WebUI. |
| 51 base::ListValue* ConvertMenuModel(ui::MenuModel* model); | 51 std::unique_ptr<base::ListValue> ConvertMenuModel(ui::MenuModel* model); |
| 52 | 52 |
| 53 // WebUI where network menu is located. | 53 // WebUI where network menu is located. |
| 54 content::WebUI* web_ui_; | 54 content::WebUI* web_ui_; |
| 55 | 55 |
| 56 DISALLOW_COPY_AND_ASSIGN(NetworkMenuWebUI); | 56 DISALLOW_COPY_AND_ASSIGN(NetworkMenuWebUI); |
| 57 }; | 57 }; |
| 58 | 58 |
| 59 // NetworkMenuWebUI ------------------------------------------------------------ | 59 // NetworkMenuWebUI ------------------------------------------------------------ |
| 60 | 60 |
| 61 NetworkMenuWebUI::NetworkMenuWebUI(NetworkMenu::Delegate* delegate, | 61 NetworkMenuWebUI::NetworkMenuWebUI(NetworkMenu::Delegate* delegate, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 74 } | 74 } |
| 75 | 75 |
| 76 void NetworkMenuWebUI::OnItemChosen(int id) { | 76 void NetworkMenuWebUI::OnItemChosen(int id) { |
| 77 int index; | 77 int index; |
| 78 ui::MenuModel* model = GetMenuModel(); | 78 ui::MenuModel* model = GetMenuModel(); |
| 79 if (!ui::MenuModel::GetModelAndIndexForCommandId(id, &model, &index)) | 79 if (!ui::MenuModel::GetModelAndIndexForCommandId(id, &model, &index)) |
| 80 return; | 80 return; |
| 81 model->ActivatedAt(index); | 81 model->ActivatedAt(index); |
| 82 } | 82 } |
| 83 | 83 |
| 84 base::ListValue* NetworkMenuWebUI::ConvertMenuModel(ui::MenuModel* model) { | 84 std::unique_ptr<base::ListValue> NetworkMenuWebUI::ConvertMenuModel( |
| 85 base::ListValue* list = new base::ListValue(); | 85 ui::MenuModel* model) { |
| 86 auto list = base::MakeUnique<base::ListValue>(); |
| 86 for (int i = 0; i < model->GetItemCount(); ++i) { | 87 for (int i = 0; i < model->GetItemCount(); ++i) { |
| 87 ui::MenuModel::ItemType type = model->GetTypeAt(i); | 88 ui::MenuModel::ItemType type = model->GetTypeAt(i); |
| 88 int id; | 89 int id; |
| 89 if (type == ui::MenuModel::TYPE_SEPARATOR) | 90 if (type == ui::MenuModel::TYPE_SEPARATOR) |
| 90 id = -2; | 91 id = -2; |
| 91 else | 92 else |
| 92 id = model->GetCommandIdAt(i); | 93 id = model->GetCommandIdAt(i); |
| 93 auto item = base::MakeUnique<base::DictionaryValue>(); | 94 auto item = base::MakeUnique<base::DictionaryValue>(); |
| 94 item->SetInteger("id", id); | 95 item->SetInteger("id", id); |
| 95 base::string16 label = model->GetLabelAt(i); | 96 base::string16 label = model->GetLabelAt(i); |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 web_ui_->CallJavascriptFunctionUnsafe("cr.ui.DropDown.updateNetworkTitle", | 206 web_ui_->CallJavascriptFunctionUnsafe("cr.ui.DropDown.updateNetworkTitle", |
| 206 title, icon); | 207 title, icon); |
| 207 } | 208 } |
| 208 | 209 |
| 209 void NetworkDropdown::RequestNetworkScan() { | 210 void NetworkDropdown::RequestNetworkScan() { |
| 210 NetworkHandler::Get()->network_state_handler()->RequestScan(); | 211 NetworkHandler::Get()->network_state_handler()->RequestScan(); |
| 211 Refresh(); | 212 Refresh(); |
| 212 } | 213 } |
| 213 | 214 |
| 214 } // namespace chromeos | 215 } // namespace chromeos |
| OLD | NEW |