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

Unified Diff: chrome/browser/chromeos/gdata/gdata_file_system.cc

Issue 9947002: Wired preference that hides hosted documents for the directory view. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 months 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/chromeos/gdata/gdata_file_system.cc
diff --git a/chrome/browser/chromeos/gdata/gdata_file_system.cc b/chrome/browser/chromeos/gdata/gdata_file_system.cc
index 2af5f544160abc991582410cfa6b61dafdc57211..d9d57a2cd65f8a3b761568fdabb88770faaae332 100644
--- a/chrome/browser/chromeos/gdata/gdata_file_system.cc
+++ b/chrome/browser/chromeos/gdata/gdata_file_system.cc
@@ -29,8 +29,11 @@
#include "chrome/browser/chromeos/gdata/gdata_upload_file_info.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/chrome_constants.h"
+#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/chrome_paths_internal.h"
+#include "chrome/common/pref_names.h"
#include "content/public/browser/browser_thread.h"
+#include "content/public/browser/notification_details.h"
#include "net/base/mime_util.h"
#include "webkit/fileapi/file_system_file_util_proxy.h"
#include "webkit/fileapi/file_system_types.h"
@@ -479,6 +482,7 @@ GDataFileSystem::GDataFileSystem(Profile* profile,
true /* manual reset */, false /* initially not signaled */)),
cache_initialization_started_(false),
num_pending_tasks_(0),
+ hide_hosted_docs_(false),
ui_weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(
new base::WeakPtrFactory<GDataFileSystem>(this))),
ui_weak_ptr_(ui_weak_ptr_factory_->GetWeakPtr()) {
@@ -505,6 +509,11 @@ void GDataFileSystem::Initialize() {
root_.reset(new GDataRootDirectory(this));
root_->set_file_name(kGDataRootDirectory);
+
+ PrefService* pref_service = profile_->GetPrefs();
+ hide_hosted_docs_ = pref_service->GetBoolean(prefs::kDisableGDataHostedFiles);
+
+ InitializePreferenceObserver();
}
GDataFileSystem::~GDataFileSystem() {
@@ -2682,6 +2691,44 @@ void GDataFileSystem::AddUploadedFile(const FilePath& virtual_dir_path,
CacheOperationCallback());
}
+void GDataFileSystem::Observe(int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) {
+ if (type == chrome::NOTIFICATION_PREF_CHANGED) {
+ PrefService* pref_service = profile_->GetPrefs();
+ std::string* pref_name = content::Details<std::string>(details).ptr();
+ if (*pref_name == prefs::kDisableGDataHostedFiles) {
+ SetHideHostedDocuments(
+ pref_service->GetBoolean(prefs::kDisableGDataHostedFiles));
+ } else if (*pref_name == prefs::kDisableGDataOverCellular) {
+ // TODO(satorux): Disable pinning over mobil connection.
+ } else if (*pref_name == prefs::kDisableGData) {
+ // TODO(satorux): Disable gdata.
+ }
satorux1 2012/04/04 21:23:16 Please remove TODOs. My part won't need code in GD
zel 2012/04/04 22:14:18 Done.
+ } else {
+ NOTREACHED();
+ }
+}
+
+bool GDataFileSystem::hide_hosted_documents() {
+ base::AutoLock lock(lock_);
+ return hide_hosted_docs_;
+}
+
+void GDataFileSystem::SetHideHostedDocuments(bool hide) {
+ FilePath root_path;
+ {
+ base::AutoLock lock(lock_);
+ if (hide == hide_hosted_docs_)
+ return;
+
+ hide_hosted_docs_ = hide;
+ root_path = root_->GetFilePath();
+ }
+
+ // Kick of directory refresh when this setting changes.
+ NotifyDirectoryChanged(root_path);
+}
//===================== GDataFileSystem: Cache entry points ====================
@@ -3769,4 +3816,11 @@ void GDataFileSystem::PostBlockingPoolSequencedTaskAndReply(
DCHECK(posted);
}
+void GDataFileSystem::InitializePreferenceObserver() {
+ pref_observer_.reset(new PrefSetObserver(profile_->GetPrefs(), this));
achuithb 2012/04/04 19:14:11 pref_observer_ doesn't seem to do anything? What a
zel 2012/04/04 20:16:57 it does. it's a helper class for registering for m
achuithb 2012/04/04 20:46:19 Ah, got it. It takes care of the NotificationRegis
satorux1 2012/04/04 21:47:11 BTW, PrefChangeRegistar solves the same problem.
zel 2012/04/04 22:14:18 Done.
+ pref_observer_->AddPref(prefs::kDisableGDataHostedFiles);
+ pref_observer_->AddPref(prefs::kDisableGDataOverCellular);
+ pref_observer_->AddPref(prefs::kDisableGData);
+}
+
} // namespace gdata

Powered by Google App Engine
This is Rietveld 408576698