OLD | NEW |
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_integration_service.h" | 5 #include "chrome/browser/chromeos/drive/drive_integration_service.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/prefs/pref_change_registrar.h" | 9 #include "base/prefs/pref_change_registrar.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 } | 346 } |
347 } | 347 } |
348 | 348 |
349 bool DriveIntegrationService::IsMounted() const { | 349 bool DriveIntegrationService::IsMounted() const { |
350 if (mount_point_name_.empty()) | 350 if (mount_point_name_.empty()) |
351 return false; | 351 return false; |
352 | 352 |
353 // Look up the registered path, and just discard it. | 353 // Look up the registered path, and just discard it. |
354 // GetRegisteredPath() returns true if the path is available. | 354 // GetRegisteredPath() returns true if the path is available. |
355 base::FilePath unused; | 355 base::FilePath unused; |
356 return BrowserContext::GetMountPoints(profile_)->GetRegisteredPath( | 356 fileapi::ExternalMountPoints* const mount_points = |
357 mount_point_name_, &unused); | 357 fileapi::ExternalMountPoints::GetSystemInstance(); |
| 358 DCHECK(mount_points); |
| 359 return mount_points->GetRegisteredPath(mount_point_name_, &unused); |
358 } | 360 } |
359 | 361 |
360 void DriveIntegrationService::AddObserver( | 362 void DriveIntegrationService::AddObserver( |
361 DriveIntegrationServiceObserver* observer) { | 363 DriveIntegrationServiceObserver* observer) { |
362 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 364 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
363 observers_.AddObserver(observer); | 365 observers_.AddObserver(observer); |
364 } | 366 } |
365 | 367 |
366 void DriveIntegrationService::RemoveObserver( | 368 void DriveIntegrationService::RemoveObserver( |
367 DriveIntegrationServiceObserver* observer) { | 369 DriveIntegrationServiceObserver* observer) { |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 | 426 |
425 void DriveIntegrationService::AddDriveMountPoint() { | 427 void DriveIntegrationService::AddDriveMountPoint() { |
426 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 428 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
427 DCHECK_EQ(INITIALIZED, state_); | 429 DCHECK_EQ(INITIALIZED, state_); |
428 DCHECK(enabled_); | 430 DCHECK(enabled_); |
429 | 431 |
430 const base::FilePath& drive_mount_point = | 432 const base::FilePath& drive_mount_point = |
431 util::GetDriveMountPointPath(profile_); | 433 util::GetDriveMountPointPath(profile_); |
432 if (mount_point_name_.empty()) | 434 if (mount_point_name_.empty()) |
433 mount_point_name_ = drive_mount_point.BaseName().AsUTF8Unsafe(); | 435 mount_point_name_ = drive_mount_point.BaseName().AsUTF8Unsafe(); |
434 fileapi::ExternalMountPoints* mount_points = | 436 fileapi::ExternalMountPoints* const mount_points = |
435 BrowserContext::GetMountPoints(profile_); | 437 fileapi::ExternalMountPoints::GetSystemInstance(); |
436 DCHECK(mount_points); | 438 DCHECK(mount_points); |
437 | 439 |
438 bool success = mount_points->RegisterFileSystem( | 440 bool success = mount_points->RegisterFileSystem( |
439 mount_point_name_, | 441 mount_point_name_, |
440 fileapi::kFileSystemTypeDrive, | 442 fileapi::kFileSystemTypeDrive, |
441 fileapi::FileSystemMountOption(), | 443 fileapi::FileSystemMountOption(), |
442 drive_mount_point); | 444 drive_mount_point); |
443 | 445 |
444 if (success) { | 446 if (success) { |
445 util::Log(logging::LOG_INFO, "Drive mount point is added"); | 447 util::Log(logging::LOG_INFO, "Drive mount point is added"); |
446 FOR_EACH_OBSERVER(DriveIntegrationServiceObserver, observers_, | 448 FOR_EACH_OBSERVER(DriveIntegrationServiceObserver, observers_, |
447 OnFileSystemMounted()); | 449 OnFileSystemMounted()); |
448 } | 450 } |
449 } | 451 } |
450 | 452 |
451 void DriveIntegrationService::RemoveDriveMountPoint() { | 453 void DriveIntegrationService::RemoveDriveMountPoint() { |
452 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 454 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
453 | 455 |
454 if (!mount_point_name_.empty()) { | 456 if (!mount_point_name_.empty()) { |
455 job_list()->CancelAllJobs(); | 457 job_list()->CancelAllJobs(); |
456 | 458 |
457 FOR_EACH_OBSERVER(DriveIntegrationServiceObserver, observers_, | 459 FOR_EACH_OBSERVER(DriveIntegrationServiceObserver, observers_, |
458 OnFileSystemBeingUnmounted()); | 460 OnFileSystemBeingUnmounted()); |
459 | 461 |
460 fileapi::ExternalMountPoints* mount_points = | 462 fileapi::ExternalMountPoints* const mount_points = |
461 BrowserContext::GetMountPoints(profile_); | 463 fileapi::ExternalMountPoints::GetSystemInstance(); |
462 DCHECK(mount_points); | 464 DCHECK(mount_points); |
463 | 465 |
464 mount_points->RevokeFileSystem(mount_point_name_); | 466 mount_points->RevokeFileSystem(mount_point_name_); |
465 util::Log(logging::LOG_INFO, "Drive mount point is removed"); | 467 util::Log(logging::LOG_INFO, "Drive mount point is removed"); |
466 } | 468 } |
467 } | 469 } |
468 | 470 |
469 void DriveIntegrationService::Initialize() { | 471 void DriveIntegrationService::Initialize() { |
470 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 472 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
471 DCHECK_EQ(NOT_INITIALIZED, state_); | 473 DCHECK_EQ(NOT_INITIALIZED, state_); |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
625 profile, preference_watcher, | 627 profile, preference_watcher, |
626 NULL, std::string(), base::FilePath(), NULL); | 628 NULL, std::string(), base::FilePath(), NULL); |
627 } else { | 629 } else { |
628 service = factory_for_test_->Run(profile); | 630 service = factory_for_test_->Run(profile); |
629 } | 631 } |
630 | 632 |
631 return service; | 633 return service; |
632 } | 634 } |
633 | 635 |
634 } // namespace drive | 636 } // namespace drive |
OLD | NEW |