OLD | NEW |
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 <vector> | 8 #include <vector> |
9 | 9 |
10 #include "chrome/browser/prefs/session_startup_pref.h" | 10 #include "chrome/browser/prefs/session_startup_pref.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 void StartupPagesHandler::RenderViewReused() { | 47 void StartupPagesHandler::RenderViewReused() { |
48 startup_custom_pages_table_model_.SetObserver(nullptr); | 48 startup_custom_pages_table_model_.SetObserver(nullptr); |
49 pref_change_registrar_.RemoveAll(); | 49 pref_change_registrar_.RemoveAll(); |
50 } | 50 } |
51 | 51 |
52 void StartupPagesHandler::OnModelChanged() { | 52 void StartupPagesHandler::OnModelChanged() { |
53 base::ListValue startup_pages; | 53 base::ListValue startup_pages; |
54 int page_count = startup_custom_pages_table_model_.RowCount(); | 54 int page_count = startup_custom_pages_table_model_.RowCount(); |
55 std::vector<GURL> urls = startup_custom_pages_table_model_.GetURLs(); | 55 std::vector<GURL> urls = startup_custom_pages_table_model_.GetURLs(); |
56 for (int i = 0; i < page_count; ++i) { | 56 for (int i = 0; i < page_count; ++i) { |
57 scoped_ptr<base::DictionaryValue> entry(new base::DictionaryValue()); | 57 std::unique_ptr<base::DictionaryValue> entry(new base::DictionaryValue()); |
58 entry->SetString("title", startup_custom_pages_table_model_.GetText(i, 0)); | 58 entry->SetString("title", startup_custom_pages_table_model_.GetText(i, 0)); |
59 entry->SetString("url", urls[i].spec()); | 59 entry->SetString("url", urls[i].spec()); |
60 entry->SetString("tooltip", | 60 entry->SetString("tooltip", |
61 startup_custom_pages_table_model_.GetTooltip(i)); | 61 startup_custom_pages_table_model_.GetTooltip(i)); |
62 entry->SetInteger("modelIndex", i); | 62 entry->SetInteger("modelIndex", i); |
63 startup_pages.Append(entry.release()); | 63 startup_pages.Append(entry.release()); |
64 } | 64 } |
65 | 65 |
66 web_ui()->CallJavascriptFunction("cr.webUIListenerCallback", | 66 web_ui()->CallJavascriptFunction("cr.webUIListenerCallback", |
67 base::StringValue("update-startup-pages"), | 67 base::StringValue("update-startup-pages"), |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 | 176 |
177 void StartupPagesHandler::UpdateStartupPages() { | 177 void StartupPagesHandler::UpdateStartupPages() { |
178 const SessionStartupPref startup_pref = SessionStartupPref::GetStartupPref( | 178 const SessionStartupPref startup_pref = SessionStartupPref::GetStartupPref( |
179 Profile::FromWebUI(web_ui())->GetPrefs()); | 179 Profile::FromWebUI(web_ui())->GetPrefs()); |
180 startup_custom_pages_table_model_.SetURLs(startup_pref.urls); | 180 startup_custom_pages_table_model_.SetURLs(startup_pref.urls); |
181 // The change will go to the JS code in the | 181 // The change will go to the JS code in the |
182 // StartupPagesHandler::OnModelChanged() method. | 182 // StartupPagesHandler::OnModelChanged() method. |
183 } | 183 } |
184 | 184 |
185 } // namespace settings | 185 } // namespace settings |
OLD | NEW |