| 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/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/memory/ref_counted.h" | |
| 16 #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 "chrome/common/extensions/api/cookies.h" | 18 #include "chrome/common/extensions/api/cookies.h" |
| 20 #include "content/public/browser/notification_observer.h" | 19 #include "content/public/browser/notification_observer.h" |
| 21 #include "content/public/browser/notification_registrar.h" | 20 #include "content/public/browser/notification_registrar.h" |
| 22 #include "googleurl/src/gurl.h" | 21 #include "googleurl/src/gurl.h" |
| 23 #include "net/cookies/canonical_cookie.h" | 22 #include "net/cookies/canonical_cookie.h" |
| 24 | 23 |
| 25 namespace base { | |
| 26 class DictionaryValue; | |
| 27 } | |
| 28 | |
| 29 namespace net { | 24 namespace net { |
| 30 class URLRequestContextGetter; | 25 class URLRequestContextGetter; |
| 31 } | 26 } |
| 32 | 27 |
| 33 namespace extensions { | 28 namespace extensions { |
| 34 | 29 |
| 35 // Observes CookieMonster notifications and routes them as events to the | 30 // Observes CookieMonster notifications and routes them as events to the |
| 36 // extension system. | 31 // extension system. |
| 37 class ExtensionCookiesEventRouter : public content::NotificationObserver { | 32 class ExtensionCookiesEventRouter : public content::NotificationObserver { |
| 38 public: | 33 public: |
| 39 explicit ExtensionCookiesEventRouter(Profile* profile); | 34 explicit ExtensionCookiesEventRouter(Profile* profile); |
| 40 virtual ~ExtensionCookiesEventRouter(); | 35 virtual ~ExtensionCookiesEventRouter(); |
| 41 | 36 |
| 42 void Init(); | 37 void Init(); |
| 43 | 38 |
| 44 private: | 39 private: |
| 45 // content::NotificationObserver implementation. | 40 // content::NotificationObserver implementation. |
| 46 virtual void Observe(int type, | 41 virtual void Observe(int type, |
| 47 const content::NotificationSource& source, | 42 const content::NotificationSource& source, |
| 48 const content::NotificationDetails& details) OVERRIDE; | 43 const content::NotificationDetails& details) OVERRIDE; |
| 49 | 44 |
| 50 // Handler for the COOKIE_CHANGED event. The method takes the details of such | 45 // 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. | 46 // an event and constructs a suitable JSON formatted extension event from it. |
| 52 void CookieChanged(Profile* profile, | 47 void CookieChanged(Profile* profile, ChromeCookieDetails* details); |
| 53 ChromeCookieDetails* details); | |
| 54 | 48 |
| 55 // This method dispatches events to the extension message service. | 49 // This method dispatches events to the extension message service. |
| 56 void DispatchEvent(Profile* context, | 50 void DispatchEvent(Profile* context, |
| 57 const char* event_name, | 51 const std::string& event_name, |
| 58 scoped_ptr<base::ListValue> event_args, | 52 scoped_ptr<base::ListValue> event_args, |
| 59 GURL& cookie_domain); | 53 GURL& cookie_domain); |
| 60 | 54 |
| 61 // Used for tracking registrations to CookieMonster notifications. | 55 // Used for tracking registrations to CookieMonster notifications. |
| 62 content::NotificationRegistrar registrar_; | 56 content::NotificationRegistrar registrar_; |
| 63 | 57 |
| 64 Profile* profile_; | 58 Profile* profile_; |
| 65 | 59 |
| 66 DISALLOW_COPY_AND_ASSIGN(ExtensionCookiesEventRouter); | 60 DISALLOW_COPY_AND_ASSIGN(ExtensionCookiesEventRouter); |
| 67 }; | 61 }; |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 | 188 |
| 195 // ExtensionFunction: | 189 // ExtensionFunction: |
| 196 // GetAllCookieStoresFunction is sync. | 190 // GetAllCookieStoresFunction is sync. |
| 197 virtual void Run() OVERRIDE; | 191 virtual void Run() OVERRIDE; |
| 198 virtual bool RunImpl() OVERRIDE; | 192 virtual bool RunImpl() OVERRIDE; |
| 199 }; | 193 }; |
| 200 | 194 |
| 201 } // namespace extensions | 195 } // namespace extensions |
| 202 | 196 |
| 203 #endif // CHROME_BROWSER_EXTENSIONS_API_COOKIES_COOKIES_API_H_ | 197 #endif // CHROME_BROWSER_EXTENSIONS_API_COOKIES_COOKIES_API_H_ |
| OLD | NEW |