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

Unified Diff: chrome/browser/extensions/chrome_runtime_api_delegate.h

Issue 264743014: Move chrome.runtime to //extensions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 8 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/chrome_runtime_api_delegate.h
diff --git a/chrome/browser/extensions/chrome_runtime_api_delegate.h b/chrome/browser/extensions/chrome_runtime_api_delegate.h
new file mode 100644
index 0000000000000000000000000000000000000000..0d69d20c4449b41e816d84312f6b6bf8f1d3a0c7
--- /dev/null
+++ b/chrome/browser/extensions/chrome_runtime_api_delegate.h
@@ -0,0 +1,88 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_EXTENSIONS_CHROME_RUNTIME_API_DELEGATE_H_
+#define CHROME_BROWSER_EXTENSIONS_CHROME_RUNTIME_API_DELEGATE_H_
+
+#include <map>
+#include <vector>
+
+#include "content/public/browser/notification_observer.h"
+#include "content/public/browser/notification_registrar.h"
+#include "extensions/browser/api/runtime/runtime_api.h"
+#include "extensions/browser/runtime_api_delegate.h"
+
+namespace base {
+class TimeTicks;
+}
+
+namespace content {
+class BrowserContext;
+class NotificationDetails;
+class NotificationSource;
+}
+
+namespace extensions {
+class RuntimeAPI;
+class UpdateObserver;
+}
+
+class ChromeRuntimeAPIDelegate : public extensions::RuntimeAPIDelegate,
not at google - send to devlin 2014/05/05 19:26:15 can this be in chrome/browser/extensions/api/runti
Ken Rockot(use gerrit already) 2014/05/05 21:08:07 Done.
+ public content::NotificationObserver {
+ public:
+ explicit ChromeRuntimeAPIDelegate(content::BrowserContext* context);
+ virtual ~ChromeRuntimeAPIDelegate();
+
+ private:
+ friend class extensions::RuntimeAPI;
+
+ // extensions::RuntimeAPIDelegate implementation.
+ virtual void RegisterUpdateObserver(
+ extensions::UpdateObserver* observer) OVERRIDE;
+ virtual void UnregisterUpdateObserver(
+ extensions::UpdateObserver* observer) OVERRIDE;
+ virtual base::Version GetOldExtensionVersion(
+ const extensions::Extension* extension) OVERRIDE;
+ virtual void MaybeReloadExtension(const std::string& extension_id) OVERRIDE;
+ virtual bool RequestUpdateCheck(
+ const std::string& extension_id,
+ const extensions::RuntimeAPI::UpdateCheckCallback& callback) OVERRIDE;
+ virtual void HandleUninstall(const std::string& extension_id,
+ const GURL& uninstall_url) OVERRIDE;
+ virtual bool GetPlatformInfo(
+ extensions::core_api::runtime::GetPlatformInfo::Results::PlatformInfo*
+ info) OVERRIDE;
+ virtual bool RequestRestart(std::string* error_message) OVERRIDE;
+
+ // content::NotificationObserver implementation.
+ virtual void Observe(int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) OVERRIDE;
+
+ void UpdateCheckComplete(const std::string& extension_id);
+ void CallUpdateCallbacks(
+ const std::string& extension_id,
+ const extensions::RuntimeAPI::UpdateCheckResult& result);
+
+ content::BrowserContext* browser_context_;
+
+ content::NotificationRegistrar registrar_;
+
+ // Whether the API registered with the ExtensionService to receive
+ // update notifications.
+ bool registered_for_updates_;
+
+ // Map to prevent extensions from getting stuck in reload loops. Maps
+ // extension id to the last time it was reloaded and the number of times
+ // it was reloaded with not enough time in between reloads.
+ std::map<std::string, std::pair<base::TimeTicks, int> > last_reload_time_;
+
+ // Pending update checks.
+ typedef std::vector<extensions::RuntimeAPI::UpdateCheckCallback>
+ UpdateCallbackList;
+ typedef std::map<std::string, UpdateCallbackList> UpdateCallbackMap;
+ UpdateCallbackMap pending_update_checks_;
+};
+
+#endif // CHROME_BROWSER_EXTENSIONS_CHROME_RUNTIME_API_DELEGATE_H_

Powered by Google App Engine
This is Rietveld 408576698