| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/first_run/drive_first_run_controller.h" | 5 #include "chrome/browser/chromeos/first_run/drive_first_run_controller.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "ash/common/system/tray/system_tray_delegate.h" | 10 #include "ash/common/system/tray/system_tray_delegate.h" |
| (...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 418 void DriveFirstRunController::SetAppInfoForTest( | 418 void DriveFirstRunController::SetAppInfoForTest( |
| 419 const std::string& app_id, | 419 const std::string& app_id, |
| 420 const std::string& endpoint_url) { | 420 const std::string& endpoint_url) { |
| 421 DCHECK(!started_); | 421 DCHECK(!started_); |
| 422 drive_hosted_app_id_ = app_id; | 422 drive_hosted_app_id_ = app_id; |
| 423 drive_offline_endpoint_url_ = endpoint_url; | 423 drive_offline_endpoint_url_ = endpoint_url; |
| 424 } | 424 } |
| 425 | 425 |
| 426 void DriveFirstRunController::OnWebContentsTimedOut() { | 426 void DriveFirstRunController::OnWebContentsTimedOut() { |
| 427 LOG(WARNING) << "Timed out waiting for web contents."; | 427 LOG(WARNING) << "Timed out waiting for web contents."; |
| 428 FOR_EACH_OBSERVER(Observer, observer_list_, OnTimedOut()); | 428 for (auto& observer : observer_list_) |
| 429 observer.OnTimedOut(); |
| 429 OnOfflineInit(false, OUTCOME_WEB_CONTENTS_TIMED_OUT); | 430 OnOfflineInit(false, OUTCOME_WEB_CONTENTS_TIMED_OUT); |
| 430 } | 431 } |
| 431 | 432 |
| 432 void DriveFirstRunController::CleanUp() { | 433 void DriveFirstRunController::CleanUp() { |
| 433 if (web_contents_manager_) | 434 if (web_contents_manager_) |
| 434 web_contents_manager_->StopLoad(); | 435 web_contents_manager_->StopLoad(); |
| 435 web_contents_timer_.Stop(); | 436 web_contents_timer_.Stop(); |
| 436 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, this); | 437 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, this); |
| 437 } | 438 } |
| 438 | 439 |
| 439 void DriveFirstRunController::OnOfflineInit(bool success, UMAOutcome outcome) { | 440 void DriveFirstRunController::OnOfflineInit(bool success, UMAOutcome outcome) { |
| 440 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 441 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 441 if (success) | 442 if (success) |
| 442 ShowNotification(); | 443 ShowNotification(); |
| 443 UMA_HISTOGRAM_ENUMERATION("DriveOffline.CrosAutoEnableOutcome", | 444 UMA_HISTOGRAM_ENUMERATION("DriveOffline.CrosAutoEnableOutcome", |
| 444 outcome, OUTCOME_MAX); | 445 outcome, OUTCOME_MAX); |
| 445 FOR_EACH_OBSERVER(Observer, observer_list_, OnCompletion(success)); | 446 for (auto& observer : observer_list_) |
| 447 observer.OnCompletion(success); |
| 446 CleanUp(); | 448 CleanUp(); |
| 447 } | 449 } |
| 448 | 450 |
| 449 void DriveFirstRunController::ShowNotification() { | 451 void DriveFirstRunController::ShowNotification() { |
| 450 ExtensionService* service = | 452 ExtensionService* service = |
| 451 extensions::ExtensionSystem::Get(profile_)->extension_service(); | 453 extensions::ExtensionSystem::Get(profile_)->extension_service(); |
| 452 DCHECK(service); | 454 DCHECK(service); |
| 453 const extensions::Extension* extension = | 455 const extensions::Extension* extension = |
| 454 service->GetExtensionById(drive_hosted_app_id_, false); | 456 service->GetExtensionById(drive_hosted_app_id_, false); |
| 455 DCHECK(extension); | 457 DCHECK(extension); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 467 base::UTF8ToUTF16(extension->name()), GURL(), | 469 base::UTF8ToUTF16(extension->name()), GURL(), |
| 468 message_center::NotifierId(message_center::NotifierId::APPLICATION, | 470 message_center::NotifierId(message_center::NotifierId::APPLICATION, |
| 469 kDriveHostedAppId), | 471 kDriveHostedAppId), |
| 470 data, new DriveOfflineNotificationDelegate(profile_))); | 472 data, new DriveOfflineNotificationDelegate(profile_))); |
| 471 notification->set_priority(message_center::LOW_PRIORITY); | 473 notification->set_priority(message_center::LOW_PRIORITY); |
| 472 message_center::MessageCenter::Get()->AddNotification( | 474 message_center::MessageCenter::Get()->AddNotification( |
| 473 std::move(notification)); | 475 std::move(notification)); |
| 474 } | 476 } |
| 475 | 477 |
| 476 } // namespace chromeos | 478 } // namespace chromeos |
| OLD | NEW |