Index: chrome/browser/in_process_webkit/webkit_context.cc |
diff --git a/chrome/browser/in_process_webkit/webkit_context.cc b/chrome/browser/in_process_webkit/webkit_context.cc |
index 32fccf7b7c702e60c9bcca9ba77a3a35b7be86e2..6e39e3ee40b189d2086f495acd619c504da90e12 100644 |
--- a/chrome/browser/in_process_webkit/webkit_context.cc |
+++ b/chrome/browser/in_process_webkit/webkit_context.cc |
@@ -7,15 +7,25 @@ |
#include "base/command_line.h" |
#include "chrome/browser/browser_thread.h" |
#include "chrome/browser/profile.h" |
+#include "chrome/browser/prefs/pref_service.h" |
#include "chrome/common/chrome_switches.h" |
+#include "chrome/common/notification_details.h" |
+#include "chrome/common/notification_type.h" |
+#include "chrome/common/pref_names.h" |
+#include "chrome/common/url_constants.h" |
WebKitContext::WebKitContext(Profile* profile) |
: data_path_(profile->IsOffTheRecord() ? FilePath() : profile->GetPath()), |
is_incognito_(profile->IsOffTheRecord()), |
+ profile_(profile), |
ALLOW_THIS_IN_INITIALIZER_LIST( |
dom_storage_context_(new DOMStorageContext(this))), |
ALLOW_THIS_IN_INITIALIZER_LIST( |
indexed_db_context_(new IndexedDBContext(this))) { |
+ PrefService* prefs = profile->GetPrefs(); |
+ clear_on_exit_ = prefs->GetBoolean(prefs::kClearSiteDataOnExit); |
+ pref_change_registrar_.Init(prefs); |
+ pref_change_registrar_.Add(prefs::kClearSiteDataOnExit, this); |
} |
WebKitContext::~WebKitContext() { |
@@ -30,6 +40,13 @@ WebKitContext::~WebKitContext() { |
delete dom_storage_context; |
} |
+ if (clear_on_exit()) { |
jochen (gone - plz use gerrit)
2010/11/27 19:02:27
since we're explicitly deleting the context, you c
pastarmovj
2010/11/27 20:45:15
Done.
As a result I had to push(done upon constr
|
+ const char* url_scheme_skipped = chrome::kExtensionScheme; |
+ BrowserThread::PostTask( |
+ BrowserThread::WEBKIT, FROM_HERE, |
+ NewRunnableFunction(&IndexedDBContext::ClearLocalState, |
+ data_path_, url_scheme_skipped)); |
+ } |
IndexedDBContext* indexed_db_context = indexed_db_context_.release(); |
if (!BrowserThread::DeleteSoon( |
BrowserThread::WEBKIT, FROM_HERE, indexed_db_context)) { |
@@ -37,6 +54,11 @@ WebKitContext::~WebKitContext() { |
} |
} |
+bool WebKitContext::clear_on_exit() const { |
+ AutoLock auto_lock(lock_); |
+ return clear_on_exit_; |
pastarmovj
2010/11/27 20:45:15
Not needed anymore.
|
+} |
+ |
void WebKitContext::PurgeMemory() { |
if (!BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)) { |
BrowserThread::PostTask( |
@@ -78,3 +100,19 @@ void WebKitContext::DeleteSessionStorageNamespace( |
dom_storage_context_->DeleteSessionStorageNamespace( |
session_storage_namespace_id); |
} |
+ |
+void WebKitContext::Observe(NotificationType type, |
+ const NotificationSource& source, |
+ const NotificationDetails& details) { |
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
jochen (gone - plz use gerrit)
2010/11/27 19:02:27
that shouldn't be required
pastarmovj
2010/11/27 20:45:15
Removed it.
|
+ |
+ if (NotificationType::PREF_CHANGED == type) { |
+ std::string* name = Details<std::string>(details).ptr(); |
+ if (prefs::kClearSiteDataOnExit == *name) { |
+ AutoLock auto_lock(lock_); |
+ clear_on_exit_ = profile_->GetPrefs()->GetBoolean( |
+ prefs::kClearSiteDataOnExit); |
+ LOG(WARNING) << "Option changed " << clear_on_exit_; |
jochen (gone - plz use gerrit)
2010/11/27 19:02:27
please remove
pastarmovj
2010/11/27 20:45:15
Done. It was debug output to test if it is getting
|
+ } |
+ } |
+} |