| 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 // Defines the Chrome Extensions Cookies API functions for accessing internet | 5 // Defines the Chrome Extensions Cookies API functions for accessing internet |
| 6 // cookies, as specified in the extension API JSON. | 6 // cookies, as specified in the extension API JSON. |
| 7 | 7 |
| 8 #ifndef CHROME_BROWSER_EXTENSIONS_API_COOKIES_COOKIES_API_H_ | 8 #ifndef CHROME_BROWSER_EXTENSIONS_API_COOKIES_COOKIES_API_H_ |
| 9 #define CHROME_BROWSER_EXTENSIONS_API_COOKIES_COOKIES_API_H_ | 9 #define CHROME_BROWSER_EXTENSIONS_API_COOKIES_COOKIES_API_H_ |
| 10 | 10 |
| 11 #include <string> | 11 #include <string> |
| 12 | 12 |
| 13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
| 14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
| 16 #include "chrome/browser/extensions/api/profile_keyed_api_factory.h" |
| 16 #include "chrome/browser/extensions/event_router.h" | 17 #include "chrome/browser/extensions/event_router.h" |
| 17 #include "chrome/browser/extensions/extension_function.h" | 18 #include "chrome/browser/extensions/extension_function.h" |
| 18 #include "chrome/browser/net/chrome_cookie_notification_details.h" | 19 #include "chrome/browser/net/chrome_cookie_notification_details.h" |
| 19 #include "chrome/browser/profiles/profile_keyed_service.h" | |
| 20 #include "chrome/common/extensions/api/cookies.h" | 20 #include "chrome/common/extensions/api/cookies.h" |
| 21 #include "content/public/browser/notification_observer.h" | 21 #include "content/public/browser/notification_observer.h" |
| 22 #include "content/public/browser/notification_registrar.h" | 22 #include "content/public/browser/notification_registrar.h" |
| 23 #include "googleurl/src/gurl.h" | 23 #include "googleurl/src/gurl.h" |
| 24 #include "net/cookies/canonical_cookie.h" | 24 #include "net/cookies/canonical_cookie.h" |
| 25 | 25 |
| 26 namespace net { | 26 namespace net { |
| 27 class URLRequestContextGetter; | 27 class URLRequestContextGetter; |
| 28 } | 28 } |
| 29 | 29 |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 | 185 |
| 186 protected: | 186 protected: |
| 187 virtual ~GetAllCookieStoresFunction() {} | 187 virtual ~GetAllCookieStoresFunction() {} |
| 188 | 188 |
| 189 // ExtensionFunction: | 189 // ExtensionFunction: |
| 190 // GetAllCookieStoresFunction is sync. | 190 // GetAllCookieStoresFunction is sync. |
| 191 virtual void Run() OVERRIDE; | 191 virtual void Run() OVERRIDE; |
| 192 virtual bool RunImpl() OVERRIDE; | 192 virtual bool RunImpl() OVERRIDE; |
| 193 }; | 193 }; |
| 194 | 194 |
| 195 class CookiesAPI : public ProfileKeyedService, | 195 class CookiesAPI : public ProfileKeyedAPI, |
| 196 public extensions::EventRouter::Observer { | 196 public extensions::EventRouter::Observer { |
| 197 public: | 197 public: |
| 198 explicit CookiesAPI(Profile* profile); | 198 explicit CookiesAPI(Profile* profile); |
| 199 virtual ~CookiesAPI(); | 199 virtual ~CookiesAPI(); |
| 200 | 200 |
| 201 // ProfileKeyedService implementation. | 201 // ProfileKeyedService implementation. |
| 202 virtual void Shutdown() OVERRIDE; | 202 virtual void Shutdown() OVERRIDE; |
| 203 | 203 |
| 204 // EventRouter::Observer implementation. | 204 // EventRouter::Observer implementation. |
| 205 virtual void OnListenerAdded(const extensions::EventListenerInfo& details) | 205 virtual void OnListenerAdded(const extensions::EventListenerInfo& details) |
| 206 OVERRIDE; | 206 OVERRIDE; |
| 207 | 207 |
| 208 private: | 208 private: |
| 209 friend class ProfileKeyedAPIFactory<CookiesAPI>; |
| 210 |
| 209 Profile* profile_; | 211 Profile* profile_; |
| 210 | 212 |
| 213 // ProfileKeyedAPI implementation. |
| 214 static const char* service_name() { |
| 215 return "CookiesAPI"; |
| 216 } |
| 217 static const bool kServiceIsNULLWhileTesting = true; |
| 218 |
| 211 // Created lazily upon OnListenerAdded. | 219 // Created lazily upon OnListenerAdded. |
| 212 scoped_ptr<CookiesEventRouter> cookies_event_router_; | 220 scoped_ptr<CookiesEventRouter> cookies_event_router_; |
| 221 |
| 222 DISALLOW_COPY_AND_ASSIGN(CookiesAPI); |
| 213 }; | 223 }; |
| 214 | 224 |
| 225 template <> |
| 226 ProfileKeyedAPIFactory<CookiesAPI>* |
| 227 ProfileKeyedAPIFactory<CookiesAPI>::GetInstance(); |
| 228 |
| 215 } // namespace extensions | 229 } // namespace extensions |
| 216 | 230 |
| 217 #endif // CHROME_BROWSER_EXTENSIONS_API_COOKIES_COOKIES_API_H_ | 231 #endif // CHROME_BROWSER_EXTENSIONS_API_COOKIES_COOKIES_API_H_ |
| OLD | NEW |