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 30 matching lines...) Expand all Loading... |
41 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 41 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
42 #include "components/signin/core/browser/profile_oauth2_token_service.h" | 42 #include "components/signin/core/browser/profile_oauth2_token_service.h" |
43 #include "components/signin/core/browser/signin_manager.h" | 43 #include "components/signin/core/browser/signin_manager.h" |
44 #include "content/public/browser/browser_context.h" | 44 #include "content/public/browser/browser_context.h" |
45 #include "content/public/browser/browser_thread.h" | 45 #include "content/public/browser/browser_thread.h" |
46 #include "content/public/browser/notification_service.h" | 46 #include "content/public/browser/notification_service.h" |
47 #include "content/public/common/user_agent.h" | 47 #include "content/public/common/user_agent.h" |
48 #include "google_apis/drive/auth_service.h" | 48 #include "google_apis/drive/auth_service.h" |
49 #include "google_apis/drive/gdata_wapi_url_generator.h" | 49 #include "google_apis/drive/gdata_wapi_url_generator.h" |
50 #include "ui/base/l10n/l10n_util.h" | 50 #include "ui/base/l10n/l10n_util.h" |
51 #include "webkit/browser/fileapi/external_mount_points.h" | 51 #include "storage/browser/fileapi/external_mount_points.h" |
52 | 52 |
53 using content::BrowserContext; | 53 using content::BrowserContext; |
54 using content::BrowserThread; | 54 using content::BrowserThread; |
55 | 55 |
56 namespace drive { | 56 namespace drive { |
57 namespace { | 57 namespace { |
58 | 58 |
59 // Name of the directory used to store metadata. | 59 // Name of the directory used to store metadata. |
60 const base::FilePath::CharType kMetadataDirectory[] = FILE_PATH_LITERAL("meta"); | 60 const base::FilePath::CharType kMetadataDirectory[] = FILE_PATH_LITERAL("meta"); |
61 | 61 |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 } | 347 } |
348 } | 348 } |
349 | 349 |
350 bool DriveIntegrationService::IsMounted() const { | 350 bool DriveIntegrationService::IsMounted() const { |
351 if (mount_point_name_.empty()) | 351 if (mount_point_name_.empty()) |
352 return false; | 352 return false; |
353 | 353 |
354 // Look up the registered path, and just discard it. | 354 // Look up the registered path, and just discard it. |
355 // GetRegisteredPath() returns true if the path is available. | 355 // GetRegisteredPath() returns true if the path is available. |
356 base::FilePath unused; | 356 base::FilePath unused; |
357 fileapi::ExternalMountPoints* const mount_points = | 357 storage::ExternalMountPoints* const mount_points = |
358 fileapi::ExternalMountPoints::GetSystemInstance(); | 358 storage::ExternalMountPoints::GetSystemInstance(); |
359 DCHECK(mount_points); | 359 DCHECK(mount_points); |
360 return mount_points->GetRegisteredPath(mount_point_name_, &unused); | 360 return mount_points->GetRegisteredPath(mount_point_name_, &unused); |
361 } | 361 } |
362 | 362 |
363 void DriveIntegrationService::AddObserver( | 363 void DriveIntegrationService::AddObserver( |
364 DriveIntegrationServiceObserver* observer) { | 364 DriveIntegrationServiceObserver* observer) { |
365 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 365 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
366 observers_.AddObserver(observer); | 366 observers_.AddObserver(observer); |
367 } | 367 } |
368 | 368 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 | 427 |
428 void DriveIntegrationService::AddDriveMountPoint() { | 428 void DriveIntegrationService::AddDriveMountPoint() { |
429 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 429 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
430 DCHECK_EQ(INITIALIZED, state_); | 430 DCHECK_EQ(INITIALIZED, state_); |
431 DCHECK(enabled_); | 431 DCHECK(enabled_); |
432 | 432 |
433 const base::FilePath& drive_mount_point = | 433 const base::FilePath& drive_mount_point = |
434 util::GetDriveMountPointPath(profile_); | 434 util::GetDriveMountPointPath(profile_); |
435 if (mount_point_name_.empty()) | 435 if (mount_point_name_.empty()) |
436 mount_point_name_ = drive_mount_point.BaseName().AsUTF8Unsafe(); | 436 mount_point_name_ = drive_mount_point.BaseName().AsUTF8Unsafe(); |
437 fileapi::ExternalMountPoints* const mount_points = | 437 storage::ExternalMountPoints* const mount_points = |
438 fileapi::ExternalMountPoints::GetSystemInstance(); | 438 storage::ExternalMountPoints::GetSystemInstance(); |
439 DCHECK(mount_points); | 439 DCHECK(mount_points); |
440 | 440 |
441 bool success = mount_points->RegisterFileSystem( | 441 bool success = |
442 mount_point_name_, | 442 mount_points->RegisterFileSystem(mount_point_name_, |
443 fileapi::kFileSystemTypeDrive, | 443 storage::kFileSystemTypeDrive, |
444 fileapi::FileSystemMountOption(), | 444 storage::FileSystemMountOption(), |
445 drive_mount_point); | 445 drive_mount_point); |
446 | 446 |
447 if (success) { | 447 if (success) { |
448 logger_->Log(logging::LOG_INFO, "Drive mount point is added"); | 448 logger_->Log(logging::LOG_INFO, "Drive mount point is added"); |
449 FOR_EACH_OBSERVER(DriveIntegrationServiceObserver, observers_, | 449 FOR_EACH_OBSERVER(DriveIntegrationServiceObserver, observers_, |
450 OnFileSystemMounted()); | 450 OnFileSystemMounted()); |
451 } | 451 } |
452 } | 452 } |
453 | 453 |
454 void DriveIntegrationService::RemoveDriveMountPoint() { | 454 void DriveIntegrationService::RemoveDriveMountPoint() { |
455 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 455 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
456 | 456 |
457 if (!mount_point_name_.empty()) { | 457 if (!mount_point_name_.empty()) { |
458 job_list()->CancelAllJobs(); | 458 job_list()->CancelAllJobs(); |
459 | 459 |
460 FOR_EACH_OBSERVER(DriveIntegrationServiceObserver, observers_, | 460 FOR_EACH_OBSERVER(DriveIntegrationServiceObserver, observers_, |
461 OnFileSystemBeingUnmounted()); | 461 OnFileSystemBeingUnmounted()); |
462 | 462 |
463 fileapi::ExternalMountPoints* const mount_points = | 463 storage::ExternalMountPoints* const mount_points = |
464 fileapi::ExternalMountPoints::GetSystemInstance(); | 464 storage::ExternalMountPoints::GetSystemInstance(); |
465 DCHECK(mount_points); | 465 DCHECK(mount_points); |
466 | 466 |
467 mount_points->RevokeFileSystem(mount_point_name_); | 467 mount_points->RevokeFileSystem(mount_point_name_); |
468 logger_->Log(logging::LOG_INFO, "Drive mount point is removed"); | 468 logger_->Log(logging::LOG_INFO, "Drive mount point is removed"); |
469 } | 469 } |
470 } | 470 } |
471 | 471 |
472 void DriveIntegrationService::Initialize() { | 472 void DriveIntegrationService::Initialize() { |
473 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 473 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
474 DCHECK_EQ(NOT_INITIALIZED, state_); | 474 DCHECK_EQ(NOT_INITIALIZED, state_); |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
646 profile, preference_watcher, | 646 profile, preference_watcher, |
647 NULL, std::string(), base::FilePath(), NULL); | 647 NULL, std::string(), base::FilePath(), NULL); |
648 } else { | 648 } else { |
649 service = factory_for_test_->Run(profile); | 649 service = factory_for_test_->Run(profile); |
650 } | 650 } |
651 | 651 |
652 return service; | 652 return service; |
653 } | 653 } |
654 | 654 |
655 } // namespace drive | 655 } // namespace drive |
OLD | NEW |