| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_HISTORY_HISTORY_API_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_HISTORY_HISTORY_API_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_API_HISTORY_HISTORY_API_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_HISTORY_HISTORY_API_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 // extension system. | 28 // extension system. |
| 29 class HistoryEventRouter : public content::NotificationObserver { | 29 class HistoryEventRouter : public content::NotificationObserver { |
| 30 public: | 30 public: |
| 31 explicit HistoryEventRouter(Profile* profile); | 31 explicit HistoryEventRouter(Profile* profile); |
| 32 virtual ~HistoryEventRouter(); | 32 virtual ~HistoryEventRouter(); |
| 33 | 33 |
| 34 private: | 34 private: |
| 35 // content::NotificationObserver::Observe. | 35 // content::NotificationObserver::Observe. |
| 36 virtual void Observe(int type, | 36 virtual void Observe(int type, |
| 37 const content::NotificationSource& source, | 37 const content::NotificationSource& source, |
| 38 const content::NotificationDetails& details) OVERRIDE; | 38 const content::NotificationDetails& details) override; |
| 39 | 39 |
| 40 void HistoryUrlVisited(Profile* profile, | 40 void HistoryUrlVisited(Profile* profile, |
| 41 const history::URLVisitedDetails* details); | 41 const history::URLVisitedDetails* details); |
| 42 | 42 |
| 43 void HistoryUrlsRemoved(Profile* profile, | 43 void HistoryUrlsRemoved(Profile* profile, |
| 44 const history::URLsDeletedDetails* details); | 44 const history::URLsDeletedDetails* details); |
| 45 | 45 |
| 46 void DispatchEvent(Profile* profile, | 46 void DispatchEvent(Profile* profile, |
| 47 const std::string& event_name, | 47 const std::string& event_name, |
| 48 scoped_ptr<base::ListValue> event_args); | 48 scoped_ptr<base::ListValue> event_args); |
| 49 | 49 |
| 50 // Used for tracking registrations to history service notifications. | 50 // Used for tracking registrations to history service notifications. |
| 51 content::NotificationRegistrar registrar_; | 51 content::NotificationRegistrar registrar_; |
| 52 | 52 |
| 53 DISALLOW_COPY_AND_ASSIGN(HistoryEventRouter); | 53 DISALLOW_COPY_AND_ASSIGN(HistoryEventRouter); |
| 54 }; | 54 }; |
| 55 | 55 |
| 56 class HistoryAPI : public BrowserContextKeyedAPI, public EventRouter::Observer { | 56 class HistoryAPI : public BrowserContextKeyedAPI, public EventRouter::Observer { |
| 57 public: | 57 public: |
| 58 explicit HistoryAPI(content::BrowserContext* context); | 58 explicit HistoryAPI(content::BrowserContext* context); |
| 59 virtual ~HistoryAPI(); | 59 virtual ~HistoryAPI(); |
| 60 | 60 |
| 61 // KeyedService implementation. | 61 // KeyedService implementation. |
| 62 virtual void Shutdown() OVERRIDE; | 62 virtual void Shutdown() override; |
| 63 | 63 |
| 64 // BrowserContextKeyedAPI implementation. | 64 // BrowserContextKeyedAPI implementation. |
| 65 static BrowserContextKeyedAPIFactory<HistoryAPI>* GetFactoryInstance(); | 65 static BrowserContextKeyedAPIFactory<HistoryAPI>* GetFactoryInstance(); |
| 66 | 66 |
| 67 // EventRouter::Observer implementation. | 67 // EventRouter::Observer implementation. |
| 68 virtual void OnListenerAdded(const EventListenerInfo& details) OVERRIDE; | 68 virtual void OnListenerAdded(const EventListenerInfo& details) override; |
| 69 | 69 |
| 70 private: | 70 private: |
| 71 friend class BrowserContextKeyedAPIFactory<HistoryAPI>; | 71 friend class BrowserContextKeyedAPIFactory<HistoryAPI>; |
| 72 | 72 |
| 73 content::BrowserContext* browser_context_; | 73 content::BrowserContext* browser_context_; |
| 74 | 74 |
| 75 // BrowserContextKeyedAPI implementation. | 75 // BrowserContextKeyedAPI implementation. |
| 76 static const char* service_name() { | 76 static const char* service_name() { |
| 77 return "HistoryAPI"; | 77 return "HistoryAPI"; |
| 78 } | 78 } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 98 // Base class for history funciton APIs which require async interaction with | 98 // Base class for history funciton APIs which require async interaction with |
| 99 // chrome services and the extension thread. | 99 // chrome services and the extension thread. |
| 100 class HistoryFunctionWithCallback : public HistoryFunction { | 100 class HistoryFunctionWithCallback : public HistoryFunction { |
| 101 public: | 101 public: |
| 102 HistoryFunctionWithCallback(); | 102 HistoryFunctionWithCallback(); |
| 103 | 103 |
| 104 protected: | 104 protected: |
| 105 virtual ~HistoryFunctionWithCallback(); | 105 virtual ~HistoryFunctionWithCallback(); |
| 106 | 106 |
| 107 // ExtensionFunction: | 107 // ExtensionFunction: |
| 108 virtual bool RunAsync() OVERRIDE; | 108 virtual bool RunAsync() override; |
| 109 | 109 |
| 110 // Return true if the async call was completed, false otherwise. | 110 // Return true if the async call was completed, false otherwise. |
| 111 virtual bool RunAsyncImpl() = 0; | 111 virtual bool RunAsyncImpl() = 0; |
| 112 | 112 |
| 113 // Call this method to report the results of the async method to the caller. | 113 // Call this method to report the results of the async method to the caller. |
| 114 // This method calls Release(). | 114 // This method calls Release(). |
| 115 virtual void SendAsyncResponse(); | 115 virtual void SendAsyncResponse(); |
| 116 | 116 |
| 117 // The task tracker for the HistoryService callbacks. | 117 // The task tracker for the HistoryService callbacks. |
| 118 base::CancelableTaskTracker task_tracker_; | 118 base::CancelableTaskTracker task_tracker_; |
| 119 | 119 |
| 120 private: | 120 private: |
| 121 // The actual call to SendResponse. This is required since the semantics for | 121 // The actual call to SendResponse. This is required since the semantics for |
| 122 // CancelableRequestConsumerT require it to be accessed after the call. | 122 // CancelableRequestConsumerT require it to be accessed after the call. |
| 123 void SendResponseToCallback(); | 123 void SendResponseToCallback(); |
| 124 }; | 124 }; |
| 125 | 125 |
| 126 class HistoryGetVisitsFunction : public HistoryFunctionWithCallback { | 126 class HistoryGetVisitsFunction : public HistoryFunctionWithCallback { |
| 127 public: | 127 public: |
| 128 DECLARE_EXTENSION_FUNCTION("history.getVisits", HISTORY_GETVISITS) | 128 DECLARE_EXTENSION_FUNCTION("history.getVisits", HISTORY_GETVISITS) |
| 129 | 129 |
| 130 protected: | 130 protected: |
| 131 virtual ~HistoryGetVisitsFunction() {} | 131 virtual ~HistoryGetVisitsFunction() {} |
| 132 | 132 |
| 133 // HistoryFunctionWithCallback: | 133 // HistoryFunctionWithCallback: |
| 134 virtual bool RunAsyncImpl() OVERRIDE; | 134 virtual bool RunAsyncImpl() override; |
| 135 | 135 |
| 136 // Callback for the history function to provide results. | 136 // Callback for the history function to provide results. |
| 137 void QueryComplete(bool success, | 137 void QueryComplete(bool success, |
| 138 const history::URLRow& url_row, | 138 const history::URLRow& url_row, |
| 139 const history::VisitVector& visits); | 139 const history::VisitVector& visits); |
| 140 }; | 140 }; |
| 141 | 141 |
| 142 class HistorySearchFunction : public HistoryFunctionWithCallback { | 142 class HistorySearchFunction : public HistoryFunctionWithCallback { |
| 143 public: | 143 public: |
| 144 DECLARE_EXTENSION_FUNCTION("history.search", HISTORY_SEARCH) | 144 DECLARE_EXTENSION_FUNCTION("history.search", HISTORY_SEARCH) |
| 145 | 145 |
| 146 protected: | 146 protected: |
| 147 virtual ~HistorySearchFunction() {} | 147 virtual ~HistorySearchFunction() {} |
| 148 | 148 |
| 149 // HistoryFunctionWithCallback: | 149 // HistoryFunctionWithCallback: |
| 150 virtual bool RunAsyncImpl() OVERRIDE; | 150 virtual bool RunAsyncImpl() override; |
| 151 | 151 |
| 152 // Callback for the history function to provide results. | 152 // Callback for the history function to provide results. |
| 153 void SearchComplete(history::QueryResults* results); | 153 void SearchComplete(history::QueryResults* results); |
| 154 }; | 154 }; |
| 155 | 155 |
| 156 class HistoryAddUrlFunction : public HistoryFunction { | 156 class HistoryAddUrlFunction : public HistoryFunction { |
| 157 public: | 157 public: |
| 158 DECLARE_EXTENSION_FUNCTION("history.addUrl", HISTORY_ADDURL) | 158 DECLARE_EXTENSION_FUNCTION("history.addUrl", HISTORY_ADDURL) |
| 159 | 159 |
| 160 protected: | 160 protected: |
| 161 virtual ~HistoryAddUrlFunction() {} | 161 virtual ~HistoryAddUrlFunction() {} |
| 162 | 162 |
| 163 // HistoryFunctionWithCallback: | 163 // HistoryFunctionWithCallback: |
| 164 virtual bool RunAsync() OVERRIDE; | 164 virtual bool RunAsync() override; |
| 165 }; | 165 }; |
| 166 | 166 |
| 167 class HistoryDeleteAllFunction : public HistoryFunctionWithCallback { | 167 class HistoryDeleteAllFunction : public HistoryFunctionWithCallback { |
| 168 public: | 168 public: |
| 169 DECLARE_EXTENSION_FUNCTION("history.deleteAll", HISTORY_DELETEALL) | 169 DECLARE_EXTENSION_FUNCTION("history.deleteAll", HISTORY_DELETEALL) |
| 170 | 170 |
| 171 protected: | 171 protected: |
| 172 virtual ~HistoryDeleteAllFunction() {} | 172 virtual ~HistoryDeleteAllFunction() {} |
| 173 | 173 |
| 174 // HistoryFunctionWithCallback: | 174 // HistoryFunctionWithCallback: |
| 175 virtual bool RunAsyncImpl() OVERRIDE; | 175 virtual bool RunAsyncImpl() override; |
| 176 | 176 |
| 177 // Callback for the history service to acknowledge deletion. | 177 // Callback for the history service to acknowledge deletion. |
| 178 void DeleteComplete(); | 178 void DeleteComplete(); |
| 179 }; | 179 }; |
| 180 | 180 |
| 181 | 181 |
| 182 class HistoryDeleteUrlFunction : public HistoryFunction { | 182 class HistoryDeleteUrlFunction : public HistoryFunction { |
| 183 public: | 183 public: |
| 184 DECLARE_EXTENSION_FUNCTION("history.deleteUrl", HISTORY_DELETEURL) | 184 DECLARE_EXTENSION_FUNCTION("history.deleteUrl", HISTORY_DELETEURL) |
| 185 | 185 |
| 186 protected: | 186 protected: |
| 187 virtual ~HistoryDeleteUrlFunction() {} | 187 virtual ~HistoryDeleteUrlFunction() {} |
| 188 | 188 |
| 189 // HistoryFunctionWithCallback: | 189 // HistoryFunctionWithCallback: |
| 190 virtual bool RunAsync() OVERRIDE; | 190 virtual bool RunAsync() override; |
| 191 }; | 191 }; |
| 192 | 192 |
| 193 class HistoryDeleteRangeFunction : public HistoryFunctionWithCallback { | 193 class HistoryDeleteRangeFunction : public HistoryFunctionWithCallback { |
| 194 public: | 194 public: |
| 195 DECLARE_EXTENSION_FUNCTION("history.deleteRange", HISTORY_DELETERANGE) | 195 DECLARE_EXTENSION_FUNCTION("history.deleteRange", HISTORY_DELETERANGE) |
| 196 | 196 |
| 197 protected: | 197 protected: |
| 198 virtual ~HistoryDeleteRangeFunction() {} | 198 virtual ~HistoryDeleteRangeFunction() {} |
| 199 | 199 |
| 200 // HistoryFunctionWithCallback: | 200 // HistoryFunctionWithCallback: |
| 201 virtual bool RunAsyncImpl() OVERRIDE; | 201 virtual bool RunAsyncImpl() override; |
| 202 | 202 |
| 203 // Callback for the history service to acknowledge deletion. | 203 // Callback for the history service to acknowledge deletion. |
| 204 void DeleteComplete(); | 204 void DeleteComplete(); |
| 205 }; | 205 }; |
| 206 | 206 |
| 207 } // namespace extensions | 207 } // namespace extensions |
| 208 | 208 |
| 209 #endif // CHROME_BROWSER_EXTENSIONS_API_HISTORY_HISTORY_API_H_ | 209 #endif // CHROME_BROWSER_EXTENSIONS_API_HISTORY_HISTORY_API_H_ |
| OLD | NEW |