Chromium Code Reviews| Index: chrome/browser/sync_file_system/sync_file_system_service.cc |
| diff --git a/chrome/browser/sync_file_system/sync_file_system_service.cc b/chrome/browser/sync_file_system/sync_file_system_service.cc |
| index 4774edfd17356c0671bac3a9545616a7a76f8d55..306677b59fcc06844a66355ade4f59ae184e62af 100644 |
| --- a/chrome/browser/sync_file_system/sync_file_system_service.cc |
| +++ b/chrome/browser/sync_file_system/sync_file_system_service.cc |
| @@ -196,6 +196,8 @@ void SyncFileSystemService::Initialize( |
| content::Source<Profile>(profile_)); |
| registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, |
| content::Source<Profile>(profile_)); |
| + registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_ENABLED, |
| + content::Source<Profile>(profile_)); |
| } |
| void SyncFileSystemService::DidInitializeFileSystem( |
| @@ -398,27 +400,75 @@ void SyncFileSystemService::Observe( |
| int type, |
| const content::NotificationSource& source, |
| const content::NotificationDetails& details) { |
| - if (chrome::NOTIFICATION_EXTENSION_UNLOADED == type) { |
| - // Unregister origin for remote synchronization. |
| - std::string extension_id = |
| - content::Details<const extensions::UnloadedExtensionInfo>( |
| - details)->extension->id(); |
| - GURL app_origin = extensions::Extension::GetBaseURLFromExtensionId( |
| - extension_id); |
| - remote_file_service_->UnregisterOriginForTrackingChanges( |
| - app_origin, base::Bind(&DidHandleOriginForExtensionEvent, |
| - type, app_origin)); |
| - local_file_service_->SetOriginEnabled(app_origin, false); |
| - } else if (chrome::NOTIFICATION_EXTENSION_LOADED == type) { |
| - std::string extension_id = |
| - content::Details<const extensions::Extension>( |
| - details)->id(); |
| - GURL app_origin = extensions::Extension::GetBaseURLFromExtensionId( |
| - extension_id); |
| - local_file_service_->SetOriginEnabled(app_origin, true); |
| - } else { |
| - NOTREACHED() << "Unknown notification."; |
| + switch (type) { |
|
kinuko
2013/03/16 23:16:51
Can you add a comment about when each event is del
nhiroki
2013/03/18 09:40:18
Done.
|
| + case chrome::NOTIFICATION_EXTENSION_UNLOADED: |
| + HandleExtensionUnloaded(type, details); |
| + break; |
| + case chrome::NOTIFICATION_EXTENSION_LOADED: |
| + HandleExtensionLoaded(details); |
| + break; |
| + case chrome::NOTIFICATION_EXTENSION_ENABLED: |
| + HandleExtensionEnabled(type, details); |
| + break; |
| + default: |
| + NOTREACHED() << "Unknown notification."; |
| + break; |
| + } |
| +} |
| + |
| +void SyncFileSystemService::HandleExtensionUnloaded( |
| + int type, |
| + const content::NotificationDetails& details) { |
| + content::Details<const extensions::UnloadedExtensionInfo> info = |
| + content::Details<const extensions::UnloadedExtensionInfo>(details); |
| + std::string extension_id = info->extension->id(); |
| + GURL app_origin = |
| + extensions::Extension::GetBaseURLFromExtensionId(extension_id); |
| + |
| + switch (info->reason) { |
| + case extension_misc::UNLOAD_REASON_DISABLE: |
| + DVLOG(1) << "Handle extension notification for UNLOAD(DISABLE): " |
| + << app_origin; |
| + remote_file_service_->DisableOriginForTrackingChanges( |
| + app_origin, |
| + base::Bind(&DidHandleOriginForExtensionEvent, type, app_origin)); |
| + break; |
| + case extension_misc::UNLOAD_REASON_UNINSTALL: |
| + DVLOG(1) << "Handle extension notification for UNLOAD(UNINSTALL): " |
| + << app_origin; |
| + remote_file_service_->UnregisterOriginForTrackingChanges( |
| + app_origin, |
| + base::Bind(&DidHandleOriginForExtensionEvent, type, app_origin)); |
| + break; |
| + default: |
| + // Nothing to do. |
| + break; |
| } |
| + |
| + local_file_service_->SetOriginEnabled(app_origin, false); |
| +} |
| + |
| +void SyncFileSystemService::HandleExtensionLoaded( |
| + const content::NotificationDetails& details) { |
| + std::string extension_id = |
| + content::Details<const extensions::Extension>(details)->id(); |
| + GURL app_origin = |
| + extensions::Extension::GetBaseURLFromExtensionId(extension_id); |
| + DVLOG(1) << "Handle extension notification for LOADED: " << app_origin; |
| + local_file_service_->SetOriginEnabled(app_origin, true); |
| +} |
| + |
| +void SyncFileSystemService::HandleExtensionEnabled( |
| + int type, |
| + const content::NotificationDetails& details) { |
| + std::string extension_id = |
| + content::Details<const extensions::Extension>(details)->id(); |
| + GURL app_origin = |
| + extensions::Extension::GetBaseURLFromExtensionId(extension_id); |
| + DVLOG(1) << "Handle extension notification for ENABLED: " << app_origin; |
| + remote_file_service_->EnableOriginForTrackingChanges( |
| + app_origin, |
| + base::Bind(&DidHandleOriginForExtensionEvent, type, app_origin)); |
|
kinuko
2013/03/16 23:16:51
Looking into the table in https://code.google.com/
nhiroki
2013/03/18 09:40:18
Removed HandleExtensionLoaded and DCHECK from Loca
|
| } |
| void SyncFileSystemService::OnStateChanged() { |