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

Unified Diff: chrome/browser/plugin_data_remover_helper.cc

Issue 5278001: Add a preference to clear Flash LSO data in the Clear Browsing Data dialog. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 10 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/plugin_data_remover_helper.cc
diff --git a/chrome/browser/plugin_data_remover_helper.cc b/chrome/browser/plugin_data_remover_helper.cc
new file mode 100644
index 0000000000000000000000000000000000000000..04dab18d52c1c0fdce6efdfc5ed299dde2f7c463
--- /dev/null
+++ b/chrome/browser/plugin_data_remover_helper.cc
@@ -0,0 +1,74 @@
+// Copyright (c) 2010 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.
+
+#include "chrome/browser/plugin_data_remover_helper.h"
+
+#include "base/ref_counted.h"
+#include "chrome/browser/browser_thread.h"
+#include "chrome/browser/plugin_data_remover.h"
+#include "chrome/common/pref_names.h"
+#include "chrome/browser/prefs/pref_service.h"
+#include "chrome/browser/profile.h"
+
+class PluginDataRemoverHelper::Internal
+ : public base::RefCountedThreadSafe<PluginDataRemoverHelper::Internal> {
+ public:
+ explicit Internal(const char* pref_name, PrefService* prefs)
+ : pref_name_(pref_name), prefs_(prefs) {}
+
+ void StartUpdate() {
+ BrowserThread::PostTask(
+ BrowserThread::FILE,
+ FROM_HERE,
+ NewRunnableMethod(
+ this,
+ &PluginDataRemoverHelper::Internal::UpdateOnFileThread));
+ }
+
+ void Invalidate() {
+ prefs_ = NULL;
+ }
+
+ private:
+ friend class base::RefCountedThreadSafe<Internal>;
+
+ ~Internal() {}
+
+ void UpdateOnFileThread() {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
+ bool result = PluginDataRemover::IsSupported();
+ BrowserThread::PostTask(
+ BrowserThread::UI,
+ FROM_HERE,
+ NewRunnableMethod(this,
+ &PluginDataRemoverHelper::Internal::SetPrefOnUIThread,
+ result));
+ }
+
+ void SetPrefOnUIThread(bool value) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ if (prefs_)
+ prefs_->SetBoolean(pref_name_.c_str(), value);
+ }
+
+ std::string pref_name_;
+ // Weak pointer.
+ PrefService* prefs_;
+};
jochen (gone - plz use gerrit) 2010/11/24 19:03:07 disallow copy and assign
Bernhard Bauer 2010/11/29 10:45:23 Done.
+
+PluginDataRemoverHelper::PluginDataRemoverHelper() {}
+
+PluginDataRemoverHelper::~PluginDataRemoverHelper() {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ if (internal_)
+ internal_->Invalidate();
+}
+
+void PluginDataRemoverHelper::Init(const char* pref_name,
+ PrefService* prefs,
+ NotificationObserver* observer) {
+ pref_.Init(pref_name, prefs, observer);
+ internal_ = make_scoped_refptr(new Internal(pref_name, prefs));
+ internal_->StartUpdate();
+}

Powered by Google App Engine
This is Rietveld 408576698