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 #ifndef NET_COOKIES_COOKIE_STORE_TEST_HELPERS_H_ | 5 #ifndef NET_COOKIES_COOKIE_STORE_TEST_HELPERS_H_ |
6 #define NET_COOKIES_COOKIE_STORE_TEST_HELPERS_H_ | 6 #define NET_COOKIES_COOKIE_STORE_TEST_HELPERS_H_ |
7 | 7 |
8 #include "net/cookies/cookie_monster.h" | 8 #include "net/cookies/cookie_monster.h" |
9 | 9 |
10 #include <string> | 10 #include <string> |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 | 63 |
64 void DeleteSessionCookiesAsync(const DeleteCallback&) override; | 64 void DeleteSessionCookiesAsync(const DeleteCallback&) override; |
65 | 65 |
66 CookieMonster* GetCookieMonster() override; | 66 CookieMonster* GetCookieMonster() override; |
67 | 67 |
68 scoped_ptr<CookieStore::CookieChangedSubscription> | 68 scoped_ptr<CookieStore::CookieChangedSubscription> |
69 AddCallbackForCookie(const GURL& url, const std::string& name, | 69 AddCallbackForCookie(const GURL& url, const std::string& name, |
70 const CookieChangedCallback& callback) override; | 70 const CookieChangedCallback& callback) override; |
71 | 71 |
72 private: | 72 private: |
73 | |
74 // Be called immediately from CookieMonster. | 73 // Be called immediately from CookieMonster. |
75 | 74 |
76 void SetCookiesInternalCallback(bool result); | 75 void SetCookiesInternalCallback(bool result); |
77 | 76 |
78 void GetCookiesWithOptionsInternalCallback(const std::string& cookie); | 77 void GetCookiesWithOptionsInternalCallback(const std::string& cookie); |
79 | 78 |
80 // Invoke the original callbacks. | 79 // Invoke the original callbacks. |
81 | 80 |
82 void InvokeSetCookiesCallback( | 81 void InvokeSetCookiesCallback( |
83 const CookieMonster::SetCookiesCallback& callback); | 82 const CookieMonster::SetCookiesCallback& callback); |
84 | 83 |
85 void InvokeGetCookieStringCallback( | 84 void InvokeGetCookieStringCallback( |
86 const CookieMonster::GetCookiesCallback& callback); | 85 const CookieMonster::GetCookiesCallback& callback); |
87 | 86 |
88 friend class base::RefCountedThreadSafe<DelayedCookieMonster>; | 87 friend class base::RefCountedThreadSafe<DelayedCookieMonster>; |
89 ~DelayedCookieMonster() override; | 88 ~DelayedCookieMonster() override; |
90 | 89 |
91 scoped_refptr<CookieMonster> cookie_monster_; | 90 scoped_refptr<CookieMonster> cookie_monster_; |
92 | 91 |
93 bool did_run_; | 92 bool did_run_; |
94 bool result_; | 93 bool result_; |
95 std::string cookie_; | 94 std::string cookie_; |
96 std::string cookie_line_; | 95 std::string cookie_line_; |
97 }; | 96 }; |
98 | 97 |
| 98 class CookieURLHelper { |
| 99 public: |
| 100 explicit CookieURLHelper(const std::string& url_string); |
| 101 |
| 102 const std::string& domain() const { return domain_and_registry_; } |
| 103 std::string host() const { return url_.host(); } |
| 104 const GURL& url() const { return url_; } |
| 105 const GURL AppendPath(const std::string& path) const; |
| 106 |
| 107 // Return a new string with the following substitutions: |
| 108 // 1. "%R" -> Domain registry (i.e. "com") |
| 109 // 2. "%D" -> Domain + registry (i.e. "google.com") |
| 110 std::string Format(const std::string& format_string) const; |
| 111 |
| 112 private: |
| 113 const GURL url_; |
| 114 const std::string registry_; |
| 115 const std::string domain_and_registry_; |
| 116 }; |
| 117 |
99 } // namespace net | 118 } // namespace net |
100 | 119 |
101 #endif // NET_COOKIES_COOKIE_STORE_TEST_HELPERS_H_ | 120 #endif // NET_COOKIES_COOKIE_STORE_TEST_HELPERS_H_ |
OLD | NEW |