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

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: 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 757 matching lines...) Expand 10 before | Expand all | Expand 10 after
2225 #else 2227 #else
2226 prefs->RegisterBooleanPref(prefs::kClearPluginLSODataEnabled, false); 2228 prefs->RegisterBooleanPref(prefs::kClearPluginLSODataEnabled, false);
2227 #endif 2229 #endif
2228 } 2230 }
2229 2231
2230 // static 2232 // static
2231 void Browser::RegisterUserPrefs(PrefService* prefs) { 2233 void Browser::RegisterUserPrefs(PrefService* prefs) {
2232 prefs->RegisterStringPref(prefs::kHomePage, 2234 prefs->RegisterStringPref(prefs::kHomePage,
2233 chrome::kChromeUINewTabURL, 2235 chrome::kChromeUINewTabURL,
2234 PrefService::SYNCABLE_PREF); 2236 PrefService::SYNCABLE_PREF);
2237 prefs->RegisterBooleanPref(prefs::kHomePageChanged,
2238 false,
2239 PrefService::UNSYNCABLE_PREF);
2235 prefs->RegisterBooleanPref(prefs::kHomePageIsNewTabPage, 2240 prefs->RegisterBooleanPref(prefs::kHomePageIsNewTabPage,
2236 true, 2241 true,
2237 PrefService::SYNCABLE_PREF); 2242 PrefService::SYNCABLE_PREF);
2238 prefs->RegisterBooleanPref(prefs::kShowHomeButton, 2243 prefs->RegisterBooleanPref(prefs::kShowHomeButton,
2239 false, 2244 false,
2240 PrefService::SYNCABLE_PREF); 2245 PrefService::SYNCABLE_PREF);
2241 #if defined(OS_MACOSX) 2246 #if defined(OS_MACOSX)
2242 // This really belongs in platform code, but there's no good place to 2247 // This really belongs in platform code, but there's no good place to
2243 // initialize it between the time when the AppController is created 2248 // initialize it between the time when the AppController is created
2244 // (where there's no profile) and the time the controller gets another 2249 // (where there's no profile) and the time the controller gets another
(...skipping 1735 matching lines...) Expand 10 before | Expand all | Expand 10 after
3980 IDC_NEW_INCOGNITO_WINDOW, 3985 IDC_NEW_INCOGNITO_WINDOW,
3981 available != IncognitoModePrefs::DISABLED); 3986 available != IncognitoModePrefs::DISABLED);
3982 } else if (pref_name == prefs::kDevToolsDisabled) { 3987 } else if (pref_name == prefs::kDevToolsDisabled) {
3983 UpdateCommandsForDevTools(); 3988 UpdateCommandsForDevTools();
3984 if (profile_->GetPrefs()->GetBoolean(prefs::kDevToolsDisabled)) 3989 if (profile_->GetPrefs()->GetBoolean(prefs::kDevToolsDisabled))
3985 g_browser_process->devtools_manager()->CloseAllClientHosts(); 3990 g_browser_process->devtools_manager()->CloseAllClientHosts();
3986 } else if (pref_name == prefs::kEditBookmarksEnabled) { 3991 } else if (pref_name == prefs::kEditBookmarksEnabled) {
3987 UpdateCommandsForBookmarkEditing(); 3992 UpdateCommandsForBookmarkEditing();
3988 } else if (pref_name == prefs::kEnableBookmarkBar) { 3993 } else if (pref_name == prefs::kEnableBookmarkBar) {
3989 UpdateCommandsForBookmarkBar(); 3994 UpdateCommandsForBookmarkBar();
3995 } else if (pref_name == prefs::kHomePage) {
3996 PrefService* pref_service = Source<PrefService>(source).ptr();
3997 MarkHomePageAsChanged(pref_service);
3990 } else if (pref_name == prefs::kAllowFileSelectionDialogs) { 3998 } else if (pref_name == prefs::kAllowFileSelectionDialogs) {
3991 UpdateSaveAsState(GetContentRestrictionsForSelectedTab()); 3999 UpdateSaveAsState(GetContentRestrictionsForSelectedTab());
3992 UpdateOpenFileState(); 4000 UpdateOpenFileState();
3993 } else { 4001 } else {
3994 NOTREACHED(); 4002 NOTREACHED();
3995 } 4003 }
3996 break; 4004 break;
3997 } 4005 }
3998 4006
3999 case chrome::NOTIFICATION_TAB_CONTENT_SETTINGS_CHANGED: { 4007 case chrome::NOTIFICATION_TAB_CONTENT_SETTINGS_CHANGED: {
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
4432 (!window_ || !window_->IsFullscreen()); 4440 (!window_ || !window_->IsFullscreen());
4433 #else 4441 #else
4434 const bool show_main_ui = is_type_tabbed(); 4442 const bool show_main_ui = is_type_tabbed();
4435 #endif 4443 #endif
4436 command_updater_.UpdateCommandEnabled(IDC_SHOW_BOOKMARK_BAR, 4444 command_updater_.UpdateCommandEnabled(IDC_SHOW_BOOKMARK_BAR,
4437 browser_defaults::bookmarks_enabled && 4445 browser_defaults::bookmarks_enabled &&
4438 !profile_->GetPrefs()->IsManagedPreference(prefs::kEnableBookmarkBar) && 4446 !profile_->GetPrefs()->IsManagedPreference(prefs::kEnableBookmarkBar) &&
4439 show_main_ui); 4447 show_main_ui);
4440 } 4448 }
4441 4449
4450 void Browser::MarkHomePageAsChanged(PrefService* pref_service) {
4451 pref_service->SetBoolean(prefs::kHomePageChanged, true);
4452 pref_service->ScheduleSavePersistentPrefs();
4453 }
4454
4442 void Browser::UpdateSaveAsState(int content_restrictions) { 4455 void Browser::UpdateSaveAsState(int content_restrictions) {
4443 bool enabled = !(content_restrictions & CONTENT_RESTRICTION_SAVE); 4456 bool enabled = !(content_restrictions & CONTENT_RESTRICTION_SAVE);
4444 PrefService* state = g_browser_process->local_state(); 4457 PrefService* state = g_browser_process->local_state();
4445 if (state) 4458 if (state)
4446 enabled = enabled && state->GetBoolean(prefs::kAllowFileSelectionDialogs); 4459 enabled = enabled && state->GetBoolean(prefs::kAllowFileSelectionDialogs);
4447 4460
4448 command_updater_.UpdateCommandEnabled(IDC_SAVE_PAGE, enabled); 4461 command_updater_.UpdateCommandEnabled(IDC_SAVE_PAGE, enabled);
4449 } 4462 }
4450 4463
4451 void Browser::UpdateOpenFileState() { 4464 void Browser::UpdateOpenFileState() {
(...skipping 664 matching lines...) Expand 10 before | Expand all | Expand 10 after
5116 } 5129 }
5117 5130
5118 void Browser::ShowSyncSetup() { 5131 void Browser::ShowSyncSetup() {
5119 ProfileSyncService* service = 5132 ProfileSyncService* service =
5120 profile()->GetOriginalProfile()->GetProfileSyncService(); 5133 profile()->GetOriginalProfile()->GetProfileSyncService();
5121 if (service->HasSyncSetupCompleted()) 5134 if (service->HasSyncSetupCompleted())
5122 ShowOptionsTab(chrome::kSyncSetupSubPage); 5135 ShowOptionsTab(chrome::kSyncSetupSubPage);
5123 else 5136 else
5124 service->ShowLoginDialog(); 5137 service->ShowLoginDialog();
5125 } 5138 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698