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

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

Issue 1903713002: Revert of Rate limit programmatic update checks for extensions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/extensions/api/runtime/chrome_runtime_api_delegate.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_EXTENSIONS_API_RUNTIME_CHROME_RUNTIME_API_DELEGATE_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_RUNTIME_CHROME_RUNTIME_API_DELEGATE_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_RUNTIME_CHROME_RUNTIME_API_DELEGATE_H_ 6 #define CHROME_BROWSER_EXTENSIONS_API_RUNTIME_CHROME_RUNTIME_API_DELEGATE_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <vector>
10 #include <utility>
11 10
12 #include "base/macros.h" 11 #include "base/macros.h"
13 #include "base/scoped_observer.h"
14 #include "content/public/browser/notification_observer.h" 12 #include "content/public/browser/notification_observer.h"
15 #include "content/public/browser/notification_registrar.h" 13 #include "content/public/browser/notification_registrar.h"
16 #include "extensions/browser/api/runtime/runtime_api.h" 14 #include "extensions/browser/api/runtime/runtime_api.h"
17 #include "extensions/browser/api/runtime/runtime_api_delegate.h" 15 #include "extensions/browser/api/runtime/runtime_api_delegate.h"
18 #include "extensions/browser/extension_registry_observer.h"
19 16
20 namespace base { 17 namespace base {
21 class TickClock;
22 class TimeTicks; 18 class TimeTicks;
23 } 19 }
24 20
25 namespace content { 21 namespace content {
26 class BrowserContext; 22 class BrowserContext;
27 class NotificationDetails; 23 class NotificationDetails;
28 class NotificationSource; 24 class NotificationSource;
29 } 25 }
30 26
31 namespace extensions { 27 namespace extensions {
32 class ExtensionRegistry;
33 class RuntimeAPI; 28 class RuntimeAPI;
34 class UpdateObserver; 29 class UpdateObserver;
35 } 30 }
36 31
37 class ChromeRuntimeAPIDelegate : public extensions::RuntimeAPIDelegate, 32 class ChromeRuntimeAPIDelegate : public extensions::RuntimeAPIDelegate,
38 public content::NotificationObserver, 33 public content::NotificationObserver {
39 public extensions::ExtensionRegistryObserver {
40 public: 34 public:
41 explicit ChromeRuntimeAPIDelegate(content::BrowserContext* context); 35 explicit ChromeRuntimeAPIDelegate(content::BrowserContext* context);
42 ~ChromeRuntimeAPIDelegate() override; 36 ~ChromeRuntimeAPIDelegate() override;
43 37
44 // Sets a custom TickClock to use in tests.
45 static void set_tick_clock_for_tests(base::TickClock* clock);
46
47 private: 38 private:
48 friend class extensions::RuntimeAPI; 39 friend class extensions::RuntimeAPI;
49 40
50 // extensions::RuntimeAPIDelegate implementation. 41 // extensions::RuntimeAPIDelegate implementation.
51 void AddUpdateObserver(extensions::UpdateObserver* observer) override; 42 void AddUpdateObserver(extensions::UpdateObserver* observer) override;
52 void RemoveUpdateObserver(extensions::UpdateObserver* observer) override; 43 void RemoveUpdateObserver(extensions::UpdateObserver* observer) override;
53 base::Version GetPreviousExtensionVersion( 44 base::Version GetPreviousExtensionVersion(
54 const extensions::Extension* extension) override; 45 const extensions::Extension* extension) override;
55 void ReloadExtension(const std::string& extension_id) override; 46 void ReloadExtension(const std::string& extension_id) override;
56 bool CheckForUpdates(const std::string& extension_id, 47 bool CheckForUpdates(const std::string& extension_id,
57 const UpdateCheckCallback& callback) override; 48 const UpdateCheckCallback& callback) override;
58 void OpenURL(const GURL& uninstall_url) override; 49 void OpenURL(const GURL& uninstall_url) override;
59 bool GetPlatformInfo(extensions::api::runtime::PlatformInfo* info) override; 50 bool GetPlatformInfo(extensions::api::runtime::PlatformInfo* info) override;
60 bool RestartDevice(std::string* error_message) override; 51 bool RestartDevice(std::string* error_message) override;
61 bool OpenOptionsPage(const extensions::Extension* extension) override; 52 bool OpenOptionsPage(const extensions::Extension* extension) override;
62 53
63 // content::NotificationObserver implementation. 54 // content::NotificationObserver implementation.
64 void Observe(int type, 55 void Observe(int type,
65 const content::NotificationSource& source, 56 const content::NotificationSource& source,
66 const content::NotificationDetails& details) override; 57 const content::NotificationDetails& details) override;
67 58
68 // ExtensionRegistryObserver implementation.
69 void OnExtensionInstalled(content::BrowserContext* browser_context,
70 const extensions::Extension* extension,
71 bool is_update) override;
72
73 void UpdateCheckComplete(const std::string& extension_id); 59 void UpdateCheckComplete(const std::string& extension_id);
74 void CallUpdateCallbacks(const std::string& extension_id, 60 void CallUpdateCallbacks(const std::string& extension_id,
75 const UpdateCheckResult& result); 61 const UpdateCheckResult& result);
76 62
77 content::BrowserContext* browser_context_; 63 content::BrowserContext* browser_context_;
78 64
79 content::NotificationRegistrar registrar_; 65 content::NotificationRegistrar registrar_;
80 66
81 // Whether the API registered with the ExtensionService to receive 67 // Whether the API registered with the ExtensionService to receive
82 // update notifications. 68 // update notifications.
83 bool registered_for_updates_; 69 bool registered_for_updates_;
84 70
85 // Map to prevent extensions from getting stuck in reload loops. Maps 71 // Map to prevent extensions from getting stuck in reload loops. Maps
86 // extension id to the last time it was reloaded and the number of times 72 // extension id to the last time it was reloaded and the number of times
87 // it was reloaded with not enough time in between reloads. 73 // it was reloaded with not enough time in between reloads.
88 std::map<std::string, std::pair<base::TimeTicks, int> > last_reload_time_; 74 std::map<std::string, std::pair<base::TimeTicks, int> > last_reload_time_;
89 75
90 // Information about update checks, keyed by extension id. 76 // Pending update checks.
91 struct UpdateCheckInfo; 77 typedef std::vector<UpdateCheckCallback> UpdateCallbackList;
92 std::map<std::string, UpdateCheckInfo> update_check_info_; 78 typedef std::map<std::string, UpdateCallbackList> UpdateCallbackMap;
79 UpdateCallbackMap pending_update_checks_;
93 80
94 ScopedObserver<extensions::ExtensionRegistry, 81 private:
95 extensions::ExtensionRegistryObserver>
96 extension_registry_observer_;
97
98 DISALLOW_COPY_AND_ASSIGN(ChromeRuntimeAPIDelegate); 82 DISALLOW_COPY_AND_ASSIGN(ChromeRuntimeAPIDelegate);
99 }; 83 };
100 84
101 #endif // CHROME_BROWSER_EXTENSIONS_API_RUNTIME_CHROME_RUNTIME_API_DELEGATE_H_ 85 #endif // CHROME_BROWSER_EXTENSIONS_API_RUNTIME_CHROME_RUNTIME_API_DELEGATE_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/api/runtime/chrome_runtime_api_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698