Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/in_process_webkit/webkit_context.h" | 5 #include "chrome/browser/in_process_webkit/webkit_context.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "chrome/browser/browser_thread.h" | 8 #include "chrome/browser/browser_thread.h" |
| 9 #include "chrome/browser/profile.h" | 9 #include "chrome/browser/profile.h" |
| 10 #include "chrome/browser/prefs/pref_service.h" | |
| 10 #include "chrome/common/chrome_switches.h" | 11 #include "chrome/common/chrome_switches.h" |
| 12 #include "chrome/common/notification_details.h" | |
| 13 #include "chrome/common/notification_source.h" | |
| 14 #include "chrome/common/notification_type.h" | |
| 15 #include "chrome/common/pref_names.h" | |
| 11 | 16 |
| 12 WebKitContext::WebKitContext(Profile* profile) | 17 WebKitContext::WebKitContext(Profile* profile) |
| 13 : data_path_(profile->IsOffTheRecord() ? FilePath() : profile->GetPath()), | 18 : data_path_(profile->IsOffTheRecord() ? FilePath() : profile->GetPath()), |
| 14 is_incognito_(profile->IsOffTheRecord()), | 19 is_incognito_(profile->IsOffTheRecord()), |
| 15 ALLOW_THIS_IN_INITIALIZER_LIST( | 20 ALLOW_THIS_IN_INITIALIZER_LIST( |
| 16 dom_storage_context_(new DOMStorageContext(this))), | 21 dom_storage_context_(new DOMStorageContext(this))), |
| 17 ALLOW_THIS_IN_INITIALIZER_LIST( | 22 ALLOW_THIS_IN_INITIALIZER_LIST( |
| 18 indexed_db_context_(new IndexedDBContext(this))) { | 23 indexed_db_context_(new IndexedDBContext(this))) { |
| 24 PrefService* prefs = profile->GetPrefs(); | |
|
jochen (gone - plz use gerrit)
2010/11/29 13:29:33
hum. if the profile is off the record, you should
pastarmovj
2010/11/29 13:45:12
Done.
| |
| 25 clear_local_state_on_exit_ = prefs->GetBoolean(prefs::kClearSiteDataOnExit); | |
| 26 pref_change_registrar_.Init(prefs); | |
| 27 pref_change_registrar_.Add(prefs::kClearSiteDataOnExit, this); | |
| 19 } | 28 } |
| 20 | 29 |
| 21 WebKitContext::~WebKitContext() { | 30 WebKitContext::~WebKitContext() { |
| 22 // If the WebKit thread was ever spun up, delete the object there. The task | 31 // If the WebKit thread was ever spun up, delete the object there. The task |
| 23 // will just get deleted if the WebKit thread isn't created (which only | 32 // will just get deleted if the WebKit thread isn't created (which only |
| 24 // happens during testing). | 33 // happens during testing). |
| 25 DOMStorageContext* dom_storage_context = dom_storage_context_.release(); | 34 DOMStorageContext* dom_storage_context = dom_storage_context_.release(); |
| 26 if (!BrowserThread::DeleteSoon( | 35 if (!BrowserThread::DeleteSoon( |
| 27 BrowserThread::WEBKIT, FROM_HERE, dom_storage_context)) { | 36 BrowserThread::WEBKIT, FROM_HERE, dom_storage_context)) { |
| 28 // The WebKit thread wasn't created, and the task got deleted without | 37 // The WebKit thread wasn't created, and the task got deleted without |
| 29 // freeing the DOMStorageContext, so delete it manually. | 38 // freeing the DOMStorageContext, so delete it manually. |
| 30 delete dom_storage_context; | 39 delete dom_storage_context; |
| 31 } | 40 } |
| 32 | 41 |
| 42 indexed_db_context_->set_clear_local_state_on_exit_( | |
| 43 clear_local_state_on_exit_); | |
| 33 IndexedDBContext* indexed_db_context = indexed_db_context_.release(); | 44 IndexedDBContext* indexed_db_context = indexed_db_context_.release(); |
| 34 if (!BrowserThread::DeleteSoon( | 45 if (!BrowserThread::DeleteSoon( |
| 35 BrowserThread::WEBKIT, FROM_HERE, indexed_db_context)) { | 46 BrowserThread::WEBKIT, FROM_HERE, indexed_db_context)) { |
| 36 delete indexed_db_context; | 47 delete indexed_db_context; |
| 37 } | 48 } |
| 38 } | 49 } |
| 39 | 50 |
| 40 void WebKitContext::PurgeMemory() { | 51 void WebKitContext::PurgeMemory() { |
| 41 if (!BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)) { | 52 if (!BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)) { |
| 42 BrowserThread::PostTask( | 53 BrowserThread::PostTask( |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 71 BrowserThread::PostTask( | 82 BrowserThread::PostTask( |
| 72 BrowserThread::WEBKIT, FROM_HERE, | 83 BrowserThread::WEBKIT, FROM_HERE, |
| 73 NewRunnableMethod(this, &WebKitContext::DeleteSessionStorageNamespace, | 84 NewRunnableMethod(this, &WebKitContext::DeleteSessionStorageNamespace, |
| 74 session_storage_namespace_id)); | 85 session_storage_namespace_id)); |
| 75 return; | 86 return; |
| 76 } | 87 } |
| 77 | 88 |
| 78 dom_storage_context_->DeleteSessionStorageNamespace( | 89 dom_storage_context_->DeleteSessionStorageNamespace( |
| 79 session_storage_namespace_id); | 90 session_storage_namespace_id); |
| 80 } | 91 } |
| 92 | |
| 93 void WebKitContext::Observe(NotificationType type, | |
| 94 const NotificationSource& source, | |
| 95 const NotificationDetails& details) { | |
| 96 if (NotificationType::PREF_CHANGED == type) { | |
| 97 std::string* name = Details<std::string>(details).ptr(); | |
| 98 PrefService* prefs = Source<PrefService>(source).ptr(); | |
| 99 if (prefs::kClearSiteDataOnExit == *name) | |
| 100 { | |
|
jochen (gone - plz use gerrit)
2010/11/29 13:29:33
{ on previous line
pastarmovj
2010/11/29 13:45:12
Done.
| |
| 101 clear_local_state_on_exit_ = prefs->GetBoolean( | |
|
jochen (gone - plz use gerrit)
2010/11/29 13:29:33
i'd wrap around after the =
pastarmovj
2010/11/29 13:45:12
Done.
| |
| 102 prefs::kClearSiteDataOnExit); | |
| 103 } | |
| 104 } | |
| 105 } | |
| OLD | NEW |