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/options/startup_pages_handler.h" | 5 #include "chrome/browser/ui/webui/options/startup_pages_handler.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
| 9 #include <utility> |
| 10 |
9 #include "base/bind.h" | 11 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
11 #include "base/logging.h" | 13 #include "base/logging.h" |
12 #include "base/macros.h" | 14 #include "base/macros.h" |
13 #include "base/memory/ptr_util.h" | 15 #include "base/memory/ptr_util.h" |
14 #include "chrome/browser/autocomplete/chrome_autocomplete_provider_client.h" | 16 #include "chrome/browser/autocomplete/chrome_autocomplete_provider_client.h" |
15 #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h" | 17 #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h" |
16 #include "chrome/browser/chrome_notification_types.h" | 18 #include "chrome/browser/chrome_notification_types.h" |
17 #include "chrome/browser/custom_home_pages_table_model.h" | 19 #include "chrome/browser/custom_home_pages_table_model.h" |
18 #include "chrome/browser/prefs/session_startup_pref.h" | 20 #include "chrome/browser/prefs/session_startup_pref.h" |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 | 116 |
115 void StartupPagesHandler::InitializePage() { | 117 void StartupPagesHandler::InitializePage() { |
116 UpdateStartupPages(); | 118 UpdateStartupPages(); |
117 } | 119 } |
118 | 120 |
119 void StartupPagesHandler::OnModelChanged() { | 121 void StartupPagesHandler::OnModelChanged() { |
120 base::ListValue startup_pages; | 122 base::ListValue startup_pages; |
121 int page_count = startup_custom_pages_table_model_->RowCount(); | 123 int page_count = startup_custom_pages_table_model_->RowCount(); |
122 std::vector<GURL> urls = startup_custom_pages_table_model_->GetURLs(); | 124 std::vector<GURL> urls = startup_custom_pages_table_model_->GetURLs(); |
123 for (int i = 0; i < page_count; ++i) { | 125 for (int i = 0; i < page_count; ++i) { |
124 base::DictionaryValue* entry = new base::DictionaryValue(); | 126 std::unique_ptr<base::DictionaryValue> entry(new base::DictionaryValue()); |
125 entry->SetString("title", startup_custom_pages_table_model_->GetText(i, 0)); | 127 entry->SetString("title", startup_custom_pages_table_model_->GetText(i, 0)); |
126 entry->SetString("url", urls[i].spec()); | 128 entry->SetString("url", urls[i].spec()); |
127 entry->SetString("tooltip", | 129 entry->SetString("tooltip", |
128 startup_custom_pages_table_model_->GetTooltip(i)); | 130 startup_custom_pages_table_model_->GetTooltip(i)); |
129 entry->SetInteger("modelIndex", i); | 131 entry->SetInteger("modelIndex", i); |
130 startup_pages.Append(entry); | 132 startup_pages.Append(std::move(entry)); |
131 } | 133 } |
132 | 134 |
133 web_ui()->CallJavascriptFunctionUnsafe("StartupOverlay.updateStartupPages", | 135 web_ui()->CallJavascriptFunctionUnsafe("StartupOverlay.updateStartupPages", |
134 startup_pages); | 136 startup_pages); |
135 } | 137 } |
136 | 138 |
137 void StartupPagesHandler::OnItemsChanged(int start, int length) { | 139 void StartupPagesHandler::OnItemsChanged(int start, int length) { |
138 OnModelChanged(); | 140 OnModelChanged(); |
139 } | 141 } |
140 | 142 |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 | 262 |
261 void StartupPagesHandler::OnResultChanged(bool default_match_changed) { | 263 void StartupPagesHandler::OnResultChanged(bool default_match_changed) { |
262 const AutocompleteResult& result = autocomplete_controller_->result(); | 264 const AutocompleteResult& result = autocomplete_controller_->result(); |
263 base::ListValue suggestions; | 265 base::ListValue suggestions; |
264 OptionsUI::ProcessAutocompleteSuggestions(result, &suggestions); | 266 OptionsUI::ProcessAutocompleteSuggestions(result, &suggestions); |
265 web_ui()->CallJavascriptFunctionUnsafe( | 267 web_ui()->CallJavascriptFunctionUnsafe( |
266 "StartupOverlay.updateAutocompleteSuggestions", suggestions); | 268 "StartupOverlay.updateAutocompleteSuggestions", suggestions); |
267 } | 269 } |
268 | 270 |
269 } // namespace options | 271 } // namespace options |
OLD | NEW |