| OLD | NEW | 
|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/basictypes.h" | 7 #include "base/basictypes.h" | 
| 8 #include "base/scoped_ptr.h" | 8 #include "base/scoped_ptr.h" | 
| 9 #include "base/singleton.h" | 9 #include "base/singleton.h" | 
| 10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" | 
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 148 | 148 | 
| 149 void BrowserOptionsHandler::SetHomePage(const ListValue* args) { | 149 void BrowserOptionsHandler::SetHomePage(const ListValue* args) { | 
| 150   std::string url_string; | 150   std::string url_string; | 
| 151   std::string do_fixup_string; | 151   std::string do_fixup_string; | 
| 152   int do_fixup; | 152   int do_fixup; | 
| 153   if (args->GetSize() != 2 || | 153   if (args->GetSize() != 2 || | 
| 154       !args->GetString(0, &url_string) || | 154       !args->GetString(0, &url_string) || | 
| 155       !args->GetString(1, &do_fixup_string) || | 155       !args->GetString(1, &do_fixup_string) || | 
| 156       !base::StringToInt(do_fixup_string, &do_fixup)) { | 156       !base::StringToInt(do_fixup_string, &do_fixup)) { | 
| 157     CHECK(false); | 157     CHECK(false); | 
|  | 158     return;  // needs analysis why this is needed | 
| 158   }; | 159   }; | 
| 159 | 160 | 
| 160   if (do_fixup) { | 161   if (do_fixup) { | 
| 161     GURL fixed_url = URLFixerUpper::FixupURL(url_string, std::string()); | 162     GURL fixed_url = URLFixerUpper::FixupURL(url_string, std::string()); | 
| 162     url_string = fixed_url.spec(); | 163     url_string = fixed_url.spec(); | 
| 163   } | 164   } | 
| 164   homepage_.SetValueIfNotManaged(url_string); | 165   homepage_.SetValueIfNotManaged(url_string); | 
| 165 } | 166 } | 
| 166 | 167 | 
| 167 void BrowserOptionsHandler::UpdateDefaultBrowserState() { | 168 void BrowserOptionsHandler::UpdateDefaultBrowserState() { | 
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 376 | 377 | 
| 377 void BrowserOptionsHandler::AddStartupPage(const ListValue* args) { | 378 void BrowserOptionsHandler::AddStartupPage(const ListValue* args) { | 
| 378   std::string url_string; | 379   std::string url_string; | 
| 379   std::string index_string; | 380   std::string index_string; | 
| 380   int index; | 381   int index; | 
| 381   if (args->GetSize() != 2 || | 382   if (args->GetSize() != 2 || | 
| 382       !args->GetString(0, &url_string) || | 383       !args->GetString(0, &url_string) || | 
| 383       !args->GetString(1, &index_string) || | 384       !args->GetString(1, &index_string) || | 
| 384       !base::StringToInt(index_string, &index)) { | 385       !base::StringToInt(index_string, &index)) { | 
| 385     CHECK(false); | 386     CHECK(false); | 
|  | 387     return;  // needs analysis why this is needed | 
| 386   }; | 388   }; | 
| 387 | 389 | 
| 388   if (index == -1) | 390   if (index == -1) | 
| 389     index = startup_custom_pages_table_model_->RowCount(); | 391     index = startup_custom_pages_table_model_->RowCount(); | 
| 390   else | 392   else | 
| 391     ++index; | 393     ++index; | 
| 392 | 394 | 
| 393   GURL url = URLFixerUpper::FixupURL(url_string, std::string()); | 395   GURL url = URLFixerUpper::FixupURL(url_string, std::string()); | 
| 394 | 396 | 
| 395   startup_custom_pages_table_model_->Add(index, url); | 397   startup_custom_pages_table_model_->Add(index, url); | 
| 396   SaveStartupPagesPref(); | 398   SaveStartupPagesPref(); | 
| 397 } | 399 } | 
| 398 | 400 | 
| 399 void BrowserOptionsHandler::EditStartupPage(const ListValue* args) { | 401 void BrowserOptionsHandler::EditStartupPage(const ListValue* args) { | 
| 400   std::string url_string; | 402   std::string url_string; | 
| 401   std::string index_string; | 403   std::string index_string; | 
| 402   int index; | 404   int index; | 
| 403   if (args->GetSize() != 2 || | 405   if (args->GetSize() != 2 || | 
| 404       !args->GetString(0, &index_string) || | 406       !args->GetString(0, &index_string) || | 
| 405       !base::StringToInt(index_string, &index) || | 407       !base::StringToInt(index_string, &index) || | 
| 406       !args->GetString(1, &url_string)) { | 408       !args->GetString(1, &url_string)) { | 
| 407     CHECK(false); | 409     CHECK(false); | 
|  | 410     return;  // needs analysis why this is needed | 
| 408   }; | 411   }; | 
| 409 | 412 | 
| 410   if (index < 0 || index > startup_custom_pages_table_model_->RowCount()) { | 413   if (index < 0 || index > startup_custom_pages_table_model_->RowCount()) { | 
| 411     NOTREACHED(); | 414     NOTREACHED(); | 
| 412     return; | 415     return; | 
| 413   } | 416   } | 
| 414 | 417 | 
| 415   std::vector<GURL> urls = startup_custom_pages_table_model_->GetURLs(); | 418   std::vector<GURL> urls = startup_custom_pages_table_model_->GetURLs(); | 
| 416   urls[index] = URLFixerUpper::FixupURL(url_string, std::string()); | 419   urls[index] = URLFixerUpper::FixupURL(url_string, std::string()); | 
| 417   startup_custom_pages_table_model_->SetURLs(urls); | 420   startup_custom_pages_table_model_->SetURLs(urls); | 
| 418 } | 421 } | 
| 419 | 422 | 
| 420 void BrowserOptionsHandler::SaveStartupPagesPref() { | 423 void BrowserOptionsHandler::SaveStartupPagesPref() { | 
| 421   PrefService* prefs = dom_ui_->GetProfile()->GetPrefs(); | 424   PrefService* prefs = dom_ui_->GetProfile()->GetPrefs(); | 
| 422 | 425 | 
| 423   SessionStartupPref pref = SessionStartupPref::GetStartupPref(prefs); | 426   SessionStartupPref pref = SessionStartupPref::GetStartupPref(prefs); | 
| 424   pref.urls = startup_custom_pages_table_model_->GetURLs(); | 427   pref.urls = startup_custom_pages_table_model_->GetURLs(); | 
| 425 | 428 | 
| 426   SessionStartupPref::SetStartupPref(prefs, pref); | 429   SessionStartupPref::SetStartupPref(prefs, pref); | 
| 427 } | 430 } | 
| OLD | NEW | 
|---|