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

Side by Side Diff: chrome/browser/chromeos/gdata/gdata_system_service.cc

Issue 10834115: Drive: Mount/Unmount GoogleDrive on Files App when the file system is mounted/unmounted. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 4 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/chromeos/gdata/gdata_system_service.h" 5 #include "chrome/browser/chromeos/gdata/gdata_system_service.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "chrome/browser/browser_process.h" 9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/chromeos/extensions/file_browser_event_router.h"
10 #include "chrome/browser/chromeos/gdata/drive_webapps_registry.h" 11 #include "chrome/browser/chromeos/gdata/drive_webapps_registry.h"
11 #include "chrome/browser/chromeos/gdata/gdata_contacts_service.h" 12 #include "chrome/browser/chromeos/gdata/gdata_contacts_service.h"
12 #include "chrome/browser/chromeos/gdata/gdata_documents_service.h" 13 #include "chrome/browser/chromeos/gdata/gdata_documents_service.h"
13 #include "chrome/browser/chromeos/gdata/gdata_download_observer.h" 14 #include "chrome/browser/chromeos/gdata/gdata_download_observer.h"
14 #include "chrome/browser/chromeos/gdata/gdata_file_system.h" 15 #include "chrome/browser/chromeos/gdata/gdata_file_system.h"
15 #include "chrome/browser/chromeos/gdata/gdata_file_system_proxy.h"
16 #include "chrome/browser/chromeos/gdata/gdata_sync_client.h" 16 #include "chrome/browser/chromeos/gdata/gdata_sync_client.h"
17 #include "chrome/browser/chromeos/gdata/gdata_uploader.h" 17 #include "chrome/browser/chromeos/gdata/gdata_uploader.h"
18 #include "chrome/browser/chromeos/gdata/gdata_util.h" 18 #include "chrome/browser/chromeos/gdata/gdata_util.h"
19 #include "chrome/browser/download/download_service.h" 19 #include "chrome/browser/download/download_service.h"
20 #include "chrome/browser/download/download_service_factory.h" 20 #include "chrome/browser/download/download_service_factory.h"
21 #include "chrome/browser/profiles/profile.h" 21 #include "chrome/browser/profiles/profile.h"
22 #include "chrome/browser/profiles/profile_dependency_manager.h" 22 #include "chrome/browser/profiles/profile_dependency_manager.h"
23 #include "content/public/browser/browser_context.h"
24 #include "content/public/browser/browser_thread.h" 23 #include "content/public/browser/browser_thread.h"
25 #include "webkit/fileapi/file_system_context.h"
26 #include "webkit/fileapi/file_system_mount_point_provider.h"
27 24
28 using content::BrowserContext; 25 using content::BrowserContext;
29 using content::BrowserThread; 26 using content::BrowserThread;
30 27
31 namespace gdata { 28 namespace gdata {
32 namespace { 29 namespace {
33 30
34 // Used in test to setup system service. 31 // Used in test to setup system service.
35 DocumentsServiceInterface* g_test_documents_service = NULL; 32 DocumentsServiceInterface* g_test_documents_service = NULL;
36 const std::string* g_test_cache_root = NULL; 33 const std::string* g_test_cache_root = NULL;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 download_observer_.reset(); 96 download_observer_.reset();
100 file_system_.reset(); 97 file_system_.reset();
101 webapps_registry_.reset(); 98 webapps_registry_.reset();
102 uploader_.reset(); 99 uploader_.reset();
103 documents_service_.reset(); 100 documents_service_.reset();
104 } 101 }
105 102
106 void GDataSystemService::AddDriveMountPoint() { 103 void GDataSystemService::AddDriveMountPoint() {
107 if (!gdata::util::IsGDataAvailable(profile_)) 104 if (!gdata::util::IsGDataAvailable(profile_))
108 return; 105 return;
109 106 file_system_->AddDriveMountPoint();
110 const FilePath mount_point = gdata::util::GetGDataMountPointPath();
111 fileapi::ExternalFileSystemMountPointProvider* provider =
112 BrowserContext::GetFileSystemContext(profile_)->external_provider();
113 if (provider && !provider->HasMountPoint(mount_point)) {
114 provider->AddRemoteMountPoint(
115 mount_point,
116 new GDataFileSystemProxy(file_system_.get()));
117 }
118 } 107 }
119 108
120 void GDataSystemService::RemoveDriveMountPoint() { 109 void GDataSystemService::RemoveDriveMountPoint() {
121 const FilePath mount_point = gdata::util::GetGDataMountPointPath(); 110 file_system_->RemoveDriveMountPoint();
122 fileapi::ExternalFileSystemMountPointProvider* provider =
123 BrowserContext::GetFileSystemContext(profile_)->external_provider();
124 if (provider && provider->HasMountPoint(mount_point))
125 provider->RemoveMountPoint(mount_point);
126 } 111 }
127 112
128 //===================== GDataSystemServiceFactory ============================= 113 //===================== GDataSystemServiceFactory =============================
129 114
130 // static 115 // static
131 GDataSystemService* GDataSystemServiceFactory::GetForProfile( 116 GDataSystemService* GDataSystemServiceFactory::GetForProfile(
132 Profile* profile) { 117 Profile* profile) {
133 return static_cast<GDataSystemService*>( 118 return static_cast<GDataSystemService*>(
134 GetInstance()->GetServiceForProfile(profile, true)); 119 GetInstance()->GetServiceForProfile(profile, true));
135 } 120 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 g_test_cache_root ? FilePath(*g_test_cache_root) : 169 g_test_cache_root ? FilePath(*g_test_cache_root) :
185 GDataCache::GetCacheRootPath(profile); 170 GDataCache::GetCacheRootPath(profile);
186 delete g_test_cache_root; 171 delete g_test_cache_root;
187 g_test_cache_root = NULL; 172 g_test_cache_root = NULL;
188 173
189 service->Initialize(documents_service, cache_root); 174 service->Initialize(documents_service, cache_root);
190 return service; 175 return service;
191 } 176 }
192 177
193 } // namespace gdata 178 } // namespace gdata
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698