| 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 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 533 if (util::IsUnderDriveMountPoint( | 533 if (util::IsUnderDriveMountPoint( |
| 534 pref_service->GetFilePath(prefs::kDownloadDefaultDirectory))) { | 534 pref_service->GetFilePath(prefs::kDownloadDefaultDirectory))) { |
| 535 pref_service->SetFilePath( | 535 pref_service->SetFilePath( |
| 536 prefs::kDownloadDefaultDirectory, | 536 prefs::kDownloadDefaultDirectory, |
| 537 file_manager::util::GetDownloadsFolderForProfile(profile_)); | 537 file_manager::util::GetDownloadsFolderForProfile(profile_)); |
| 538 } | 538 } |
| 539 } | 539 } |
| 540 | 540 |
| 541 //===================== DriveIntegrationServiceFactory ======================= | 541 //===================== DriveIntegrationServiceFactory ======================= |
| 542 | 542 |
| 543 DriveIntegrationServiceFactory::FactoryCallback* |
| 544 DriveIntegrationServiceFactory::factory_for_test_ = NULL; |
| 545 |
| 543 // static | 546 // static |
| 544 DriveIntegrationService* DriveIntegrationServiceFactory::GetForProfile( | 547 DriveIntegrationService* DriveIntegrationServiceFactory::GetForProfile( |
| 545 Profile* profile) { | 548 Profile* profile) { |
| 546 return GetForProfileRegardlessOfStates(profile); | 549 return GetForProfileRegardlessOfStates(profile); |
| 547 } | 550 } |
| 548 | 551 |
| 549 // static | 552 // static |
| 550 DriveIntegrationService* | 553 DriveIntegrationService* |
| 551 DriveIntegrationServiceFactory::GetForProfileRegardlessOfStates( | 554 DriveIntegrationServiceFactory::GetForProfileRegardlessOfStates( |
| 552 Profile* profile) { | 555 Profile* profile) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 568 GetInstance()->GetServiceForBrowserContext(profile, false)); | 571 GetInstance()->GetServiceForBrowserContext(profile, false)); |
| 569 } | 572 } |
| 570 | 573 |
| 571 // static | 574 // static |
| 572 DriveIntegrationServiceFactory* DriveIntegrationServiceFactory::GetInstance() { | 575 DriveIntegrationServiceFactory* DriveIntegrationServiceFactory::GetInstance() { |
| 573 return Singleton<DriveIntegrationServiceFactory>::get(); | 576 return Singleton<DriveIntegrationServiceFactory>::get(); |
| 574 } | 577 } |
| 575 | 578 |
| 576 // static | 579 // static |
| 577 void DriveIntegrationServiceFactory::SetFactoryForTest( | 580 void DriveIntegrationServiceFactory::SetFactoryForTest( |
| 578 const FactoryCallback& factory_for_test) { | 581 FactoryCallback* factory_for_test) { |
| 579 GetInstance()->factory_for_test_ = factory_for_test; | 582 factory_for_test_ = factory_for_test; |
| 580 } | 583 } |
| 581 | 584 |
| 582 DriveIntegrationServiceFactory::DriveIntegrationServiceFactory() | 585 DriveIntegrationServiceFactory::DriveIntegrationServiceFactory() |
| 583 : BrowserContextKeyedServiceFactory( | 586 : BrowserContextKeyedServiceFactory( |
| 584 "DriveIntegrationService", | 587 "DriveIntegrationService", |
| 585 BrowserContextDependencyManager::GetInstance()) { | 588 BrowserContextDependencyManager::GetInstance()) { |
| 586 DependsOn(ProfileOAuth2TokenServiceFactory::GetInstance()); | 589 DependsOn(ProfileOAuth2TokenServiceFactory::GetInstance()); |
| 587 DependsOn(DriveNotificationManagerFactory::GetInstance()); | 590 DependsOn(DriveNotificationManagerFactory::GetInstance()); |
| 588 DependsOn(DownloadServiceFactory::GetInstance()); | 591 DependsOn(DownloadServiceFactory::GetInstance()); |
| 589 } | 592 } |
| 590 | 593 |
| 591 DriveIntegrationServiceFactory::~DriveIntegrationServiceFactory() { | 594 DriveIntegrationServiceFactory::~DriveIntegrationServiceFactory() { |
| 592 } | 595 } |
| 593 | 596 |
| 594 BrowserContextKeyedService* | 597 BrowserContextKeyedService* |
| 595 DriveIntegrationServiceFactory::BuildServiceInstanceFor( | 598 DriveIntegrationServiceFactory::BuildServiceInstanceFor( |
| 596 content::BrowserContext* context) const { | 599 content::BrowserContext* context) const { |
| 597 Profile* profile = Profile::FromBrowserContext(context); | 600 Profile* profile = Profile::FromBrowserContext(context); |
| 598 | 601 |
| 599 DriveIntegrationService* service = NULL; | 602 DriveIntegrationService* service = NULL; |
| 600 if (factory_for_test_.is_null()) { | 603 if (!factory_for_test_) { |
| 601 DriveIntegrationService::PreferenceWatcher* preference_watcher = NULL; | 604 DriveIntegrationService::PreferenceWatcher* preference_watcher = NULL; |
| 602 if (chromeos::IsProfileAssociatedWithGaiaAccount(profile)) { | 605 if (chromeos::IsProfileAssociatedWithGaiaAccount(profile)) { |
| 603 // Drive File System can be enabled. | 606 // Drive File System can be enabled. |
| 604 preference_watcher = | 607 preference_watcher = |
| 605 new DriveIntegrationService::PreferenceWatcher(profile->GetPrefs()); | 608 new DriveIntegrationService::PreferenceWatcher(profile->GetPrefs()); |
| 606 } | 609 } |
| 607 | 610 |
| 608 service = new DriveIntegrationService(profile, preference_watcher, | 611 service = new DriveIntegrationService(profile, preference_watcher, |
| 609 NULL, base::FilePath(), NULL); | 612 NULL, base::FilePath(), NULL); |
| 610 } else { | 613 } else { |
| 611 service = factory_for_test_.Run(profile); | 614 service = factory_for_test_->Run(profile); |
| 612 } | 615 } |
| 613 | 616 |
| 614 return service; | 617 return service; |
| 615 } | 618 } |
| 616 | 619 |
| 617 } // namespace drive | 620 } // namespace drive |
| OLD | NEW |