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

Side by Side Diff: chrome/browser/ui/webui/voice_search_ui.cc

Issue 1865213004: Convert //chrome/browser/ui from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 8 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/voice_search_ui.h" 5 #include "chrome/browser/ui/webui/voice_search_ui.h"
6 6
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 IDR_ABOUT_VOICESEARCH_JS); 72 IDR_ABOUT_VOICESEARCH_JS);
73 html_source->SetDefaultResource(IDR_ABOUT_VOICESEARCH_HTML); 73 html_source->SetDefaultResource(IDR_ABOUT_VOICESEARCH_HTML);
74 return html_source; 74 return html_source;
75 } 75 }
76 76
77 // Helper functions for collecting a list of key-value pairs that will 77 // Helper functions for collecting a list of key-value pairs that will
78 // be displayed. 78 // be displayed.
79 void AddPair16(base::ListValue* list, 79 void AddPair16(base::ListValue* list,
80 const base::string16& key, 80 const base::string16& key,
81 const base::string16& value) { 81 const base::string16& value) {
82 scoped_ptr<base::DictionaryValue> results(new base::DictionaryValue()); 82 std::unique_ptr<base::DictionaryValue> results(new base::DictionaryValue());
83 results->SetString("key", key); 83 results->SetString("key", key);
84 results->SetString("value", value); 84 results->SetString("value", value);
85 list->Append(results.release()); 85 list->Append(results.release());
86 } 86 }
87 87
88 void AddPair(base::ListValue* list, 88 void AddPair(base::ListValue* list,
89 const base::StringPiece& key, 89 const base::StringPiece& key,
90 const base::StringPiece& value) { 90 const base::StringPiece& value) {
91 AddPair16(list, UTF8ToUTF16(key), UTF8ToUTF16(value)); 91 AddPair16(list, UTF8ToUTF16(key), UTF8ToUTF16(value));
92 } 92 }
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 base::Bind(&VoiceSearchDomHandler::HandleRequestVoiceSearchInfo, 151 base::Bind(&VoiceSearchDomHandler::HandleRequestVoiceSearchInfo,
152 base::Unretained(this))); 152 base::Unretained(this)));
153 } 153 }
154 154
155 private: 155 private:
156 // Callback for the "requestVoiceSearchInfo" message. No arguments. 156 // Callback for the "requestVoiceSearchInfo" message. No arguments.
157 void HandleRequestVoiceSearchInfo(const base::ListValue* args) { 157 void HandleRequestVoiceSearchInfo(const base::ListValue* args) {
158 PopulatePageInformation(); 158 PopulatePageInformation();
159 } 159 }
160 160
161 void ReturnVoiceSearchInfo(scoped_ptr<base::ListValue> info) { 161 void ReturnVoiceSearchInfo(std::unique_ptr<base::ListValue> info) {
162 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 162 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
163 DCHECK(info); 163 DCHECK(info);
164 base::DictionaryValue voiceSearchInfo; 164 base::DictionaryValue voiceSearchInfo;
165 voiceSearchInfo.Set("voiceSearchInfo", info.release()); 165 voiceSearchInfo.Set("voiceSearchInfo", info.release());
166 web_ui()->CallJavascriptFunction("returnVoiceSearchInfo", voiceSearchInfo); 166 web_ui()->CallJavascriptFunction("returnVoiceSearchInfo", voiceSearchInfo);
167 } 167 }
168 168
169 // Fill in the data to be displayed on the page. 169 // Fill in the data to be displayed on the page.
170 void PopulatePageInformation() { 170 void PopulatePageInformation() {
171 // Store Key-Value pairs of about-information. 171 // Store Key-Value pairs of about-information.
172 scoped_ptr<base::ListValue> list(new base::ListValue()); 172 std::unique_ptr<base::ListValue> list(new base::ListValue());
173 173
174 // Populate information. 174 // Populate information.
175 AddOperatingSystemInfo(list.get()); 175 AddOperatingSystemInfo(list.get());
176 AddAudioInfo(list.get()); 176 AddAudioInfo(list.get());
177 AddLanguageInfo(list.get()); 177 AddLanguageInfo(list.get());
178 AddHotwordInfo(list.get()); 178 AddHotwordInfo(list.get());
179 AddAppListInfo(list.get()); 179 AddAppListInfo(list.get());
180 180
181 AddExtensionInfo(extension_misc::kHotwordNewExtensionId, 181 AddExtensionInfo(extension_misc::kHotwordNewExtensionId,
182 "Extension", 182 "Extension",
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 VoiceSearchUI::VoiceSearchUI(content::WebUI* web_ui) 434 VoiceSearchUI::VoiceSearchUI(content::WebUI* web_ui)
435 : content::WebUIController(web_ui) { 435 : content::WebUIController(web_ui) {
436 Profile* profile = Profile::FromWebUI(web_ui); 436 Profile* profile = Profile::FromWebUI(web_ui);
437 web_ui->AddMessageHandler(new VoiceSearchDomHandler(profile)); 437 web_ui->AddMessageHandler(new VoiceSearchDomHandler(profile));
438 438
439 // Set up the about:voicesearch source. 439 // Set up the about:voicesearch source.
440 content::WebUIDataSource::Add(profile, CreateVoiceSearchUiHtmlSource()); 440 content::WebUIDataSource::Add(profile, CreateVoiceSearchUiHtmlSource());
441 } 441 }
442 442
443 VoiceSearchUI::~VoiceSearchUI() {} 443 VoiceSearchUI::~VoiceSearchUI() {}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698