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

Side by Side Diff: chrome/browser/extensions/api/runtime/chrome_runtime_api_delegate.h

Issue 264743014: Move chrome.runtime to //extensions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: make clang, cros happy Created 6 years, 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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_API_RUNTIME_CHROME_RUNTIME_API_DELEGATE_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_RUNTIME_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/api/runtime/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,
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 AddUpdateObserver(extensions::UpdateObserver* observer) OVERRIDE;
42 virtual void RemoveUpdateObserver(
43 extensions::UpdateObserver* observer) OVERRIDE;
44 virtual base::Version GetPreviousExtensionVersion(
45 const extensions::Extension* extension) OVERRIDE;
46 virtual void ReloadExtension(const std::string& extension_id) OVERRIDE;
47 virtual bool CheckForUpdates(const std::string& extension_id,
48 const UpdateCheckCallback& callback) OVERRIDE;
49 virtual void OpenURL(const GURL& uninstall_url) OVERRIDE;
50 virtual bool GetPlatformInfo(
51 extensions::core_api::runtime::GetPlatformInfo::Results::PlatformInfo*
52 info) OVERRIDE;
53 virtual bool RestartDevice(std::string* error_message) OVERRIDE;
54
55 // content::NotificationObserver implementation.
56 virtual void Observe(int type,
57 const content::NotificationSource& source,
58 const content::NotificationDetails& details) OVERRIDE;
59
60 void UpdateCheckComplete(const std::string& extension_id);
61 void CallUpdateCallbacks(const std::string& extension_id,
62 const UpdateCheckResult& result);
63
64 content::BrowserContext* browser_context_;
65
66 content::NotificationRegistrar registrar_;
67
68 // Whether the API registered with the ExtensionService to receive
69 // update notifications.
70 bool registered_for_updates_;
71
72 // Map to prevent extensions from getting stuck in reload loops. Maps
73 // extension id to the last time it was reloaded and the number of times
74 // it was reloaded with not enough time in between reloads.
75 std::map<std::string, std::pair<base::TimeTicks, int> > last_reload_time_;
76
77 // Pending update checks.
78 typedef std::vector<UpdateCheckCallback> UpdateCallbackList;
79 typedef std::map<std::string, UpdateCallbackList> UpdateCallbackMap;
80 UpdateCallbackMap pending_update_checks_;
81 };
82
83 #endif // CHROME_BROWSER_EXTENSIONS_API_RUNTIME_CHROME_RUNTIME_API_DELEGATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698