OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CONTENT_BROWSER_ANDROID_COOKIE_GETTER_IMPL_H_ | |
6 #define CONTENT_BROWSER_ANDROID_COOKIE_GETTER_IMPL_H_ | |
7 | |
8 #include <string> | |
9 | |
10 #include "base/memory/ref_counted.h" | |
11 #include "base/memory/weak_ptr.h" | |
12 #include "base/synchronization/waitable_event.h" | |
13 #include "media/base/android/cookie_getter.h" | |
14 #include "net/cookies/canonical_cookie.h" | |
15 | |
16 namespace net { | |
17 class URLRequestContextGetter; | |
18 } | |
19 | |
20 namespace content { | |
21 | |
22 class BrowserContext; | |
23 class ResourceContext; | |
24 | |
25 // This class implements media::CookieGetter to retrive cookies | |
26 // asynchronously on the UI thread. | |
27 class CookieGetterImpl : public media::CookieGetter { | |
28 public: | |
29 // Construct a CookieGetterImpl by passing the BrowserContext reference | |
30 // and renderer_id to retrieve the CookieStore later. | |
31 CookieGetterImpl( | |
32 BrowserContext* browser_context, int renderer_id, int routing_id); | |
33 virtual ~CookieGetterImpl(); | |
34 | |
35 // media::CookieGetter implementation. | |
36 // Must be called on the UI thread. | |
37 virtual void GetCookies(const std::string& url, | |
38 const std::string& first_party_for_cookies, | |
39 const GetCookieCB& callback) OVERRIDE; | |
40 | |
41 private: | |
42 // Called when GetCookies() finishes. | |
43 void GetCookiesCallback( | |
44 const GetCookieCB& callback, const std::string& cookies); | |
45 | |
46 // BrowserContext to retrieve URLRequestContext and ResourceContext. | |
47 BrowserContext* browser_context_; | |
48 | |
49 // Used to post tasks. | |
50 base::WeakPtrFactory<CookieGetterImpl> weak_this_; | |
51 | |
52 // Render process id, used to check whether the process can access cookies. | |
53 int renderer_id_; | |
54 | |
55 // Routing id for the render view, used to check tab specific cookie policy. | |
56 int routing_id_; | |
57 | |
58 DISALLOW_COPY_AND_ASSIGN(CookieGetterImpl); | |
59 }; | |
60 | |
61 } // namespace content | |
62 | |
63 #endif // CONTENT_BROWSER_ANDROID_COOKIE_GETTER_IMPL_H_ | |
OLD | NEW |