| 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/sync_file_system/sync_file_system_service.h" | 5 #include "chrome/browser/sync_file_system/sync_file_system_service.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 } | 444 } |
| 445 | 445 |
| 446 void SyncFileSystemService::Observe( | 446 void SyncFileSystemService::Observe( |
| 447 int type, | 447 int type, |
| 448 const content::NotificationSource& source, | 448 const content::NotificationSource& source, |
| 449 const content::NotificationDetails& details) { | 449 const content::NotificationDetails& details) { |
| 450 // Event notification sequence. | 450 // Event notification sequence. |
| 451 // | 451 // |
| 452 // (User action) (Notification type) | 452 // (User action) (Notification type) |
| 453 // Install: INSTALLED. | 453 // Install: INSTALLED. |
| 454 // Update: INSTALLED. |
| 454 // Uninstall: UNLOADED(UNINSTALL). | 455 // Uninstall: UNLOADED(UNINSTALL). |
| 455 // Launch, Close: No notification. | 456 // Launch, Close: No notification. |
| 456 // Enable: EABLED. | 457 // Enable: EABLED. |
| 457 // Disable: UNLOADED(DISABLE). | 458 // Disable: UNLOADED(DISABLE). |
| 458 // Reload, Restart: UNLOADED(DISABLE) -> INSTALLED -> ENABLED. | 459 // Reload, Restart: UNLOADED(DISABLE) -> INSTALLED -> ENABLED. |
| 459 // | 460 // |
| 460 switch (type) { | 461 switch (type) { |
| 461 case chrome::NOTIFICATION_EXTENSION_INSTALLED: | 462 case chrome::NOTIFICATION_EXTENSION_INSTALLED: |
| 462 HandleExtensionInstalled(details); | 463 HandleExtensionInstalled(details); |
| 463 break; | 464 break; |
| 464 case chrome::NOTIFICATION_EXTENSION_UNLOADED: | 465 case chrome::NOTIFICATION_EXTENSION_UNLOADED: |
| 465 HandleExtensionUnloaded(type, details); | 466 HandleExtensionUnloaded(type, details); |
| 466 break; | 467 break; |
| 467 case chrome::NOTIFICATION_EXTENSION_ENABLED: | 468 case chrome::NOTIFICATION_EXTENSION_ENABLED: |
| 468 HandleExtensionEnabled(type, details); | 469 HandleExtensionEnabled(type, details); |
| 469 break; | 470 break; |
| 470 default: | 471 default: |
| 471 NOTREACHED() << "Unknown notification."; | 472 NOTREACHED() << "Unknown notification."; |
| 472 break; | 473 break; |
| 473 } | 474 } |
| 474 } | 475 } |
| 475 | 476 |
| 476 void SyncFileSystemService::HandleExtensionInstalled( | 477 void SyncFileSystemService::HandleExtensionInstalled( |
| 477 const content::NotificationDetails& details) { | 478 const content::NotificationDetails& details) { |
| 478 content::Details<const extensions::Extension> extension(details); | 479 const extensions::Extension* extension = |
| 480 content::Details<const extensions::InstalledExtensionInfo>(details)-> |
| 481 extension; |
| 479 GURL app_origin = | 482 GURL app_origin = |
| 480 extensions::Extension::GetBaseURLFromExtensionId(extension->id()); | 483 extensions::Extension::GetBaseURLFromExtensionId(extension->id()); |
| 481 DVLOG(1) << "Handle extension notification for INSTALLED: " << app_origin; | 484 DVLOG(1) << "Handle extension notification for INSTALLED: " << app_origin; |
| 482 // NOTE: When an app is uninstalled and re-installed in a sequence, | 485 // NOTE: When an app is uninstalled and re-installed in a sequence, |
| 483 // |local_file_service_| may still keeps |app_origin| as disabled origin. | 486 // |local_file_service_| may still keeps |app_origin| as disabled origin. |
| 484 local_file_service_->SetOriginEnabled(app_origin, true); | 487 local_file_service_->SetOriginEnabled(app_origin, true); |
| 485 } | 488 } |
| 486 | 489 |
| 487 void SyncFileSystemService::HandleExtensionUnloaded( | 490 void SyncFileSystemService::HandleExtensionUnloaded( |
| 488 int type, | 491 int type, |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 556 syncer::APPS); | 559 syncer::APPS); |
| 557 remote_file_service_->SetSyncEnabled(sync_enabled_); | 560 remote_file_service_->SetSyncEnabled(sync_enabled_); |
| 558 if (sync_enabled_) { | 561 if (sync_enabled_) { |
| 559 base::MessageLoopProxy::current()->PostTask( | 562 base::MessageLoopProxy::current()->PostTask( |
| 560 FROM_HERE, base::Bind(&SyncFileSystemService::MaybeStartSync, | 563 FROM_HERE, base::Bind(&SyncFileSystemService::MaybeStartSync, |
| 561 AsWeakPtr())); | 564 AsWeakPtr())); |
| 562 } | 565 } |
| 563 } | 566 } |
| 564 | 567 |
| 565 } // namespace sync_file_system | 568 } // namespace sync_file_system |
| OLD | NEW |