summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authormarja@chromium.org <marja@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-17 10:48:26 +0000
committermarja@chromium.org <marja@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-17 10:48:26 +0000
commit1848cdcc360745bb05cb8ace1f8514f48f6e4e8d (patch)
tree52dc78729e210ea3cccf531297a8cc72c068ca3d /chrome/browser
parent95aa0fe92dfe4e0ed05e5c12732c014aa2039dc1 (diff)
downloadchromium_src-1848cdcc360745bb05cb8ace1f8514f48f6e4e8d.zip
chromium_src-1848cdcc360745bb05cb8ace1f8514f48f6e4e8d.tar.gz
chromium_src-1848cdcc360745bb05cb8ace1f8514f48f6e4e8d.tar.bz2
Plugins: allow saving data if we're going to do a session restore.
BUG=104289 TEST=Manual session restore tests. Review URL: http://codereview.chromium.org/9417003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@122486 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/chrome_content_browser_client.cc13
-rw-r--r--chrome/browser/prefs/session_startup_pref.cc20
-rw-r--r--chrome/browser/prefs/session_startup_pref.h5
-rw-r--r--chrome/browser/profiles/profile_impl_io_data.cc3
-rw-r--r--chrome/browser/profiles/profile_io_data.cc1
-rw-r--r--chrome/browser/profiles/profile_io_data.h5
6 files changed, 35 insertions, 12 deletions
diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc
index f440690..384bfae 100644
--- a/chrome/browser/chrome_content_browser_client.cc
+++ b/chrome/browser/chrome_content_browser_client.cc
@@ -813,7 +813,18 @@ bool ChromeContentBrowserClient::AllowSaveLocalState(
content::ResourceContext* context) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
- return !io_data->clear_local_state_on_exit()->GetValue();
+
+ if (!io_data->clear_local_state_on_exit()->GetValue())
+ return true;
+
+ // Disable clearning the local state on exit if the browsing session is going
+ // to be restored on the next startup.
+ SessionStartupPref::Type startup_pref =
+ SessionStartupPref::PrefValueToType(
+ io_data->session_startup_pref()->GetValue());
+ return (startup_pref == SessionStartupPref::LAST &&
+ CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableRestoreSessionState));
}
bool ChromeContentBrowserClient::AllowWorkerDatabase(
diff --git a/chrome/browser/prefs/session_startup_pref.cc b/chrome/browser/prefs/session_startup_pref.cc
index a441a4c..8ed1cae 100644
--- a/chrome/browser/prefs/session_startup_pref.cc
+++ b/chrome/browser/prefs/session_startup_pref.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -37,15 +37,6 @@ int TypeToPrefValue(SessionStartupPref::Type type) {
}
}
-// Converts an integer pref value to a SessionStartupPref::Type.
-SessionStartupPref::Type PrefValueToType(int pref_value) {
- switch (pref_value) {
- case kPrefValueLast: return SessionStartupPref::LAST;
- case kPrefValueURLs: return SessionStartupPref::URLS;
- default: return SessionStartupPref::DEFAULT;
- }
-}
-
} // namespace
// static
@@ -152,6 +143,15 @@ bool SessionStartupPref::URLsAreManaged(PrefService* prefs) {
return pref_urls->IsManaged();
}
+// static
+SessionStartupPref::Type SessionStartupPref::PrefValueToType(int pref_value) {
+ switch (pref_value) {
+ case kPrefValueLast: return SessionStartupPref::LAST;
+ case kPrefValueURLs: return SessionStartupPref::URLS;
+ default: return SessionStartupPref::DEFAULT;
+ }
+}
+
SessionStartupPref::SessionStartupPref() : type(DEFAULT) {}
SessionStartupPref::SessionStartupPref(Type type) : type(type) {}
diff --git a/chrome/browser/prefs/session_startup_pref.h b/chrome/browser/prefs/session_startup_pref.h
index c536da5..226ce01 100644
--- a/chrome/browser/prefs/session_startup_pref.h
+++ b/chrome/browser/prefs/session_startup_pref.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -41,6 +41,9 @@ struct SessionStartupPref {
static bool TypeIsManaged(PrefService* prefs);
static bool URLsAreManaged(PrefService* prefs);
+ // Converts an integer pref value to a SessionStartupPref::Type.
+ static SessionStartupPref::Type PrefValueToType(int pref_value);
+
SessionStartupPref();
explicit SessionStartupPref(Type type);
diff --git a/chrome/browser/profiles/profile_impl_io_data.cc b/chrome/browser/profiles/profile_impl_io_data.cc
index 6e9deee..3481fda 100644
--- a/chrome/browser/profiles/profile_impl_io_data.cc
+++ b/chrome/browser/profiles/profile_impl_io_data.cc
@@ -232,6 +232,9 @@ void ProfileImplIOData::Handle::LazyInitialize() const {
io_data_->clear_local_state_on_exit()->Init(
prefs::kClearSiteDataOnExit, pref_service, NULL);
io_data_->clear_local_state_on_exit()->MoveToThread(BrowserThread::IO);
+ io_data_->session_startup_pref()->Init(
+ prefs::kRestoreOnStartup, pref_service, NULL);
+ io_data_->session_startup_pref()->MoveToThread(BrowserThread::IO);
#if defined(ENABLE_SAFE_BROWSING)
io_data_->safe_browsing_enabled()->Init(prefs::kSafeBrowsingEnabled,
pref_service, NULL);
diff --git a/chrome/browser/profiles/profile_io_data.cc b/chrome/browser/profiles/profile_io_data.cc
index f181460..5e761a1 100644
--- a/chrome/browser/profiles/profile_io_data.cc
+++ b/chrome/browser/profiles/profile_io_data.cc
@@ -623,6 +623,7 @@ void ProfileIOData::ShutdownOnUIThread() {
enable_referrers_.Destroy();
clear_local_state_on_exit_.Destroy();
safe_browsing_enabled_.Destroy();
+ session_startup_pref_.Destroy();
#if defined(ENABLE_CONFIGURATION_POLICY)
if (url_blacklist_manager_.get())
url_blacklist_manager_->ShutdownOnUIThread();
diff --git a/chrome/browser/profiles/profile_io_data.h b/chrome/browser/profiles/profile_io_data.h
index 1ecc3cc..ce970ee 100644
--- a/chrome/browser/profiles/profile_io_data.h
+++ b/chrome/browser/profiles/profile_io_data.h
@@ -109,6 +109,10 @@ class ProfileIOData {
return &clear_local_state_on_exit_;
}
+ IntegerPrefMember* session_startup_pref() const {
+ return &session_startup_pref_;
+ }
+
ChromeURLRequestContext* extensions_request_context() const {
return extensions_request_context_.get();
}
@@ -300,6 +304,7 @@ class ProfileIOData {
mutable BooleanPrefMember enable_referrers_;
mutable BooleanPrefMember clear_local_state_on_exit_;
mutable BooleanPrefMember safe_browsing_enabled_;
+ mutable IntegerPrefMember session_startup_pref_;
// Pointed to by NetworkDelegate.
mutable scoped_ptr<policy::URLBlacklistManager> url_blacklist_manager_;