| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/apps/drive/drive_app_provider.h" | 5 #include "chrome/browser/apps/drive/drive_app_provider.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
| 13 #include "base/location.h" | 13 #include "base/location.h" |
| 14 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "base/single_thread_task_runner.h" | 15 #include "base/single_thread_task_runner.h" |
| 16 #include "base/stl_util.h" | 16 #include "base/stl_util.h" |
| 17 #include "base/thread_task_runner_handle.h" | 17 #include "base/thread_task_runner_handle.h" |
| 18 #include "chrome/browser/apps/drive/drive_app_converter.h" | 18 #include "chrome/browser/apps/drive/drive_app_converter.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 37 void IgnoreUninstallResult(google_apis::DriveApiErrorCode) { | 37 void IgnoreUninstallResult(google_apis::DriveApiErrorCode) { |
| 38 } | 38 } |
| 39 | 39 |
| 40 } // namespace | 40 } // namespace |
| 41 | 41 |
| 42 DriveAppProvider::DriveAppProvider( | 42 DriveAppProvider::DriveAppProvider( |
| 43 Profile* profile, | 43 Profile* profile, |
| 44 DriveAppUninstallSyncService* uninstall_sync_service) | 44 DriveAppUninstallSyncService* uninstall_sync_service) |
| 45 : profile_(profile), | 45 : profile_(profile), |
| 46 uninstall_sync_service_(uninstall_sync_service), | 46 uninstall_sync_service_(uninstall_sync_service), |
| 47 service_bridge_(DriveServiceBridge::Create(profile).Pass()), | 47 service_bridge_(DriveServiceBridge::Create(profile)), |
| 48 mapping_(new DriveAppMapping(profile->GetPrefs())), | 48 mapping_(new DriveAppMapping(profile->GetPrefs())), |
| 49 drive_app_registry_updated_(false), | 49 drive_app_registry_updated_(false), |
| 50 weak_ptr_factory_(this) { | 50 weak_ptr_factory_(this) { |
| 51 service_bridge_->GetAppRegistry()->AddObserver(this); | 51 service_bridge_->GetAppRegistry()->AddObserver(this); |
| 52 ExtensionRegistry::Get(profile_)->AddObserver(this); | 52 ExtensionRegistry::Get(profile_)->AddObserver(this); |
| 53 } | 53 } |
| 54 | 54 |
| 55 DriveAppProvider::~DriveAppProvider() { | 55 DriveAppProvider::~DriveAppProvider() { |
| 56 ExtensionRegistry::Get(profile_)->RemoveObserver(this); | 56 ExtensionRegistry::Get(profile_)->RemoveObserver(this); |
| 57 service_bridge_->GetAppRegistry()->RemoveObserver(this); | 57 service_bridge_->GetAppRegistry()->RemoveObserver(this); |
| 58 } | 58 } |
| 59 | 59 |
| 60 // static | 60 // static |
| 61 void DriveAppProvider::AppendDependsOnFactories( | 61 void DriveAppProvider::AppendDependsOnFactories( |
| 62 std::set<BrowserContextKeyedServiceFactory*>* factories) { | 62 std::set<BrowserContextKeyedServiceFactory*>* factories) { |
| 63 factories->insert(extensions::ExtensionRegistryFactory::GetInstance()); | 63 factories->insert(extensions::ExtensionRegistryFactory::GetInstance()); |
| 64 DriveServiceBridge::AppendDependsOnFactories(factories); | 64 DriveServiceBridge::AppendDependsOnFactories(factories); |
| 65 } | 65 } |
| 66 | 66 |
| 67 void DriveAppProvider::SetDriveServiceBridgeForTest( | 67 void DriveAppProvider::SetDriveServiceBridgeForTest( |
| 68 scoped_ptr<DriveServiceBridge> test_bridge) { | 68 scoped_ptr<DriveServiceBridge> test_bridge) { |
| 69 service_bridge_->GetAppRegistry()->RemoveObserver(this); | 69 service_bridge_->GetAppRegistry()->RemoveObserver(this); |
| 70 service_bridge_ = test_bridge.Pass(); | 70 service_bridge_ = std::move(test_bridge); |
| 71 service_bridge_->GetAppRegistry()->AddObserver(this); | 71 service_bridge_->GetAppRegistry()->AddObserver(this); |
| 72 } | 72 } |
| 73 | 73 |
| 74 void DriveAppProvider::AddUninstalledDriveAppFromSync( | 74 void DriveAppProvider::AddUninstalledDriveAppFromSync( |
| 75 const std::string& drive_app_id) { | 75 const std::string& drive_app_id) { |
| 76 mapping_->AddUninstalledDriveApp(drive_app_id); | 76 mapping_->AddUninstalledDriveApp(drive_app_id); |
| 77 | 77 |
| 78 // Decouple the operation because this function could be called during | 78 // Decouple the operation because this function could be called during |
| 79 // sync processing and UpdateDriveApps could trigger another sync change. | 79 // sync processing and UpdateDriveApps could trigger another sync change. |
| 80 // See http://crbug.com/429205 | 80 // See http://crbug.com/429205 |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 service_bridge_->GetAppRegistry()->UninstallApp( | 327 service_bridge_->GetAppRegistry()->UninstallApp( |
| 328 drive_app_id, base::Bind(&IgnoreUninstallResult)); | 328 drive_app_id, base::Bind(&IgnoreUninstallResult)); |
| 329 } else { | 329 } else { |
| 330 mapping_->AddUninstalledDriveApp(drive_app_id); | 330 mapping_->AddUninstalledDriveApp(drive_app_id); |
| 331 uninstall_sync_service_->TrackUninstalledDriveApp(drive_app_id); | 331 uninstall_sync_service_->TrackUninstalledDriveApp(drive_app_id); |
| 332 } | 332 } |
| 333 | 333 |
| 334 return; | 334 return; |
| 335 } | 335 } |
| 336 } | 336 } |
| OLD | NEW |