diff options
author | mirandac@chromium.org <mirandac@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-30 18:51:54 +0000 |
---|---|---|
committer | mirandac@chromium.org <mirandac@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-30 18:51:54 +0000 |
commit | d5a1916d50693b037f983a893c74f9408692dd2b (patch) | |
tree | 9cfd9a468b80b13c3f8cc3ac38522add9527e58a | |
parent | e08ac26c039520b8bfdcf518f5b7de64cdadd0b7 (diff) | |
download | chromium_src-d5a1916d50693b037f983a893c74f9408692dd2b.zip chromium_src-d5a1916d50693b037f983a893c74f9408692dd2b.tar.gz chromium_src-d5a1916d50693b037f983a893c74f9408692dd2b.tar.bz2 |
Make kClearSiteDataOnExit work for Flash plugins in a multi-profile environment.
Because Flash data is global among all profiles (and all browsers) on a machine, we can't clear site data easily per profile on exit. Instead, if this flag is set, we run Flash instances in Incognito mode for profiles that want to leave no data stored on exit.
BUG=80794
TEST=
Review URL: http://codereview.chromium.org/7230052
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@91168 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/browser_process_impl.cc | 27 | ||||
-rw-r--r-- | chrome/browser/browser_process_impl.h | 1 | ||||
-rw-r--r-- | chrome/browser/chrome_content_browser_client.cc | 8 | ||||
-rw-r--r-- | chrome/browser/chrome_content_browser_client.h | 2 | ||||
-rw-r--r-- | chrome/browser/profiles/profile_impl_io_data.cc | 3 | ||||
-rw-r--r-- | chrome/browser/profiles/profile_io_data.cc | 1 | ||||
-rw-r--r-- | chrome/browser/profiles/profile_io_data.h | 5 | ||||
-rw-r--r-- | content/browser/content_browser_client.h | 4 | ||||
-rw-r--r-- | content/browser/mock_content_browser_client.cc | 5 | ||||
-rw-r--r-- | content/browser/mock_content_browser_client.h | 2 | ||||
-rw-r--r-- | content/browser/plugin_process_host.cc | 5 | ||||
-rw-r--r-- | content/browser/renderer_host/render_message_filter.cc | 8 | ||||
-rw-r--r-- | content/browser/renderer_host/render_message_filter.h | 3 |
13 files changed, 43 insertions, 31 deletions
diff --git a/chrome/browser/browser_process_impl.cc b/chrome/browser/browser_process_impl.cc index 32e80dd..02ff81d 100644 --- a/chrome/browser/browser_process_impl.cc +++ b/chrome/browser/browser_process_impl.cc @@ -37,7 +37,6 @@ #include "chrome/browser/net/predictor_api.h" #include "chrome/browser/net/sdch_dictionary_fetcher.h" #include "chrome/browser/notifications/notification_ui_manager.h" -#include "chrome/browser/plugin_data_remover.h" #include "chrome/browser/policy/browser_policy_connector.h" #include "chrome/browser/prefs/browser_prefs.h" #include "chrome/browser/prefs/pref_service.h" @@ -139,10 +138,6 @@ BrowserProcessImpl::BrowserProcessImpl(const CommandLine& command_line) clipboard_.reset(new ui::Clipboard); main_notification_service_.reset(new NotificationService); - notification_registrar_.Add(this, - NotificationType::APP_TERMINATING, - NotificationService::AllSources()); - // Must be created after the NotificationService. print_job_manager_.reset(new printing::PrintJobManager); @@ -224,9 +219,6 @@ BrowserProcessImpl::~BrowserProcessImpl() { // down while the IO and FILE threads are still alive. browser_policy_connector_.reset(); - // Wait for removing plugin data to finish before shutting down the IO thread. - WaitForPluginDataRemoverToFinish(); - // Destroying the GpuProcessHostUIShims on the UI thread posts a task to // delete related objects on the GPU thread. This must be done before // stopping the GPU thread. The GPU thread will close IPC channels to renderer @@ -639,19 +631,7 @@ bool BrowserProcessImpl::plugin_finder_disabled() const { void BrowserProcessImpl::Observe(NotificationType type, const NotificationSource& source, const NotificationDetails& details) { - if (type == NotificationType::APP_TERMINATING) { - Profile* profile = ProfileManager::GetDefaultProfile(); - if (profile) { - PrefService* prefs = profile->GetPrefs(); - if (prefs->GetBoolean(prefs::kClearSiteDataOnExit) && - local_state()->GetBoolean(prefs::kClearPluginLSODataEnabled)) { - plugin_data_remover_ = new PluginDataRemover(); - if (!plugin_data_remover_mime_type().empty()) - plugin_data_remover_->set_mime_type(plugin_data_remover_mime_type()); - plugin_data_remover_->StartRemoving(base::Time()); - } - } - } else if (type == NotificationType::PREF_CHANGED) { + if (type == NotificationType::PREF_CHANGED) { std::string* pref = Details<std::string>(details).ptr(); if (*pref == prefs::kDefaultBrowserSettingEnabled) { if (local_state_->GetBoolean(prefs::kDefaultBrowserSettingEnabled)) @@ -666,11 +646,6 @@ void BrowserProcessImpl::Observe(NotificationType type, } } -void BrowserProcessImpl::WaitForPluginDataRemoverToFinish() { - if (plugin_data_remover_.get()) - plugin_data_remover_->Wait(); -} - #if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) void BrowserProcessImpl::StartAutoupdateTimer() { autoupdate_timer_.Start( diff --git a/chrome/browser/browser_process_impl.h b/chrome/browser/browser_process_impl.h index abc5e75..002e557 100644 --- a/chrome/browser/browser_process_impl.h +++ b/chrome/browser/browser_process_impl.h @@ -296,7 +296,6 @@ class BrowserProcessImpl : public BrowserProcess, resource_dispatcher_host_delegate_; NotificationRegistrar notification_registrar_; - scoped_refptr<PluginDataRemover> plugin_data_remover_; scoped_refptr<MHTMLGenerationManager> mhtml_generation_manager_; diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc index e46541d..51066c7 100644 --- a/chrome/browser/chrome_content_browser_client.cc +++ b/chrome/browser/chrome_content_browser_client.cc @@ -405,6 +405,14 @@ bool ChromeContentBrowserClient::AllowSetCookie( return allow; } +bool ChromeContentBrowserClient::AllowSaveLocalState( + const content::ResourceContext& context) { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); + ProfileIOData* io_data = + reinterpret_cast<ProfileIOData*>(context.GetUserData(NULL)); + return !io_data->clear_local_state_on_exit()->GetValue(); +} + QuotaPermissionContext* ChromeContentBrowserClient::CreateQuotaPermissionContext() { return new ChromeQuotaPermissionContext(); diff --git a/chrome/browser/chrome_content_browser_client.h b/chrome/browser/chrome_content_browser_client.h index d2b6f97..f8c3088 100644 --- a/chrome/browser/chrome_content_browser_client.h +++ b/chrome/browser/chrome_content_browser_client.h @@ -45,6 +45,8 @@ class ChromeContentBrowserClient : public content::ContentBrowserClient { int render_process_id, int render_view_id, net::CookieOptions* options) OVERRIDE; + virtual bool AllowSaveLocalState( + const content::ResourceContext& context) OVERRIDE; virtual QuotaPermissionContext* CreateQuotaPermissionContext() OVERRIDE; virtual void RevealFolderInOS(const FilePath& path) OVERRIDE; virtual void AllowCertificateError( diff --git a/chrome/browser/profiles/profile_impl_io_data.cc b/chrome/browser/profiles/profile_impl_io_data.cc index b148f87..d9a694a 100644 --- a/chrome/browser/profiles/profile_impl_io_data.cc +++ b/chrome/browser/profiles/profile_impl_io_data.cc @@ -144,6 +144,9 @@ void ProfileImplIOData::Handle::LazyInitialize() const { io_data_->InitializeProfileParams(profile_); ChromeNetworkDelegate::InitializeReferrersEnabled( io_data_->enable_referrers(), profile_->GetPrefs()); + io_data_->clear_local_state_on_exit()->Init( + prefs::kClearSiteDataOnExit, profile_->GetPrefs(), NULL); + io_data_->clear_local_state_on_exit()->MoveToThread(BrowserThread::IO); initialized_ = true; } } diff --git a/chrome/browser/profiles/profile_io_data.cc b/chrome/browser/profiles/profile_io_data.cc index 5fd06f9..69ab61e2 100644 --- a/chrome/browser/profiles/profile_io_data.cc +++ b/chrome/browser/profiles/profile_io_data.cc @@ -514,4 +514,5 @@ void ProfileIOData::ApplyProfileParamsToContext( void ProfileIOData::ShutdownOnUIThread() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); enable_referrers_.Destroy(); + clear_local_state_on_exit_.Destroy(); } diff --git a/chrome/browser/profiles/profile_io_data.h b/chrome/browser/profiles/profile_io_data.h index aad114b..b4fa08a 100644 --- a/chrome/browser/profiles/profile_io_data.h +++ b/chrome/browser/profiles/profile_io_data.h @@ -96,6 +96,10 @@ class ProfileIOData : public base::RefCountedThreadSafe<ProfileIOData> { HostContentSettingsMap* GetHostContentSettingsMap() const; DesktopNotificationService* GetNotificationService() const; + BooleanPrefMember* clear_local_state_on_exit() const { + return &clear_local_state_on_exit_; + } + protected: friend class base::RefCountedThreadSafe<ProfileIOData>; @@ -238,6 +242,7 @@ class ProfileIOData : public base::RefCountedThreadSafe<ProfileIOData> { // Member variables which are pointed to by the various context objects. mutable BooleanPrefMember enable_referrers_; + mutable BooleanPrefMember clear_local_state_on_exit_; // Pointed to by URLRequestContext. mutable scoped_ptr<ChromeURLDataManagerBackend> diff --git a/content/browser/content_browser_client.h b/content/browser/content_browser_client.h index d32a2ee..2850267 100644 --- a/content/browser/content_browser_client.h +++ b/content/browser/content_browser_client.h @@ -132,6 +132,10 @@ class ContentBrowserClient { int render_view_id, net::CookieOptions* options) = 0; + // This is called on the IO thread. + virtual bool AllowSaveLocalState( + const content::ResourceContext& context) = 0; + // Create and return a new quota permission context. virtual QuotaPermissionContext* CreateQuotaPermissionContext() = 0; diff --git a/content/browser/mock_content_browser_client.cc b/content/browser/mock_content_browser_client.cc index 9144f98..4a3deb1 100644 --- a/content/browser/mock_content_browser_client.cc +++ b/content/browser/mock_content_browser_client.cc @@ -94,6 +94,11 @@ bool MockContentBrowserClient::AllowSetCookie( return true; } +bool MockContentBrowserClient::AllowSaveLocalState( + const content::ResourceContext& context) { + return true; +} + QuotaPermissionContext* MockContentBrowserClient::CreateQuotaPermissionContext() { return NULL; diff --git a/content/browser/mock_content_browser_client.h b/content/browser/mock_content_browser_client.h index 2a71e0d..78e2143 100644 --- a/content/browser/mock_content_browser_client.h +++ b/content/browser/mock_content_browser_client.h @@ -47,6 +47,8 @@ class MockContentBrowserClient : public ContentBrowserClient { int render_process_id, int render_view_id, net::CookieOptions* options) OVERRIDE; + virtual bool AllowSaveLocalState( + const content::ResourceContext& context) OVERRIDE; virtual QuotaPermissionContext* CreateQuotaPermissionContext() OVERRIDE; virtual void RevealFolderInOS(const FilePath& path) OVERRIDE; virtual void AllowCertificateError( diff --git a/content/browser/plugin_process_host.cc b/content/browser/plugin_process_host.cc index d8344b5..56fc90e 100644 --- a/content/browser/plugin_process_host.cc +++ b/content/browser/plugin_process_host.cc @@ -335,8 +335,9 @@ void PluginProcessHost::RequestPluginChannel(Client* client) { // a deadlock can occur if the plugin creation request from the renderer is // a result of a sync message by the plugin process. PluginProcessMsg_CreateChannel* msg = - new PluginProcessMsg_CreateChannel(client->ID(), - client->OffTheRecord()); + new PluginProcessMsg_CreateChannel( + client->ID(), + client->OffTheRecord()); msg->set_unblock(true); if (Send(msg)) { sent_requests_.push(client); diff --git a/content/browser/renderer_host/render_message_filter.cc b/content/browser/renderer_host/render_message_filter.cc index 95f8ad5..699d479 100644 --- a/content/browser/renderer_host/render_message_filter.cc +++ b/content/browser/renderer_host/render_message_filter.cc @@ -125,7 +125,7 @@ class OpenChannelToNpapiPluginCallback : public RenderMessageCompletionCallback, } virtual bool OffTheRecord() { - return filter()->incognito(); + return filter()->OffTheRecord(); } virtual void SetPluginInfo(const webkit::npapi::WebPluginInfo& info) { @@ -378,6 +378,12 @@ void RenderMessageFilter::OnDestruct() const { BrowserThread::DeleteOnIOThread::Destruct(this); } +bool RenderMessageFilter::OffTheRecord() const { + return incognito_ || + !content::GetContentClient()->browser()->AllowSaveLocalState( + resource_context_); +} + void RenderMessageFilter::OnMsgCreateWindow( const ViewHostMsg_CreateWindow_Params& params, int* route_id, int64* cloned_session_storage_namespace_id) { diff --git a/content/browser/renderer_host/render_message_filter.h b/content/browser/renderer_host/render_message_filter.h index 0dcac08..6baea7b 100644 --- a/content/browser/renderer_host/render_message_filter.h +++ b/content/browser/renderer_host/render_message_filter.h @@ -82,11 +82,12 @@ class RenderMessageFilter : public BrowserMessageFilter { bool* message_was_ok); virtual void OnDestruct() const; + bool OffTheRecord() const; + int render_process_id() const { return render_process_id_; } ResourceDispatcherHost* resource_dispatcher_host() { return resource_dispatcher_host_; } - bool incognito() { return incognito_; } // Returns either the extension net::URLRequestContext or regular // net::URLRequestContext depending on whether |url| is an extension URL. |