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

Side by Side Diff: chrome/browser/extensions/api/cookies/cookies_api.h

Issue 10915153: Cleanup: Simplify some extension API code. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 3 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 | Annotate | Revision Log
OLDNEW
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(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(const std::string& event_name,
57 const char* event_name,
58 scoped_ptr<base::ListValue> event_args, 51 scoped_ptr<base::ListValue> event_args,
59 GURL& cookie_domain); 52 GURL& cookie_domain);
60 53
61 // Used for tracking registrations to CookieMonster notifications. 54 // Used for tracking registrations to CookieMonster notifications.
62 content::NotificationRegistrar registrar_; 55 content::NotificationRegistrar registrar_;
63 56
64 Profile* profile_; 57 Profile* profile_;
65 58
66 DISALLOW_COPY_AND_ASSIGN(ExtensionCookiesEventRouter); 59 DISALLOW_COPY_AND_ASSIGN(ExtensionCookiesEventRouter);
67 }; 60 };
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 187
195 // ExtensionFunction: 188 // ExtensionFunction:
196 // GetAllCookieStoresFunction is sync. 189 // GetAllCookieStoresFunction is sync.
197 virtual void Run() OVERRIDE; 190 virtual void Run() OVERRIDE;
198 virtual bool RunImpl() OVERRIDE; 191 virtual bool RunImpl() OVERRIDE;
199 }; 192 };
200 193
201 } // namespace extensions 194 } // namespace extensions
202 195
203 #endif // CHROME_BROWSER_EXTENSIONS_API_COOKIES_COOKIES_API_H_ 196 #endif // CHROME_BROWSER_EXTENSIONS_API_COOKIES_COOKIES_API_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698