| 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/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 void DriveIntegrationService::OnNotificationReceived() { | 264 void DriveIntegrationService::OnNotificationReceived() { |
| 265 file_system_->CheckForUpdates(); | 265 file_system_->CheckForUpdates(); |
| 266 drive_app_registry_->Update(); | 266 drive_app_registry_->Update(); |
| 267 } | 267 } |
| 268 | 268 |
| 269 void DriveIntegrationService::OnPushNotificationEnabled(bool enabled) { | 269 void DriveIntegrationService::OnPushNotificationEnabled(bool enabled) { |
| 270 if (enabled) | 270 if (enabled) |
| 271 drive_app_registry_->Update(); | 271 drive_app_registry_->Update(); |
| 272 | 272 |
| 273 const char* status = (enabled ? "enabled" : "disabled"); | 273 const char* status = (enabled ? "enabled" : "disabled"); |
| 274 util::Log("Push notification is %s", status); | 274 util::Log(logging::LOG_INFO, "Push notification is %s", status); |
| 275 } | 275 } |
| 276 | 276 |
| 277 bool DriveIntegrationService::IsDriveEnabled() { | 277 bool DriveIntegrationService::IsDriveEnabled() { |
| 278 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 278 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 279 | 279 |
| 280 if (!IsDriveEnabledForProfile(profile_)) | 280 if (!IsDriveEnabledForProfile(profile_)) |
| 281 return false; | 281 return false; |
| 282 | 282 |
| 283 // Drive may be disabled for cache initialization failure, etc. | 283 // Drive may be disabled for cache initialization failure, etc. |
| 284 if (drive_disabled_) | 284 if (drive_disabled_) |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 fileapi::ExternalMountPoints* mount_points = | 329 fileapi::ExternalMountPoints* mount_points = |
| 330 BrowserContext::GetMountPoints(profile_); | 330 BrowserContext::GetMountPoints(profile_); |
| 331 DCHECK(mount_points); | 331 DCHECK(mount_points); |
| 332 | 332 |
| 333 bool success = mount_points->RegisterFileSystem( | 333 bool success = mount_points->RegisterFileSystem( |
| 334 drive_mount_point.BaseName().AsUTF8Unsafe(), | 334 drive_mount_point.BaseName().AsUTF8Unsafe(), |
| 335 fileapi::kFileSystemTypeDrive, | 335 fileapi::kFileSystemTypeDrive, |
| 336 drive_mount_point); | 336 drive_mount_point); |
| 337 | 337 |
| 338 if (success) { | 338 if (success) { |
| 339 util::Log("Drive mount point is added"); | 339 util::Log(logging::LOG_INFO, "Drive mount point is added"); |
| 340 FOR_EACH_OBSERVER(DriveIntegrationServiceObserver, observers_, | 340 FOR_EACH_OBSERVER(DriveIntegrationServiceObserver, observers_, |
| 341 OnFileSystemMounted()); | 341 OnFileSystemMounted()); |
| 342 } | 342 } |
| 343 } | 343 } |
| 344 | 344 |
| 345 void DriveIntegrationService::RemoveDriveMountPoint() { | 345 void DriveIntegrationService::RemoveDriveMountPoint() { |
| 346 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 346 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 347 | 347 |
| 348 job_list()->CancelAllJobs(); | 348 job_list()->CancelAllJobs(); |
| 349 | 349 |
| 350 FOR_EACH_OBSERVER(DriveIntegrationServiceObserver, observers_, | 350 FOR_EACH_OBSERVER(DriveIntegrationServiceObserver, observers_, |
| 351 OnFileSystemBeingUnmounted()); | 351 OnFileSystemBeingUnmounted()); |
| 352 | 352 |
| 353 fileapi::ExternalMountPoints* mount_points = | 353 fileapi::ExternalMountPoints* mount_points = |
| 354 BrowserContext::GetMountPoints(profile_); | 354 BrowserContext::GetMountPoints(profile_); |
| 355 DCHECK(mount_points); | 355 DCHECK(mount_points); |
| 356 | 356 |
| 357 mount_points->RevokeFileSystem( | 357 mount_points->RevokeFileSystem( |
| 358 util::GetDriveMountPointPath().BaseName().AsUTF8Unsafe()); | 358 util::GetDriveMountPointPath().BaseName().AsUTF8Unsafe()); |
| 359 util::Log("Drive mount point is removed"); | 359 util::Log(logging::LOG_INFO, "Drive mount point is removed"); |
| 360 } | 360 } |
| 361 | 361 |
| 362 void DriveIntegrationService::InitializeAfterMetadataInitialized( | 362 void DriveIntegrationService::InitializeAfterMetadataInitialized( |
| 363 FileError error) { | 363 FileError error) { |
| 364 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 364 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 365 | 365 |
| 366 if (error != FILE_ERROR_OK) { | 366 if (error != FILE_ERROR_OK) { |
| 367 LOG(WARNING) << "Failed to initialize. Disabling Drive : " | 367 LOG(WARNING) << "Failed to initialize. Disabling Drive : " |
| 368 << FileErrorToString(error); | 368 << FileErrorToString(error); |
| 369 DisableDrive(); | 369 DisableDrive(); |
| 370 return; | 370 return; |
| 371 } | 371 } |
| 372 | 372 |
| 373 content::DownloadManager* download_manager = | 373 content::DownloadManager* download_manager = |
| 374 g_browser_process->download_status_updater() ? | 374 g_browser_process->download_status_updater() ? |
| 375 BrowserContext::GetDownloadManager(profile_) : NULL; | 375 BrowserContext::GetDownloadManager(profile_) : NULL; |
| 376 download_handler_->Initialize( | 376 download_handler_->Initialize( |
| 377 download_manager, | 377 download_manager, |
| 378 cache_root_directory_.Append(util::kTemporaryFileDirectory)); | 378 cache_root_directory_.Append(util::kTemporaryFileDirectory)); |
| 379 | 379 |
| 380 // Register for Google Drive invalidation notifications. | 380 // Register for Google Drive invalidation notifications. |
| 381 DriveNotificationManager* drive_notification_manager = | 381 DriveNotificationManager* drive_notification_manager = |
| 382 DriveNotificationManagerFactory::GetForProfile(profile_); | 382 DriveNotificationManagerFactory::GetForProfile(profile_); |
| 383 if (drive_notification_manager) { | 383 if (drive_notification_manager) { |
| 384 drive_notification_manager->AddObserver(this); | 384 drive_notification_manager->AddObserver(this); |
| 385 const bool registered = | 385 const bool registered = |
| 386 drive_notification_manager->push_notification_registered(); | 386 drive_notification_manager->push_notification_registered(); |
| 387 const char* status = (registered ? "registered" : "not registered"); | 387 const char* status = (registered ? "registered" : "not registered"); |
| 388 util::Log("Push notification is %s", status); | 388 util::Log(logging::LOG_INFO, "Push notification is %s", status); |
| 389 | 389 |
| 390 if (drive_notification_manager->push_notification_enabled()) | 390 if (drive_notification_manager->push_notification_enabled()) |
| 391 drive_app_registry_->Update(); | 391 drive_app_registry_->Update(); |
| 392 } | 392 } |
| 393 | 393 |
| 394 AddDriveMountPoint(); | 394 AddDriveMountPoint(); |
| 395 } | 395 } |
| 396 | 396 |
| 397 void DriveIntegrationService::DisableDrive() { | 397 void DriveIntegrationService::DisableDrive() { |
| 398 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 398 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 480 profile, NULL, base::FilePath(), NULL); | 480 profile, NULL, base::FilePath(), NULL); |
| 481 } else { | 481 } else { |
| 482 service = factory_for_test_.Run(profile); | 482 service = factory_for_test_.Run(profile); |
| 483 } | 483 } |
| 484 | 484 |
| 485 service->Initialize(); | 485 service->Initialize(); |
| 486 return service; | 486 return service; |
| 487 } | 487 } |
| 488 | 488 |
| 489 } // namespace drive | 489 } // namespace drive |
| OLD | NEW |