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

Side by Side Diff: chrome/browser/ui/browser.cc

Issue 7791029: When the user navigates to the home page, make sure to set the RLZ string (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Taking out session restore changes, not needed Created 9 years, 3 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/ui/browser.h" 5 #include "chrome/browser/ui/browser.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <windows.h> 8 #include <windows.h>
9 #include <shellapi.h> 9 #include <shellapi.h>
10 #endif // OS_WIN 10 #endif // OS_WIN
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 local_pref_registrar_.Init(local_state); 302 local_pref_registrar_.Init(local_state);
303 local_pref_registrar_.Add(prefs::kPrintingEnabled, this); 303 local_pref_registrar_.Add(prefs::kPrintingEnabled, this);
304 local_pref_registrar_.Add(prefs::kAllowFileSelectionDialogs, this); 304 local_pref_registrar_.Add(prefs::kAllowFileSelectionDialogs, this);
305 local_pref_registrar_.Add(prefs::kMetricsReportingEnabled, this); 305 local_pref_registrar_.Add(prefs::kMetricsReportingEnabled, this);
306 } 306 }
307 307
308 profile_pref_registrar_.Init(profile_->GetPrefs()); 308 profile_pref_registrar_.Init(profile_->GetPrefs());
309 profile_pref_registrar_.Add(prefs::kDevToolsDisabled, this); 309 profile_pref_registrar_.Add(prefs::kDevToolsDisabled, this);
310 profile_pref_registrar_.Add(prefs::kEditBookmarksEnabled, this); 310 profile_pref_registrar_.Add(prefs::kEditBookmarksEnabled, this);
311 profile_pref_registrar_.Add(prefs::kEnableBookmarkBar, this); 311 profile_pref_registrar_.Add(prefs::kEnableBookmarkBar, this);
312 profile_pref_registrar_.Add(prefs::kHomePage, this);
312 profile_pref_registrar_.Add(prefs::kInstantEnabled, this); 313 profile_pref_registrar_.Add(prefs::kInstantEnabled, this);
313 profile_pref_registrar_.Add(prefs::kIncognitoModeAvailability, this); 314 profile_pref_registrar_.Add(prefs::kIncognitoModeAvailability, this);
314 profile_pref_registrar_.Add(prefs::kSearchSuggestEnabled, this); 315 profile_pref_registrar_.Add(prefs::kSearchSuggestEnabled, this);
315 316
316 InitCommandState(); 317 InitCommandState();
317 BrowserList::AddBrowser(this); 318 BrowserList::AddBrowser(this);
318 319
319 // NOTE: These prefs all need to be explicitly destroyed in the destructor 320 // NOTE: These prefs all need to be explicitly destroyed in the destructor
320 // or you'll get a nasty surprise when you run the incognito tests. 321 // or you'll get a nasty surprise when you run the incognito tests.
321 encoding_auto_detect_.Init(prefs::kWebKitUsesUniversalDetector, 322 encoding_auto_detect_.Init(prefs::kWebKitUsesUniversalDetector,
(...skipping 1125 matching lines...) Expand 10 before | Expand all | Expand 10 after
1447 if (!tab->FocusLocationBarByDefault()) 1448 if (!tab->FocusLocationBarByDefault())
1448 tab->Focus(); 1449 tab->Focus();
1449 if (ignore_cache) 1450 if (ignore_cache)
1450 tab->controller().ReloadIgnoringCache(true); 1451 tab->controller().ReloadIgnoringCache(true);
1451 else 1452 else
1452 tab->controller().Reload(true); 1453 tab->controller().Reload(true);
1453 } 1454 }
1454 1455
1455 void Browser::Home(WindowOpenDisposition disposition) { 1456 void Browser::Home(WindowOpenDisposition disposition) {
1456 UserMetrics::RecordAction(UserMetricsAction("Home")); 1457 UserMetrics::RecordAction(UserMetricsAction("Home"));
1457 OpenURL(GetHomePage(), GURL(), disposition, PageTransition::AUTO_BOOKMARK); 1458 OpenURL(GetHomePage(), GURL(), disposition,
1459 PageTransition::AUTO_BOOKMARK | PageTransition::HOME_PAGE);
1458 } 1460 }
1459 1461
1460 void Browser::OpenCurrentURL() { 1462 void Browser::OpenCurrentURL() {
1461 UserMetrics::RecordAction(UserMetricsAction("LoadURL")); 1463 UserMetrics::RecordAction(UserMetricsAction("LoadURL"));
1462 LocationBar* location_bar = window_->GetLocationBar(); 1464 LocationBar* location_bar = window_->GetLocationBar();
1463 if (!location_bar) 1465 if (!location_bar)
1464 return; 1466 return;
1465 1467
1466 WindowOpenDisposition open_disposition = 1468 WindowOpenDisposition open_disposition =
1467 location_bar->GetWindowOpenDisposition(); 1469 location_bar->GetWindowOpenDisposition();
(...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after
2224 #else 2226 #else
2225 prefs->RegisterBooleanPref(prefs::kClearPluginLSODataEnabled, false); 2227 prefs->RegisterBooleanPref(prefs::kClearPluginLSODataEnabled, false);
2226 #endif 2228 #endif
2227 } 2229 }
2228 2230
2229 // static 2231 // static
2230 void Browser::RegisterUserPrefs(PrefService* prefs) { 2232 void Browser::RegisterUserPrefs(PrefService* prefs) {
2231 prefs->RegisterStringPref(prefs::kHomePage, 2233 prefs->RegisterStringPref(prefs::kHomePage,
2232 chrome::kChromeUINewTabURL, 2234 chrome::kChromeUINewTabURL,
2233 PrefService::SYNCABLE_PREF); 2235 PrefService::SYNCABLE_PREF);
2236 prefs->RegisterBooleanPref(prefs::kHomePageChanged,
2237 false,
2238 PrefService::UNSYNCABLE_PREF);
2234 prefs->RegisterBooleanPref(prefs::kHomePageIsNewTabPage, 2239 prefs->RegisterBooleanPref(prefs::kHomePageIsNewTabPage,
2235 true, 2240 true,
2236 PrefService::SYNCABLE_PREF); 2241 PrefService::SYNCABLE_PREF);
2237 prefs->RegisterBooleanPref(prefs::kShowHomeButton, 2242 prefs->RegisterBooleanPref(prefs::kShowHomeButton,
2238 false, 2243 false,
2239 PrefService::SYNCABLE_PREF); 2244 PrefService::SYNCABLE_PREF);
2240 #if defined(OS_MACOSX) 2245 #if defined(OS_MACOSX)
2241 // This really belongs in platform code, but there's no good place to 2246 // This really belongs in platform code, but there's no good place to
2242 // initialize it between the time when the AppController is created 2247 // initialize it between the time when the AppController is created
2243 // (where there's no profile) and the time the controller gets another 2248 // (where there's no profile) and the time the controller gets another
(...skipping 1740 matching lines...) Expand 10 before | Expand all | Expand 10 after
3984 IDC_NEW_INCOGNITO_WINDOW, 3989 IDC_NEW_INCOGNITO_WINDOW,
3985 available != IncognitoModePrefs::DISABLED); 3990 available != IncognitoModePrefs::DISABLED);
3986 } else if (pref_name == prefs::kDevToolsDisabled) { 3991 } else if (pref_name == prefs::kDevToolsDisabled) {
3987 UpdateCommandsForDevTools(); 3992 UpdateCommandsForDevTools();
3988 if (profile_->GetPrefs()->GetBoolean(prefs::kDevToolsDisabled)) 3993 if (profile_->GetPrefs()->GetBoolean(prefs::kDevToolsDisabled))
3989 g_browser_process->devtools_manager()->CloseAllClientHosts(); 3994 g_browser_process->devtools_manager()->CloseAllClientHosts();
3990 } else if (pref_name == prefs::kEditBookmarksEnabled) { 3995 } else if (pref_name == prefs::kEditBookmarksEnabled) {
3991 UpdateCommandsForBookmarkEditing(); 3996 UpdateCommandsForBookmarkEditing();
3992 } else if (pref_name == prefs::kEnableBookmarkBar) { 3997 } else if (pref_name == prefs::kEnableBookmarkBar) {
3993 UpdateCommandsForBookmarkBar(); 3998 UpdateCommandsForBookmarkBar();
3999 } else if (pref_name == prefs::kHomePage) {
4000 PrefService* pref_service = Source<PrefService>(source).ptr();
4001 MarkHomePageAsChanged(pref_service);
3994 } else if (pref_name == prefs::kAllowFileSelectionDialogs) { 4002 } else if (pref_name == prefs::kAllowFileSelectionDialogs) {
3995 UpdateSaveAsState(GetContentRestrictionsForSelectedTab()); 4003 UpdateSaveAsState(GetContentRestrictionsForSelectedTab());
3996 UpdateOpenFileState(); 4004 UpdateOpenFileState();
3997 } else { 4005 } else {
3998 NOTREACHED(); 4006 NOTREACHED();
3999 } 4007 }
4000 break; 4008 break;
4001 } 4009 }
4002 4010
4003 case chrome::NOTIFICATION_TAB_CONTENT_SETTINGS_CHANGED: { 4011 case chrome::NOTIFICATION_TAB_CONTENT_SETTINGS_CHANGED: {
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
4436 (!window_ || !window_->IsFullscreen()); 4444 (!window_ || !window_->IsFullscreen());
4437 #else 4445 #else
4438 const bool show_main_ui = is_type_tabbed(); 4446 const bool show_main_ui = is_type_tabbed();
4439 #endif 4447 #endif
4440 command_updater_.UpdateCommandEnabled(IDC_SHOW_BOOKMARK_BAR, 4448 command_updater_.UpdateCommandEnabled(IDC_SHOW_BOOKMARK_BAR,
4441 browser_defaults::bookmarks_enabled && 4449 browser_defaults::bookmarks_enabled &&
4442 !profile_->GetPrefs()->IsManagedPreference(prefs::kEnableBookmarkBar) && 4450 !profile_->GetPrefs()->IsManagedPreference(prefs::kEnableBookmarkBar) &&
4443 show_main_ui); 4451 show_main_ui);
4444 } 4452 }
4445 4453
4454 void Browser::MarkHomePageAsChanged(PrefService* pref_service) {
4455 pref_service->SetBoolean(prefs::kHomePageChanged, true);
4456 pref_service->ScheduleSavePersistentPrefs();
4457 }
4458
4446 void Browser::UpdateSaveAsState(int content_restrictions) { 4459 void Browser::UpdateSaveAsState(int content_restrictions) {
4447 bool enabled = !(content_restrictions & CONTENT_RESTRICTION_SAVE); 4460 bool enabled = !(content_restrictions & CONTENT_RESTRICTION_SAVE);
4448 PrefService* state = g_browser_process->local_state(); 4461 PrefService* state = g_browser_process->local_state();
4449 if (state) 4462 if (state)
4450 enabled = enabled && state->GetBoolean(prefs::kAllowFileSelectionDialogs); 4463 enabled = enabled && state->GetBoolean(prefs::kAllowFileSelectionDialogs);
4451 4464
4452 command_updater_.UpdateCommandEnabled(IDC_SAVE_PAGE, enabled); 4465 command_updater_.UpdateCommandEnabled(IDC_SAVE_PAGE, enabled);
4453 } 4466 }
4454 4467
4455 void Browser::UpdateOpenFileState() { 4468 void Browser::UpdateOpenFileState() {
(...skipping 664 matching lines...) Expand 10 before | Expand all | Expand 10 after
5120 } 5133 }
5121 5134
5122 void Browser::ShowSyncSetup() { 5135 void Browser::ShowSyncSetup() {
5123 ProfileSyncService* service = 5136 ProfileSyncService* service =
5124 profile()->GetOriginalProfile()->GetProfileSyncService(); 5137 profile()->GetOriginalProfile()->GetProfileSyncService();
5125 if (service->HasSyncSetupCompleted()) 5138 if (service->HasSyncSetupCompleted())
5126 ShowOptionsTab(chrome::kSyncSetupSubPage); 5139 ShowOptionsTab(chrome::kSyncSetupSubPage);
5127 else 5140 else
5128 service->ShowLoginDialog(); 5141 service->ShowLoginDialog();
5129 } 5142 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698