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

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

Issue 6247017: Revert 72153 - Remove user-related data from local_state and add to user_pre... (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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/browser.h ('k') | chrome/browser/ui/cocoa/browser_window_controller.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <shellapi.h> 8 #include <shellapi.h>
9 #include <windows.h> 9 #include <windows.h>
10 #endif // OS_WIN 10 #endif // OS_WIN
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 url = extension->GetFullLaunchURL(); 536 url = extension->GetFullLaunchURL();
537 } 537 }
538 538
539 std::string app_name; 539 std::string app_name;
540 if (extension) 540 if (extension)
541 app_name = 541 app_name =
542 web_app::GenerateApplicationNameFromExtensionId(extension->id()); 542 web_app::GenerateApplicationNameFromExtensionId(extension->id());
543 else 543 else
544 app_name = web_app::GenerateApplicationNameFromURL(url); 544 app_name = web_app::GenerateApplicationNameFromURL(url);
545 545
546 RegisterAppPrefs(app_name, profile); 546 RegisterAppPrefs(app_name);
547 547
548 bool as_panel = extension && (container == extension_misc::LAUNCH_PANEL); 548 bool as_panel = extension && (container == extension_misc::LAUNCH_PANEL);
549 549
550 gfx::Size window_size; 550 gfx::Size window_size;
551 if (extension) 551 if (extension)
552 window_size.SetSize(extension->launch_width(), 552 window_size.SetSize(extension->launch_width(),
553 extension->launch_height()); 553 extension->launch_height());
554 554
555 Browser* browser = Browser::CreateForApp(app_name, window_size, profile, 555 Browser* browser = Browser::CreateForApp(app_name, window_size, profile,
556 as_panel); 556 as_panel);
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
732 // In playback/record mode we always fix the size of the browser and 732 // In playback/record mode we always fix the size of the browser and
733 // move it to (0,0). The reason for this is two reasons: First we want 733 // move it to (0,0). The reason for this is two reasons: First we want
734 // resize/moves in the playback to still work, and Second we want 734 // resize/moves in the playback to still work, and Second we want
735 // playbacks to work (as much as possible) on machines w/ different 735 // playbacks to work (as much as possible) on machines w/ different
736 // screen sizes. 736 // screen sizes.
737 return gfx::Rect(0, 0, 800, 600); 737 return gfx::Rect(0, 0, 800, 600);
738 } 738 }
739 739
740 gfx::Rect restored_bounds = override_bounds_; 740 gfx::Rect restored_bounds = override_bounds_;
741 bool maximized; 741 bool maximized;
742 WindowSizer::GetBrowserWindowBounds(app_name_, restored_bounds, this, 742 WindowSizer::GetBrowserWindowBounds(app_name_, restored_bounds, NULL,
743 &restored_bounds, &maximized); 743 &restored_bounds, &maximized);
744 return restored_bounds; 744 return restored_bounds;
745 } 745 }
746 746
747 // TODO(beng): obtain maximized state some other way so we don't need to go 747 // TODO(beng): obtain maximized state some other way so we don't need to go
748 // through all this hassle. 748 // through all this hassle.
749 bool Browser::GetSavedMaximizedState() const { 749 bool Browser::GetSavedMaximizedState() const {
750 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kStartMaximized)) 750 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kStartMaximized))
751 return true; 751 return true;
752 752
753 if (maximized_state_ == MAXIMIZED_STATE_MAXIMIZED) 753 if (maximized_state_ == MAXIMIZED_STATE_MAXIMIZED)
754 return true; 754 return true;
755 if (maximized_state_ == MAXIMIZED_STATE_UNMAXIMIZED) 755 if (maximized_state_ == MAXIMIZED_STATE_UNMAXIMIZED)
756 return false; 756 return false;
757 757
758 // An explicit maximized state was not set. Query the window sizer. 758 // An explicit maximized state was not set. Query the window sizer.
759 gfx::Rect restored_bounds; 759 gfx::Rect restored_bounds;
760 bool maximized = false; 760 bool maximized = false;
761 WindowSizer::GetBrowserWindowBounds(app_name_, restored_bounds, this, 761 WindowSizer::GetBrowserWindowBounds(app_name_, restored_bounds, NULL,
762 &restored_bounds, &maximized); 762 &restored_bounds, &maximized);
763 return maximized; 763 return maximized;
764 } 764 }
765 765
766 SkBitmap Browser::GetCurrentPageIcon() const { 766 SkBitmap Browser::GetCurrentPageIcon() const {
767 TabContents* contents = GetSelectedTabContents(); 767 TabContents* contents = GetSelectedTabContents();
768 // |contents| can be NULL since GetCurrentPageIcon() is called by the window 768 // |contents| can be NULL since GetCurrentPageIcon() is called by the window
769 // during the window's creation (before tabs have been added). 769 // during the window's creation (before tabs have been added).
770 return contents ? contents->GetFavIcon() : SkBitmap(); 770 return contents ? contents->GetFavIcon() : SkBitmap();
771 } 771 }
(...skipping 1195 matching lines...) Expand 10 before | Expand all | Expand 10 after
1967 const PrefService::Preference* home_page_is_new_tab_page_pref = 1967 const PrefService::Preference* home_page_is_new_tab_page_pref =
1968 prefs->FindPreference(prefs::kHomePageIsNewTabPage); 1968 prefs->FindPreference(prefs::kHomePageIsNewTabPage);
1969 if (home_page_is_new_tab_page_pref && 1969 if (home_page_is_new_tab_page_pref &&
1970 !home_page_is_new_tab_page_pref->IsManaged() && 1970 !home_page_is_new_tab_page_pref->IsManaged() &&
1971 !prefs->HasPrefPath(prefs::kHomePageIsNewTabPage)) 1971 !prefs->HasPrefPath(prefs::kHomePageIsNewTabPage))
1972 prefs->SetBoolean(prefs::kHomePageIsNewTabPage, false); 1972 prefs->SetBoolean(prefs::kHomePageIsNewTabPage, false);
1973 } 1973 }
1974 1974
1975 // static 1975 // static
1976 void Browser::RegisterPrefs(PrefService* prefs) { 1976 void Browser::RegisterPrefs(PrefService* prefs) {
1977 prefs->RegisterDictionaryPref(prefs::kBrowserWindowPlacement);
1977 prefs->RegisterIntegerPref(prefs::kOptionsWindowLastTabIndex, 0); 1978 prefs->RegisterIntegerPref(prefs::kOptionsWindowLastTabIndex, 0);
1979 prefs->RegisterIntegerPref(prefs::kDevToolsSplitLocation, -1);
1978 prefs->RegisterDictionaryPref(prefs::kPreferencesWindowPlacement); 1980 prefs->RegisterDictionaryPref(prefs::kPreferencesWindowPlacement);
1979 prefs->RegisterIntegerPref(prefs::kExtensionSidebarWidth, -1); 1981 prefs->RegisterIntegerPref(prefs::kExtensionSidebarWidth, -1);
1980 prefs->RegisterIntegerPref(prefs::kMultipleProfilePrefMigration, 0);
1981 // Educated guess: Chrome has a bundled Flash version supporting 1982 // Educated guess: Chrome has a bundled Flash version supporting
1982 // clearing LSO data, Chromium hasn't. 1983 // clearing LSO data, Chromium hasn't.
1983 #if defined(GOOGLE_CHROME_BUILD) 1984 #if defined(GOOGLE_CHROME_BUILD)
1984 prefs->RegisterBooleanPref(prefs::kClearPluginLSODataEnabled, true); 1985 prefs->RegisterBooleanPref(prefs::kClearPluginLSODataEnabled, true);
1985 #else 1986 #else
1986 prefs->RegisterBooleanPref(prefs::kClearPluginLSODataEnabled, false); 1987 prefs->RegisterBooleanPref(prefs::kClearPluginLSODataEnabled, false);
1987 #endif 1988 #endif
1988 } 1989 }
1989 1990
1990 // static 1991 // static
(...skipping 27 matching lines...) Expand all
2018 prefs->RegisterBooleanPref(prefs::kShowOmniboxSearchHint, true); 2019 prefs->RegisterBooleanPref(prefs::kShowOmniboxSearchHint, true);
2019 prefs->RegisterBooleanPref(prefs::kWebAppCreateOnDesktop, true); 2020 prefs->RegisterBooleanPref(prefs::kWebAppCreateOnDesktop, true);
2020 prefs->RegisterBooleanPref(prefs::kWebAppCreateInAppsMenu, true); 2021 prefs->RegisterBooleanPref(prefs::kWebAppCreateInAppsMenu, true);
2021 prefs->RegisterBooleanPref(prefs::kWebAppCreateInQuickLaunchBar, true); 2022 prefs->RegisterBooleanPref(prefs::kWebAppCreateInQuickLaunchBar, true);
2022 prefs->RegisterBooleanPref(prefs::kUseVerticalTabs, false); 2023 prefs->RegisterBooleanPref(prefs::kUseVerticalTabs, false);
2023 prefs->RegisterBooleanPref(prefs::kEnableTranslate, true); 2024 prefs->RegisterBooleanPref(prefs::kEnableTranslate, true);
2024 prefs->RegisterBooleanPref(prefs::kRemotingHasSetupCompleted, false); 2025 prefs->RegisterBooleanPref(prefs::kRemotingHasSetupCompleted, false);
2025 prefs->RegisterStringPref(prefs::kCloudPrintEmail, std::string()); 2026 prefs->RegisterStringPref(prefs::kCloudPrintEmail, std::string());
2026 prefs->RegisterBooleanPref(prefs::kDevToolsDisabled, false); 2027 prefs->RegisterBooleanPref(prefs::kDevToolsDisabled, false);
2027 prefs->RegisterRealPref(prefs::kDefaultZoomLevel, 0.0); 2028 prefs->RegisterRealPref(prefs::kDefaultZoomLevel, 0.0);
2028 prefs->RegisterIntegerPref(prefs::kDevToolsSplitLocation, -1); 2029 prefs->RegisterIntegerPref(prefs::kMultipleProfilePrefMigration, 0);
2029 prefs->RegisterDictionaryPref(prefs::kBrowserWindowPlacement);
2030 // We need to register the type of this preference in order to query 2030 // We need to register the type of this preference in order to query
2031 // it even though it's only typically controlled via policy. 2031 // it even though it's only typically controlled via policy.
2032 prefs->RegisterBooleanPref(prefs::kDisable3DAPIs, false); 2032 prefs->RegisterBooleanPref(prefs::kDisable3DAPIs, false);
2033 } 2033 }
2034 2034
2035 // static 2035 // static
2036 bool Browser::RunUnloadEventsHelper(TabContents* contents) { 2036 bool Browser::RunUnloadEventsHelper(TabContents* contents) {
2037 // If the TabContents is not connected yet, then there's no unload 2037 // If the TabContents is not connected yet, then there's no unload
2038 // handler we can fire even if the TabContents has an unload listener. 2038 // handler we can fire even if the TabContents has an unload listener.
2039 // One case where we hit this is in a tab that has an infinite loop 2039 // One case where we hit this is in a tab that has an infinite loop
(...skipping 917 matching lines...) Expand 10 before | Expand all | Expand 10 after
2957 return false; 2957 return false;
2958 } 2958 }
2959 2959
2960 bool Browser::IsApplication() const { 2960 bool Browser::IsApplication() const {
2961 return (type_ & TYPE_APP) != 0; 2961 return (type_ & TYPE_APP) != 0;
2962 } 2962 }
2963 2963
2964 void Browser::ConvertContentsToApplication(TabContents* contents) { 2964 void Browser::ConvertContentsToApplication(TabContents* contents) {
2965 const GURL& url = contents->controller().GetActiveEntry()->url(); 2965 const GURL& url = contents->controller().GetActiveEntry()->url();
2966 std::string app_name = web_app::GenerateApplicationNameFromURL(url); 2966 std::string app_name = web_app::GenerateApplicationNameFromURL(url);
2967 RegisterAppPrefs(app_name, contents->profile()); 2967 RegisterAppPrefs(app_name);
2968 2968
2969 DetachContents(contents); 2969 DetachContents(contents);
2970 Browser* app_browser = Browser::CreateForApp( 2970 Browser* app_browser = Browser::CreateForApp(
2971 app_name, gfx::Size(), profile_, false); 2971 app_name, gfx::Size(), profile_, false);
2972 TabContentsWrapper* wrapper = new TabContentsWrapper(contents); 2972 TabContentsWrapper* wrapper = new TabContentsWrapper(contents);
2973 app_browser->tabstrip_model()->AppendTabContents(wrapper, true); 2973 app_browser->tabstrip_model()->AppendTabContents(wrapper, true);
2974 2974
2975 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; 2975 contents->GetMutableRendererPrefs()->can_accept_load_drops = false;
2976 contents->render_view_host()->SyncRendererPrefs(); 2976 contents->render_view_host()->SyncRendererPrefs();
2977 app_browser->window()->Show(); 2977 app_browser->window()->Show();
(...skipping 1133 matching lines...) Expand 10 before | Expand all | Expand 10 after
4111 // us). Avoid that by passing in false so that the call to 4111 // us). Avoid that by passing in false so that the call to
4112 // ProcessPendingTabs is delayed. 4112 // ProcessPendingTabs is delayed.
4113 ClearUnloadState(contents->tab_contents(), false); 4113 ClearUnloadState(contents->tab_contents(), false);
4114 } 4114 }
4115 4115
4116 registrar_.Remove(this, NotificationType::TAB_CONTENTS_DISCONNECTED, 4116 registrar_.Remove(this, NotificationType::TAB_CONTENTS_DISCONNECTED,
4117 Source<TabContentsWrapper>(contents)); 4117 Source<TabContentsWrapper>(contents));
4118 } 4118 }
4119 4119
4120 // static 4120 // static
4121 void Browser::RegisterAppPrefs(const std::string& app_name, Profile* profile) { 4121 void Browser::RegisterAppPrefs(const std::string& app_name) {
4122 // A set of apps that we've already started. 4122 // A set of apps that we've already started.
4123 static std::set<std::string>* g_app_names = NULL; 4123 static std::set<std::string>* g_app_names = NULL;
4124 4124
4125 if (!g_app_names) 4125 if (!g_app_names)
4126 g_app_names = new std::set<std::string>; 4126 g_app_names = new std::set<std::string>;
4127 4127
4128 // Only register once for each app name. 4128 // Only register once for each app name.
4129 if (g_app_names->find(app_name) != g_app_names->end()) 4129 if (g_app_names->find(app_name) != g_app_names->end())
4130 return; 4130 return;
4131 g_app_names->insert(app_name); 4131 g_app_names->insert(app_name);
4132 4132
4133 // We need to register the window position pref. 4133 // We need to register the window position pref.
4134 std::string window_pref(prefs::kBrowserWindowPlacement); 4134 std::string window_pref(prefs::kBrowserWindowPlacement);
4135 window_pref.append("_"); 4135 window_pref.append("_");
4136 window_pref.append(app_name); 4136 window_pref.append(app_name);
4137 profile->GetPrefs()->RegisterDictionaryPref(window_pref.c_str()); 4137 PrefService* prefs = g_browser_process->local_state();
4138 DCHECK(prefs);
4139
4140 prefs->RegisterDictionaryPref(window_pref.c_str());
4138 } 4141 }
4139 4142
4140 void Browser::TabRestoreServiceChanged(TabRestoreService* service) { 4143 void Browser::TabRestoreServiceChanged(TabRestoreService* service) {
4141 command_updater_.UpdateCommandEnabled(IDC_RESTORE_TAB, 4144 command_updater_.UpdateCommandEnabled(IDC_RESTORE_TAB,
4142 !service->entries().empty()); 4145 !service->entries().empty());
4143 } 4146 }
4144 4147
4145 void Browser::TabRestoreServiceDestroyed(TabRestoreService* service) { 4148 void Browser::TabRestoreServiceDestroyed(TabRestoreService* service) {
4146 if (!tab_restore_service_) 4149 if (!tab_restore_service_)
4147 return; 4150 return;
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
4259 // The page transition below is only for the purpose of inserting the tab. 4262 // The page transition below is only for the purpose of inserting the tab.
4260 browser->AddTab(view_source_contents, PageTransition::LINK); 4263 browser->AddTab(view_source_contents, PageTransition::LINK);
4261 } 4264 }
4262 4265
4263 if (profile_->HasSessionService()) { 4266 if (profile_->HasSessionService()) {
4264 SessionService* session_service = profile_->GetSessionService(); 4267 SessionService* session_service = profile_->GetSessionService();
4265 if (session_service) 4268 if (session_service)
4266 session_service->TabRestored(&view_source_contents->controller(), false); 4269 session_service->TabRestored(&view_source_contents->controller(), false);
4267 } 4270 }
4268 } 4271 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser.h ('k') | chrome/browser/ui/cocoa/browser_window_controller.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698