Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(636)

Unified Diff: chrome/browser/extensions/api/runtime/chrome_runtime_api_delegate.cc

Issue 1970613003: Add a new app API to enable watchdog behavior restarts in kiosk apps (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Missing include Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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.";
}
}

Powered by Google App Engine
This is Rietveld 408576698