| 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/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
| 10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
| (...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 return NULL; | 373 return NULL; |
| 374 | 374 |
| 375 return service; | 375 return service; |
| 376 } | 376 } |
| 377 | 377 |
| 378 // static | 378 // static |
| 379 DriveIntegrationService* | 379 DriveIntegrationService* |
| 380 DriveIntegrationServiceFactory::GetForProfileRegardlessOfStates( | 380 DriveIntegrationServiceFactory::GetForProfileRegardlessOfStates( |
| 381 Profile* profile) { | 381 Profile* profile) { |
| 382 return static_cast<DriveIntegrationService*>( | 382 return static_cast<DriveIntegrationService*>( |
| 383 GetInstance()->GetServiceForProfile(profile, true)); | 383 GetInstance()->GetServiceForBrowserContext(profile, true)); |
| 384 } | 384 } |
| 385 | 385 |
| 386 // static | 386 // static |
| 387 DriveIntegrationService* DriveIntegrationServiceFactory::FindForProfile( | 387 DriveIntegrationService* DriveIntegrationServiceFactory::FindForProfile( |
| 388 Profile* profile) { | 388 Profile* profile) { |
| 389 DriveIntegrationService* service = FindForProfileRegardlessOfStates(profile); | 389 DriveIntegrationService* service = FindForProfileRegardlessOfStates(profile); |
| 390 if (service && !service->IsDriveEnabled()) | 390 if (service && !service->IsDriveEnabled()) |
| 391 return NULL; | 391 return NULL; |
| 392 | 392 |
| 393 return service; | 393 return service; |
| 394 } | 394 } |
| 395 | 395 |
| 396 // static | 396 // static |
| 397 DriveIntegrationService* | 397 DriveIntegrationService* |
| 398 DriveIntegrationServiceFactory::FindForProfileRegardlessOfStates( | 398 DriveIntegrationServiceFactory::FindForProfileRegardlessOfStates( |
| 399 Profile* profile) { | 399 Profile* profile) { |
| 400 return static_cast<DriveIntegrationService*>( | 400 return static_cast<DriveIntegrationService*>( |
| 401 GetInstance()->GetServiceForProfile(profile, false)); | 401 GetInstance()->GetServiceForBrowserContext(profile, false)); |
| 402 } | 402 } |
| 403 | 403 |
| 404 // static | 404 // static |
| 405 DriveIntegrationServiceFactory* DriveIntegrationServiceFactory::GetInstance() { | 405 DriveIntegrationServiceFactory* DriveIntegrationServiceFactory::GetInstance() { |
| 406 return Singleton<DriveIntegrationServiceFactory>::get(); | 406 return Singleton<DriveIntegrationServiceFactory>::get(); |
| 407 } | 407 } |
| 408 | 408 |
| 409 // static | 409 // static |
| 410 void DriveIntegrationServiceFactory::SetFactoryForTest( | 410 void DriveIntegrationServiceFactory::SetFactoryForTest( |
| 411 const FactoryCallback& factory_for_test) { | 411 const FactoryCallback& factory_for_test) { |
| 412 GetInstance()->factory_for_test_ = factory_for_test; | 412 GetInstance()->factory_for_test_ = factory_for_test; |
| 413 } | 413 } |
| 414 | 414 |
| 415 DriveIntegrationServiceFactory::DriveIntegrationServiceFactory() | 415 DriveIntegrationServiceFactory::DriveIntegrationServiceFactory() |
| 416 : ProfileKeyedServiceFactory("DriveIntegrationService", | 416 : BrowserContextKeyedServiceFactory("DriveIntegrationService", |
| 417 ProfileDependencyManager::GetInstance()) { | 417 BrowserContextDependencyManager::GetInstance())
{ |
| 418 DependsOn(google_apis::DriveNotificationManagerFactory::GetInstance()); | 418 DependsOn(google_apis::DriveNotificationManagerFactory::GetInstance()); |
| 419 DependsOn(DownloadServiceFactory::GetInstance()); | 419 DependsOn(DownloadServiceFactory::GetInstance()); |
| 420 } | 420 } |
| 421 | 421 |
| 422 DriveIntegrationServiceFactory::~DriveIntegrationServiceFactory() { | 422 DriveIntegrationServiceFactory::~DriveIntegrationServiceFactory() { |
| 423 } | 423 } |
| 424 | 424 |
| 425 ProfileKeyedService* DriveIntegrationServiceFactory::BuildServiceInstanceFor( | 425 BrowserContextKeyedService* DriveIntegrationServiceFactory::BuildServiceInstance
For( |
| 426 content::BrowserContext* context) const { | 426 content::BrowserContext* context) const { |
| 427 Profile* profile = static_cast<Profile*>(context); | 427 Profile* profile = static_cast<Profile*>(context); |
| 428 | 428 |
| 429 DriveIntegrationService* service = NULL; | 429 DriveIntegrationService* service = NULL; |
| 430 if (factory_for_test_.is_null()) { | 430 if (factory_for_test_.is_null()) { |
| 431 service = new DriveIntegrationService( | 431 service = new DriveIntegrationService( |
| 432 profile, NULL, base::FilePath(), NULL); | 432 profile, NULL, base::FilePath(), NULL); |
| 433 } else { | 433 } else { |
| 434 service = factory_for_test_.Run(profile); | 434 service = factory_for_test_.Run(profile); |
| 435 } | 435 } |
| 436 | 436 |
| 437 service->Initialize(); | 437 service->Initialize(); |
| 438 return service; | 438 return service; |
| 439 } | 439 } |
| 440 | 440 |
| 441 } // namespace drive | 441 } // namespace drive |
| OLD | NEW |