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

Unified Diff: chrome/browser/dom_ui/options/browser_options_handler.cc

Issue 6332006: DOMUI Prefs: Improve saving of homepage pref. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/dom_ui/options/browser_options_handler.cc
diff --git a/chrome/browser/dom_ui/options/browser_options_handler.cc b/chrome/browser/dom_ui/options/browser_options_handler.cc
index e83b408eb287563670dcae2276bde73ebf23fbc2..91136135412d677c2983434d0de5d09848258591 100644
--- a/chrome/browser/dom_ui/options/browser_options_handler.cc
+++ b/chrome/browser/dom_ui/options/browser_options_handler.cc
@@ -24,6 +24,7 @@
#include "chrome/browser/search_engines/template_url.h"
#include "chrome/browser/search_engines/template_url_model.h"
#include "chrome/browser/ui/options/options_window.h"
+#include "chrome/common/pref_names.h"
#include "chrome/installer/util/browser_distribution.h"
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
@@ -98,6 +99,9 @@ void BrowserOptionsHandler::GetLocalizedValues(
void BrowserOptionsHandler::RegisterMessages() {
dom_ui_->RegisterMessageCallback(
+ "setHomePage",
+ NewCallback(this, &BrowserOptionsHandler::SetHomePage));
+ dom_ui_->RegisterMessageCallback(
"becomeDefaultBrowser",
NewCallback(this, &BrowserOptionsHandler::BecomeDefaultBrowser));
dom_ui_->RegisterMessageCallback(
@@ -118,14 +122,17 @@ void BrowserOptionsHandler::RegisterMessages() {
}
void BrowserOptionsHandler::Initialize() {
+ Profile* profile = dom_ui_->GetProfile();
+
// Create our favicon data source.
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
NewRunnableMethod(
ChromeURLDataManager::GetInstance(),
&ChromeURLDataManager::AddDataSource,
- make_scoped_refptr(new DOMUIFavIconSource(dom_ui_->GetProfile()))));
+ make_scoped_refptr(new DOMUIFavIconSource(profile))));
+ homepage_.Init(prefs::kHomePage, profile->GetPrefs(), NULL);
UpdateDefaultBrowserState();
UpdateStartupPages();
UpdateSearchEngines();
@@ -135,6 +142,24 @@ void BrowserOptionsHandler::Initialize() {
OPTIONS_PAGE_GENERAL));
}
+void BrowserOptionsHandler::SetHomePage(const ListValue* args) {
+ std::string url_string;
+ std::string do_fixup_string;
+ int do_fixup;
+ if (args->GetSize() != 2 ||
+ !args->GetString(0, &url_string) ||
+ !args->GetString(1, &do_fixup_string) ||
+ !base::StringToInt(do_fixup_string, &do_fixup)) {
+ CHECK(false);
+ };
+
+ if (do_fixup) {
+ GURL fixed_url = URLFixerUpper::FixupURL(url_string, std::string());
+ url_string = fixed_url.spec();
+ }
+ homepage_.SetValueIfNotManaged(url_string);
+}
+
void BrowserOptionsHandler::UpdateDefaultBrowserState() {
#if defined(OS_WIN)
// Check for side-by-side first.

Powered by Google App Engine
This is Rietveld 408576698