summaryrefslogtreecommitdiffstats
path: root/chrome/browser/browser.cc
diff options
context:
space:
mode:
authorfinnur@google.com <finnur@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-07-30 05:58:17 +0000
committerfinnur@google.com <finnur@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-07-30 05:58:17 +0000
commit2baf83d75ea5d1233d3ddcf8e28aa4f4466c115c (patch)
tree617cf49b21490c8e7b2e3c5a821c5d72c5735894 /chrome/browser/browser.cc
parent492399e06e64635ca8e3191f0653a8b081863b33 (diff)
downloadchromium_src-2baf83d75ea5d1233d3ddcf8e28aa4f4466c115c.zip
chromium_src-2baf83d75ea5d1233d3ddcf8e28aa4f4466c115c.tar.gz
chromium_src-2baf83d75ea5d1233d3ddcf8e28aa4f4466c115c.tar.bz2
Fix 1295677: REGRESSION: Import SETS startup page to imported home page.
We had only kHomePage pref before, which if blank/set to chrome-internal: meant that the New Tab page should be shown when Home is pressed. Now we add a pref called kHomePageIsNewTabPage for this purpose, which allows us to set the kHomePage value during import without actually using it as the HomePage (effectively importing home page becomes importing a default suggestion for when the users want a home page instead of the New Tab page). BUG=1295677 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@107 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/browser.cc')
-rw-r--r--chrome/browser/browser.cc25
1 files changed, 21 insertions, 4 deletions
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc
index 8c623b2..72f5afd 100644
--- a/chrome/browser/browser.cc
+++ b/chrome/browser/browser.cc
@@ -41,6 +41,7 @@
#include "chrome/browser/browser_shutdown.h"
#include "chrome/browser/browser_url_handler.h"
#include "chrome/browser/cert_store.h"
+#include "chrome/browser/dom_ui/new_tab_ui.h"
#include "chrome/browser/frame_util.h"
#include "chrome/browser/navigation_controller.h"
#include "chrome/browser/navigation_entry.h"
@@ -194,6 +195,7 @@ void Browser::RegisterPrefs(PrefService* prefs) {
// static
void Browser::RegisterUserPrefs(PrefService* prefs) {
prefs->RegisterStringPref(prefs::kHomePage, L"chrome-internal:");
+ prefs->RegisterBooleanPref(prefs::kHomePageIsNewTabPage, true);
prefs->RegisterIntegerPref(prefs::kCookieBehavior,
CookiePolicy::ALLOW_ALL_COOKIES);
prefs->RegisterBooleanPref(prefs::kShowHomeButton, false);
@@ -373,6 +375,20 @@ ChromeViews::View* Browser::GetToolbar() {
return &toolbar_;
}
+GURL Browser::GetHomePage() {
+ if (profile_->GetPrefs()->GetBoolean(prefs::kHomePageIsNewTabPage)) {
+ return NewTabUIURL();
+ } else {
+ GURL home_page = GURL(URLFixerUpper::FixupURL(
+ profile_->GetPrefs()->GetString(prefs::kHomePage),
+ std::wstring()));
+ if (!home_page.is_valid())
+ return NewTabUIURL();
+
+ return home_page;
+ }
+}
+
////////////////////////////////////////////////////////////////////////////////
void Browser::SyncWindowTitle() {
@@ -619,7 +635,8 @@ void Browser::OpenURLFromTab(TabContents* source,
}
if (disposition != NEW_BACKGROUND_TAB && source_tab_was_frontmost) {
- // Give the focus to the newly navigated tab, if the source tab was front-most
+ // Give the focus to the newly navigated tab, if the source tab was
+ // front-most.
new_contents->Focus();
}
}
@@ -790,7 +807,7 @@ void Browser::Observe(NotificationType type,
}
}
} else if (type == NOTIFY_WEB_CONTENTS_DISCONNECTED) {
- // Need to do this asynchronously as it will close the tab, which is
+ // Need to do this asynchronously as it will close the tab, which is
// currently on the call stack above us.
MessageLoop::current()->PostTask(FROM_HERE,
method_factory_.NewRunnableMethod(&Browser::ClearUnloadStateOnCrash,
@@ -1161,7 +1178,7 @@ TabContents* Browser::AddTabWithURL(
GURL url_to_load = url;
if (url_to_load.is_empty())
- url_to_load = GURL(profile_->GetPrefs()->GetString(prefs::kHomePage));
+ url_to_load = GetHomePage();
TabContents* contents =
CreateTabContentsForURL(url_to_load, profile_, transition, false,
instance);
@@ -1550,7 +1567,7 @@ NavigationController* Browser::BuildRestoredNavigationController(
// We should have a valid URL, if we don't fall back to the default.
GURL url = navigations[selected_navigation].url;
if (url.is_empty())
- url = GURL(profile_->GetPrefs()->GetString(prefs::kHomePage));
+ url = GetHomePage();
// Create a NavigationController. This constructor creates the appropriate
// set of TabContents.