| Index: chrome/browser/extensions/api/runtime/chrome_runtime_api_delegate.cc
|
| diff --git a/chrome/browser/extensions/api/runtime/chrome_runtime_api_delegate.cc b/chrome/browser/extensions/api/runtime/chrome_runtime_api_delegate.cc
|
| index b818c4ea6c9eb815f3404b1664ecf19d7e4e1d3d..1b9e1e0f27c64d7ee5331d47d51ef275f1c7accf 100644
|
| --- a/chrome/browser/extensions/api/runtime/chrome_runtime_api_delegate.cc
|
| +++ b/chrome/browser/extensions/api/runtime/chrome_runtime_api_delegate.cc
|
| @@ -16,6 +16,7 @@
|
| #include "base/threading/thread_task_runner_handle.h"
|
| #include "base/time/time.h"
|
| #include "build/build_config.h"
|
| +#include "chrome/browser/chrome_notification_types.h"
|
| #include "chrome/browser/extensions/extension_service.h"
|
| #include "chrome/browser/extensions/extension_tab_util.h"
|
| #include "chrome/browser/extensions/updater/extension_updater.h"
|
| @@ -139,6 +140,9 @@ ChromeRuntimeAPIDelegate::ChromeRuntimeAPIDelegate(
|
| registrar_.Add(this,
|
| extensions::NOTIFICATION_EXTENSION_UPDATE_FOUND,
|
| content::NotificationService::AllSources());
|
| + registrar_.Add(this,
|
| + chrome::NOTIFICATION_APP_TERMINATING,
|
| + content::NotificationService::AllSources());
|
| extension_registry_observer_.Add(
|
| extensions::ExtensionRegistry::Get(browser_context_));
|
| }
|
| @@ -324,6 +328,11 @@ bool ChromeRuntimeAPIDelegate::RestartDevice(std::string* error_message) {
|
| return false;
|
| }
|
|
|
| +void ChromeRuntimeAPIDelegate::SetOnDeviceShutdownCallback(
|
| + const base::Closure& callback) {
|
| + on_device_shutdown_callback_ = callback;
|
| +}
|
| +
|
| bool ChromeRuntimeAPIDelegate::OpenOptionsPage(const Extension* extension) {
|
| Profile* profile = Profile::FromBrowserContext(browser_context_);
|
| Browser* browser = chrome::FindLastActiveWithProfile(profile);
|
| @@ -336,13 +345,25 @@ void ChromeRuntimeAPIDelegate::Observe(
|
| int type,
|
| const content::NotificationSource& source,
|
| const content::NotificationDetails& details) {
|
| - DCHECK(type == extensions::NOTIFICATION_EXTENSION_UPDATE_FOUND);
|
| - typedef const std::pair<std::string, Version> UpdateDetails;
|
| - const std::string& id = content::Details<UpdateDetails>(details)->first;
|
| - const Version& version = content::Details<UpdateDetails>(details)->second;
|
| - if (version.IsValid()) {
|
| - CallUpdateCallbacks(
|
| - id, UpdateCheckResult(true, kUpdateFound, version.GetString()));
|
| + switch (type) {
|
| + case chrome::NOTIFICATION_APP_TERMINATING:
|
| + if (!on_device_shutdown_callback_.is_null())
|
| + on_device_shutdown_callback_.Run();
|
| + break;
|
| +
|
| + case extensions::NOTIFICATION_EXTENSION_UPDATE_FOUND: {
|
| + typedef const std::pair<std::string, Version> UpdateDetails;
|
| + const std::string& id = content::Details<UpdateDetails>(details)->first;
|
| + const Version& version = content::Details<UpdateDetails>(details)->second;
|
| + if (version.IsValid()) {
|
| + CallUpdateCallbacks(
|
| + id, UpdateCheckResult(true, kUpdateFound, version.GetString()));
|
| + }
|
| + break;
|
| + }
|
| +
|
| + default:
|
| + NOTREACHED() << "Unexpected notification.";
|
| }
|
| }
|
|
|
|
|