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

Side by Side Diff: chrome/browser/chromeos/drive/drive_system_service.cc

Issue 11106007: drive: Rename 'gdata' namespace to 'drive' in chrome/browser/chromeos/drive (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 2 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 | Annotate | Revision Log
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/drive/drive_system_service.h" 5 #include "chrome/browser/chromeos/drive/drive_system_service.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "chrome/browser/browser_process.h" 8 #include "chrome/browser/browser_process.h"
9 #include "chrome/browser/chromeos/drive/drive_api_service.h" 9 #include "chrome/browser/chromeos/drive/drive_api_service.h"
10 #include "chrome/browser/chromeos/drive/drive_download_observer.h" 10 #include "chrome/browser/chromeos/drive/drive_download_observer.h"
(...skipping 16 matching lines...) Expand all
27 #include "chrome/common/pref_names.h" 27 #include "chrome/common/pref_names.h"
28 #include "content/public/browser/browser_context.h" 28 #include "content/public/browser/browser_context.h"
29 #include "content/public/browser/browser_thread.h" 29 #include "content/public/browser/browser_thread.h"
30 #include "content/public/browser/storage_partition.h" 30 #include "content/public/browser/storage_partition.h"
31 #include "webkit/fileapi/file_system_context.h" 31 #include "webkit/fileapi/file_system_context.h"
32 #include "webkit/fileapi/file_system_mount_point_provider.h" 32 #include "webkit/fileapi/file_system_mount_point_provider.h"
33 33
34 using content::BrowserContext; 34 using content::BrowserContext;
35 using content::BrowserThread; 35 using content::BrowserThread;
36 36
37 namespace gdata { 37 namespace drive {
38 namespace { 38 namespace {
39 39
40 // Used in test to setup system service. 40 // Used in test to setup system service.
41 DriveServiceInterface* g_test_drive_service = NULL; 41 DriveServiceInterface* g_test_drive_service = NULL;
42 const std::string* g_test_cache_root = NULL; 42 const std::string* g_test_cache_root = NULL;
43 43
44 // Map to collect profiles with Drive disabled. 44 // Map to collect profiles with Drive disabled.
45 std::map<Profile*, bool>* g_drive_disabled_map = NULL; 45 std::map<Profile*, bool>* g_drive_disabled_map = NULL;
46 46
47 // Disables Drive for the specified profile. Used to disable Drive when 47 // Disables Drive for the specified profile. Used to disable Drive when
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 file_system_.reset(); 119 file_system_.reset();
120 webapps_registry_.reset(); 120 webapps_registry_.reset();
121 uploader_.reset(); 121 uploader_.reset();
122 drive_service_.reset(); 122 drive_service_.reset();
123 } 123 }
124 124
125 // static 125 // static
126 bool DriveSystemService::IsDriveEnabled(Profile* profile) { 126 bool DriveSystemService::IsDriveEnabled(Profile* profile) {
127 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 127 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
128 128
129 if (!AuthService::CanAuthenticate(profile)) 129 if (!gdata::AuthService::CanAuthenticate(profile))
130 return false; 130 return false;
131 131
132 // Disable gdata if preference is set. This can happen with commandline flag 132 // Disable gdata if preference is set. This can happen with commandline flag
133 // --disable-gdata or enterprise policy, or probably with user settings too 133 // --disable-gdata or enterprise policy, or probably with user settings too
134 // in the future. 134 // in the future.
135 if (profile->GetPrefs()->GetBoolean(prefs::kDisableGData)) 135 if (profile->GetPrefs()->GetBoolean(prefs::kDisableGData))
136 return false; 136 return false;
137 137
138 if (g_drive_disabled_map && g_drive_disabled_map->count(profile) > 0) 138 if (g_drive_disabled_map && g_drive_disabled_map->count(profile) > 0)
139 return false; 139 return false;
(...skipping 23 matching lines...) Expand all
163 AddDriveMountPoint(); 163 AddDriveMountPoint();
164 164
165 if (!callback.is_null()) 165 if (!callback.is_null())
166 callback.Run(error == DRIVE_FILE_OK); 166 callback.Run(error == DRIVE_FILE_OK);
167 } 167 }
168 168
169 void DriveSystemService::AddDriveMountPoint() { 169 void DriveSystemService::AddDriveMountPoint() {
170 if (!IsDriveEnabled(profile_)) 170 if (!IsDriveEnabled(profile_))
171 return; 171 return;
172 172
173 const FilePath mount_point = gdata::util::GetDriveMountPointPath(); 173 const FilePath mount_point = util::GetDriveMountPointPath();
174 fileapi::ExternalFileSystemMountPointProvider* provider = 174 fileapi::ExternalFileSystemMountPointProvider* provider =
175 BrowserContext::GetDefaultStoragePartition(profile_)-> 175 BrowserContext::GetDefaultStoragePartition(profile_)->
176 GetFileSystemContext()->external_provider(); 176 GetFileSystemContext()->external_provider();
177 if (provider && !provider->HasMountPoint(mount_point)) { 177 if (provider && !provider->HasMountPoint(mount_point)) {
178 provider->AddRemoteMountPoint( 178 provider->AddRemoteMountPoint(
179 mount_point, 179 mount_point,
180 new DriveFileSystemProxy(file_system_.get())); 180 new DriveFileSystemProxy(file_system_.get()));
181 } 181 }
182 182
183 file_system_->NotifyFileSystemMounted(); 183 file_system_->NotifyFileSystemMounted();
184 } 184 }
185 185
186 void DriveSystemService::RemoveDriveMountPoint() { 186 void DriveSystemService::RemoveDriveMountPoint() {
187 file_system_->NotifyFileSystemToBeUnmounted(); 187 file_system_->NotifyFileSystemToBeUnmounted();
188 file_system_->StopUpdates(); 188 file_system_->StopUpdates();
189 189
190 const FilePath mount_point = gdata::util::GetDriveMountPointPath(); 190 const FilePath mount_point = util::GetDriveMountPointPath();
191 fileapi::ExternalFileSystemMountPointProvider* provider = 191 fileapi::ExternalFileSystemMountPointProvider* provider =
192 BrowserContext::GetDefaultStoragePartition(profile_)-> 192 BrowserContext::GetDefaultStoragePartition(profile_)->
193 GetFileSystemContext()->external_provider(); 193 GetFileSystemContext()->external_provider();
194 if (provider && provider->HasMountPoint(mount_point)) 194 if (provider && provider->HasMountPoint(mount_point))
195 provider->RemoveMountPoint(mount_point); 195 provider->RemoveMountPoint(mount_point);
196 } 196 }
197 197
198 void DriveSystemService::OnCacheInitialized(bool success) { 198 void DriveSystemService::OnCacheInitialized(bool success) {
199 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 199 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
200 200
201 if (!success) { 201 if (!success) {
202 LOG(WARNING) << "Failed to initialize the cache. Disabling Drive"; 202 LOG(WARNING) << "Failed to initialize the cache. Disabling Drive";
203 DisableDrive(profile_); 203 DisableDrive(profile_);
204 // Change the download directory to the default value if the download 204 // Change the download directory to the default value if the download
205 // destination is set to under Drive mount point. 205 // destination is set to under Drive mount point.
206 // 206 //
207 // TODO(satorux): This cannot be done in DisableDrive(), as there is a 207 // TODO(satorux): This cannot be done in DisableDrive(), as there is a
208 // dependency problem. We should move this code to DisableDrive() once 208 // dependency problem. We should move this code to DisableDrive() once
209 // the dependency problem is solved. crbug.com/153962 209 // the dependency problem is solved. crbug.com/153962
210 PrefService* pref_service = profile_->GetPrefs(); 210 PrefService* pref_service = profile_->GetPrefs();
211 if (gdata::util::IsUnderDriveMountPoint( 211 if (util::IsUnderDriveMountPoint(
212 pref_service->GetFilePath(prefs::kDownloadDefaultDirectory))) { 212 pref_service->GetFilePath(prefs::kDownloadDefaultDirectory))) {
213 pref_service->SetFilePath(prefs::kDownloadDefaultDirectory, 213 pref_service->SetFilePath(prefs::kDownloadDefaultDirectory,
214 download_util::GetDefaultDownloadDirectory()); 214 download_util::GetDefaultDownloadDirectory());
215 } 215 }
216 return; 216 return;
217 } 217 }
218 218
219 content::DownloadManager* download_manager = 219 content::DownloadManager* download_manager =
220 g_browser_process->download_status_updater() ? 220 g_browser_process->download_status_updater() ?
221 BrowserContext::GetDownloadManager(profile_) : NULL; 221 BrowserContext::GetDownloadManager(profile_) : NULL;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 g_test_cache_root = !cache_root.empty() ? new std::string(cache_root) : NULL; 273 g_test_cache_root = !cache_root.empty() ? new std::string(cache_root) : NULL;
274 } 274 }
275 275
276 ProfileKeyedService* DriveSystemServiceFactory::BuildServiceInstanceFor( 276 ProfileKeyedService* DriveSystemServiceFactory::BuildServiceInstanceFor(
277 Profile* profile) const { 277 Profile* profile) const {
278 DriveSystemService* service = new DriveSystemService(profile); 278 DriveSystemService* service = new DriveSystemService(profile);
279 279
280 DriveServiceInterface* drive_service = g_test_drive_service; 280 DriveServiceInterface* drive_service = g_test_drive_service;
281 g_test_drive_service = NULL; 281 g_test_drive_service = NULL;
282 if (!drive_service) { 282 if (!drive_service) {
283 if (util::IsDriveV2ApiEnabled()) 283 if (gdata::util::IsDriveV2ApiEnabled())
284 drive_service = new DriveAPIService(); 284 drive_service = new DriveAPIService();
285 else 285 else
286 drive_service = new GDataWapiService(); 286 drive_service = new GDataWapiService();
287 } 287 }
288 288
289 FilePath cache_root = 289 FilePath cache_root =
290 g_test_cache_root ? FilePath(*g_test_cache_root) : 290 g_test_cache_root ? FilePath(*g_test_cache_root) :
291 DriveCache::GetCacheRootPath(profile); 291 DriveCache::GetCacheRootPath(profile);
292 delete g_test_cache_root; 292 delete g_test_cache_root;
293 g_test_cache_root = NULL; 293 g_test_cache_root = NULL;
294 294
295 service->Initialize(drive_service, cache_root); 295 service->Initialize(drive_service, cache_root);
296 return service; 296 return service;
297 } 297 }
298 298
299 } // namespace gdata 299 } // namespace drive
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/drive/drive_system_service.h ('k') | chrome/browser/chromeos/drive/drive_task_executor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698