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