| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 chrome/common/extensions/api/extension_api.json. | 6 // cookies, as specified in chrome/common/extensions/api/extension_api.json. |
| 7 | 7 |
| 8 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_COOKIES_API_H_ | 8 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_COOKIES_API_H_ |
| 9 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_COOKIES_API_H_ | 9 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_COOKIES_API_H_ |
| 10 #pragma once | 10 #pragma once |
| 11 | 11 |
| 12 #include <string> | 12 #include <string> |
| 13 | 13 |
| 14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 15 #include "base/memory/singleton.h" | |
| 16 #include "base/time.h" | 15 #include "base/time.h" |
| 17 #include "chrome/browser/extensions/extension_function.h" | 16 #include "chrome/browser/extensions/extension_function.h" |
| 18 #include "chrome/browser/net/chrome_cookie_notification_details.h" | 17 #include "chrome/browser/net/chrome_cookie_notification_details.h" |
| 19 #include "content/common/notification_observer.h" | 18 #include "content/common/notification_observer.h" |
| 20 #include "content/common/notification_registrar.h" | 19 #include "content/common/notification_registrar.h" |
| 21 #include "googleurl/src/gurl.h" | 20 #include "googleurl/src/gurl.h" |
| 22 #include "net/base/cookie_monster.h" | 21 #include "net/base/cookie_monster.h" |
| 23 | 22 |
| 24 class DictionaryValue; | 23 class DictionaryValue; |
| 25 | 24 |
| 26 namespace net { | 25 namespace net { |
| 27 class URLRequestContextGetter; | 26 class URLRequestContextGetter; |
| 28 } | 27 } |
| 29 | 28 |
| 30 // Observes CookieMonster notifications and routes them as events to the | 29 // Observes CookieMonster notifications and routes them as events to the |
| 31 // extension system. | 30 // extension system. |
| 32 class ExtensionCookiesEventRouter : public NotificationObserver { | 31 class ExtensionCookiesEventRouter : public NotificationObserver { |
| 33 public: | 32 public: |
| 34 // Single instance of the event router. | 33 explicit ExtensionCookiesEventRouter(); |
| 35 static ExtensionCookiesEventRouter* GetInstance(); | 34 virtual ~ExtensionCookiesEventRouter(); |
| 36 | 35 |
| 37 void Init(); | 36 void ObserveProfile(Profile* profile); |
| 38 | 37 |
| 39 private: | 38 private: |
| 40 friend struct DefaultSingletonTraits<ExtensionCookiesEventRouter>; | |
| 41 | |
| 42 ExtensionCookiesEventRouter() {} | |
| 43 virtual ~ExtensionCookiesEventRouter() {} | |
| 44 | |
| 45 // NotificationObserver implementation. | 39 // NotificationObserver implementation. |
| 46 virtual void Observe(NotificationType type, | 40 virtual void Observe(NotificationType type, |
| 47 const NotificationSource& source, | 41 const NotificationSource& source, |
| 48 const NotificationDetails& details); | 42 const NotificationDetails& details); |
| 49 | 43 |
| 50 // Handler for the COOKIE_CHANGED event. The method takes the details of such | 44 // Handler for the COOKIE_CHANGED event. The method takes the details of such |
| 51 // an event and constructs a suitable JSON formatted extension event from it. | 45 // an event and constructs a suitable JSON formatted extension event from it. |
| 52 void CookieChanged(Profile* profile, | 46 void CookieChanged(Profile* profile, |
| 53 ChromeCookieDetails* details); | 47 ChromeCookieDetails* details); |
| 54 | 48 |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 // Implements the cookies.getAllCookieStores() extension function. | 170 // Implements the cookies.getAllCookieStores() extension function. |
| 177 class GetAllCookieStoresFunction : public CookiesFunction { | 171 class GetAllCookieStoresFunction : public CookiesFunction { |
| 178 public: | 172 public: |
| 179 virtual bool RunImpl(); | 173 virtual bool RunImpl(); |
| 180 // GetAllCookieStoresFunction is sync. | 174 // GetAllCookieStoresFunction is sync. |
| 181 virtual void Run(); | 175 virtual void Run(); |
| 182 DECLARE_EXTENSION_FUNCTION_NAME("cookies.getAllCookieStores") | 176 DECLARE_EXTENSION_FUNCTION_NAME("cookies.getAllCookieStores") |
| 183 }; | 177 }; |
| 184 | 178 |
| 185 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_COOKIES_API_H_ | 179 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_COOKIES_API_H_ |
| OLD | NEW |