Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_EXTENSIONS_CHROME_RUNTIME_API_DELEGATE_H_ | |
| 6 #define CHROME_BROWSER_EXTENSIONS_CHROME_RUNTIME_API_DELEGATE_H_ | |
| 7 | |
| 8 #include <map> | |
| 9 #include <vector> | |
| 10 | |
| 11 #include "content/public/browser/notification_observer.h" | |
| 12 #include "content/public/browser/notification_registrar.h" | |
| 13 #include "extensions/browser/api/runtime/runtime_api.h" | |
| 14 #include "extensions/browser/runtime_api_delegate.h" | |
| 15 | |
| 16 namespace base { | |
| 17 class TimeTicks; | |
| 18 } | |
| 19 | |
| 20 namespace content { | |
| 21 class BrowserContext; | |
| 22 class NotificationDetails; | |
| 23 class NotificationSource; | |
| 24 } | |
| 25 | |
| 26 namespace extensions { | |
| 27 class RuntimeAPI; | |
| 28 class UpdateObserver; | |
| 29 } | |
| 30 | |
| 31 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.
| |
| 32 public content::NotificationObserver { | |
| 33 public: | |
| 34 explicit ChromeRuntimeAPIDelegate(content::BrowserContext* context); | |
| 35 virtual ~ChromeRuntimeAPIDelegate(); | |
| 36 | |
| 37 private: | |
| 38 friend class extensions::RuntimeAPI; | |
| 39 | |
| 40 // extensions::RuntimeAPIDelegate implementation. | |
| 41 virtual void RegisterUpdateObserver( | |
| 42 extensions::UpdateObserver* observer) OVERRIDE; | |
| 43 virtual void UnregisterUpdateObserver( | |
| 44 extensions::UpdateObserver* observer) OVERRIDE; | |
| 45 virtual base::Version GetOldExtensionVersion( | |
| 46 const extensions::Extension* extension) OVERRIDE; | |
| 47 virtual void MaybeReloadExtension(const std::string& extension_id) OVERRIDE; | |
| 48 virtual bool RequestUpdateCheck( | |
| 49 const std::string& extension_id, | |
| 50 const extensions::RuntimeAPI::UpdateCheckCallback& callback) OVERRIDE; | |
| 51 virtual void HandleUninstall(const std::string& extension_id, | |
| 52 const GURL& uninstall_url) OVERRIDE; | |
| 53 virtual bool GetPlatformInfo( | |
| 54 extensions::core_api::runtime::GetPlatformInfo::Results::PlatformInfo* | |
| 55 info) OVERRIDE; | |
| 56 virtual bool RequestRestart(std::string* error_message) OVERRIDE; | |
| 57 | |
| 58 // content::NotificationObserver implementation. | |
| 59 virtual void Observe(int type, | |
| 60 const content::NotificationSource& source, | |
| 61 const content::NotificationDetails& details) OVERRIDE; | |
| 62 | |
| 63 void UpdateCheckComplete(const std::string& extension_id); | |
| 64 void CallUpdateCallbacks( | |
| 65 const std::string& extension_id, | |
| 66 const extensions::RuntimeAPI::UpdateCheckResult& result); | |
| 67 | |
| 68 content::BrowserContext* browser_context_; | |
| 69 | |
| 70 content::NotificationRegistrar registrar_; | |
| 71 | |
| 72 // Whether the API registered with the ExtensionService to receive | |
| 73 // update notifications. | |
| 74 bool registered_for_updates_; | |
| 75 | |
| 76 // Map to prevent extensions from getting stuck in reload loops. Maps | |
| 77 // extension id to the last time it was reloaded and the number of times | |
| 78 // it was reloaded with not enough time in between reloads. | |
| 79 std::map<std::string, std::pair<base::TimeTicks, int> > last_reload_time_; | |
| 80 | |
| 81 // Pending update checks. | |
| 82 typedef std::vector<extensions::RuntimeAPI::UpdateCheckCallback> | |
| 83 UpdateCallbackList; | |
| 84 typedef std::map<std::string, UpdateCallbackList> UpdateCallbackMap; | |
| 85 UpdateCallbackMap pending_update_checks_; | |
| 86 }; | |
| 87 | |
| 88 #endif // CHROME_BROWSER_EXTENSIONS_CHROME_RUNTIME_API_DELEGATE_H_ | |
| OLD | NEW |