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

Side by Side Diff: chrome/browser/ui/webui/settings/settings_startup_pages_handler.cc

Issue 2051663003: base::ListValue::Append cleanup: pass unique_ptr instead of the released pointer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 6 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/settings/settings_startup_pages_handler.h" 5 #include "chrome/browser/ui/webui/settings/settings_startup_pages_handler.h"
6 6
7 #include <string> 7 #include <string>
8 #include <utility>
8 #include <vector> 9 #include <vector>
9 10
10 #include "chrome/browser/prefs/session_startup_pref.h" 11 #include "chrome/browser/prefs/session_startup_pref.h"
11 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/ui/webui/settings_utils.h" 13 #include "chrome/browser/ui/webui/settings_utils.h"
13 #include "chrome/common/pref_names.h" 14 #include "chrome/common/pref_names.h"
14 #include "content/public/browser/web_ui.h" 15 #include "content/public/browser/web_ui.h"
15 #include "url/gurl.h" 16 #include "url/gurl.h"
16 17
17 namespace settings { 18 namespace settings {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 base::ListValue startup_pages; 74 base::ListValue startup_pages;
74 int page_count = startup_custom_pages_table_model_.RowCount(); 75 int page_count = startup_custom_pages_table_model_.RowCount();
75 std::vector<GURL> urls = startup_custom_pages_table_model_.GetURLs(); 76 std::vector<GURL> urls = startup_custom_pages_table_model_.GetURLs();
76 for (int i = 0; i < page_count; ++i) { 77 for (int i = 0; i < page_count; ++i) {
77 std::unique_ptr<base::DictionaryValue> entry(new base::DictionaryValue()); 78 std::unique_ptr<base::DictionaryValue> entry(new base::DictionaryValue());
78 entry->SetString("title", startup_custom_pages_table_model_.GetText(i, 0)); 79 entry->SetString("title", startup_custom_pages_table_model_.GetText(i, 0));
79 entry->SetString("url", urls[i].spec()); 80 entry->SetString("url", urls[i].spec());
80 entry->SetString("tooltip", 81 entry->SetString("tooltip",
81 startup_custom_pages_table_model_.GetTooltip(i)); 82 startup_custom_pages_table_model_.GetTooltip(i));
82 entry->SetInteger("modelIndex", i); 83 entry->SetInteger("modelIndex", i);
83 startup_pages.Append(entry.release()); 84 startup_pages.Append(std::move(entry));
84 } 85 }
85 86
86 CallJavascriptFunction("cr.webUIListenerCallback", 87 CallJavascriptFunction("cr.webUIListenerCallback",
87 base::StringValue("update-startup-pages"), 88 base::StringValue("update-startup-pages"),
88 startup_pages); 89 startup_pages);
89 } 90 }
90 91
91 void StartupPagesHandler::OnItemsChanged(int start, int length) { 92 void StartupPagesHandler::OnItemsChanged(int start, int length) {
92 OnModelChanged(); 93 OnModelChanged();
93 } 94 }
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 210
210 void StartupPagesHandler::UpdateStartupPages() { 211 void StartupPagesHandler::UpdateStartupPages() {
211 const SessionStartupPref startup_pref = SessionStartupPref::GetStartupPref( 212 const SessionStartupPref startup_pref = SessionStartupPref::GetStartupPref(
212 Profile::FromWebUI(web_ui())->GetPrefs()); 213 Profile::FromWebUI(web_ui())->GetPrefs());
213 startup_custom_pages_table_model_.SetURLs(startup_pref.urls); 214 startup_custom_pages_table_model_.SetURLs(startup_pref.urls);
214 // The change will go to the JS code in the 215 // The change will go to the JS code in the
215 // StartupPagesHandler::OnModelChanged() method. 216 // StartupPagesHandler::OnModelChanged() method.
216 } 217 }
217 218
218 } // namespace settings 219 } // namespace settings
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698