OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/dom_ui/options/browser_options_handler.h" | 5 #include "chrome/browser/dom_ui/options/browser_options_handler.h" |
6 | 6 |
7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/scoped_ptr.h" | 9 #include "base/scoped_ptr.h" |
10 #include "base/singleton.h" | 10 #include "base/singleton.h" |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 SessionStartupPref::GetStartupPref(profile->GetPrefs()); | 274 SessionStartupPref::GetStartupPref(profile->GetPrefs()); |
275 startup_custom_pages_table_model_->SetURLs(startup_pref.urls); | 275 startup_custom_pages_table_model_->SetURLs(startup_pref.urls); |
276 } | 276 } |
277 | 277 |
278 void BrowserOptionsHandler::OnModelChanged() { | 278 void BrowserOptionsHandler::OnModelChanged() { |
279 ListValue startup_pages; | 279 ListValue startup_pages; |
280 int page_count = startup_custom_pages_table_model_->RowCount(); | 280 int page_count = startup_custom_pages_table_model_->RowCount(); |
281 std::vector<GURL> urls = startup_custom_pages_table_model_->GetURLs(); | 281 std::vector<GURL> urls = startup_custom_pages_table_model_->GetURLs(); |
282 for (int i = 0; i < page_count; ++i) { | 282 for (int i = 0; i < page_count; ++i) { |
283 DictionaryValue* entry = new DictionaryValue(); | 283 DictionaryValue* entry = new DictionaryValue(); |
284 entry->SetString("title", WideToUTF16Hack( | 284 entry->SetString("title", startup_custom_pages_table_model_->GetText(i, 0)); |
285 startup_custom_pages_table_model_->GetText(i, 0))); | |
286 entry->SetString("url", urls[i].spec()); | 285 entry->SetString("url", urls[i].spec()); |
287 entry->SetString("tooltip", WideToUTF16Hack( | 286 entry->SetString("tooltip", |
288 startup_custom_pages_table_model_->GetTooltip(i))); | 287 startup_custom_pages_table_model_->GetTooltip(i)); |
289 startup_pages.Append(entry); | 288 startup_pages.Append(entry); |
290 } | 289 } |
291 | 290 |
292 dom_ui_->CallJavascriptFunction(L"BrowserOptions.updateStartupPages", | 291 dom_ui_->CallJavascriptFunction(L"BrowserOptions.updateStartupPages", |
293 startup_pages); | 292 startup_pages); |
294 } | 293 } |
295 | 294 |
296 void BrowserOptionsHandler::OnItemsChanged(int start, int length) { | 295 void BrowserOptionsHandler::OnItemsChanged(int start, int length) { |
297 OnModelChanged(); | 296 OnModelChanged(); |
298 } | 297 } |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 } | 354 } |
356 | 355 |
357 void BrowserOptionsHandler::SaveStartupPagesPref() { | 356 void BrowserOptionsHandler::SaveStartupPagesPref() { |
358 PrefService* prefs = dom_ui_->GetProfile()->GetPrefs(); | 357 PrefService* prefs = dom_ui_->GetProfile()->GetPrefs(); |
359 | 358 |
360 SessionStartupPref pref = SessionStartupPref::GetStartupPref(prefs); | 359 SessionStartupPref pref = SessionStartupPref::GetStartupPref(prefs); |
361 pref.urls = startup_custom_pages_table_model_->GetURLs(); | 360 pref.urls = startup_custom_pages_table_model_->GetURLs(); |
362 | 361 |
363 SessionStartupPref::SetStartupPref(prefs, pref); | 362 SessionStartupPref::SetStartupPref(prefs, pref); |
364 } | 363 } |
OLD | NEW |