OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 CookieAccountant class, which is responsible for observing | 5 // Defines the CookieAccountant class, which is responsible for observing |
6 // and recording all cookie-related information generated by a particular | 6 // and recording all cookie-related information generated by a particular |
7 // IE browser session. It records and fires cookie change events, it provides | 7 // IE browser session. It records and fires cookie change events, it provides |
8 // access to session and persistent cookies. | 8 // access to session and persistent cookies. |
9 | 9 |
10 #ifndef CEEE_IE_PLUGIN_BHO_COOKIE_ACCOUNTANT_H_ | 10 #ifndef CEEE_IE_PLUGIN_BHO_COOKIE_ACCOUNTANT_H_ |
11 #define CEEE_IE_PLUGIN_BHO_COOKIE_ACCOUNTANT_H_ | 11 #define CEEE_IE_PLUGIN_BHO_COOKIE_ACCOUNTANT_H_ |
12 | 12 |
13 #include <string> | 13 #include <string> |
14 | 14 |
15 #include "app/win/iat_patch_function.h" | 15 #include "app/win/iat_patch_function.h" |
| 16 #include "base/lock.h" |
16 #include "base/singleton.h" | 17 #include "base/singleton.h" |
17 #include "base/time.h" | 18 #include "base/time.h" |
18 #include "ceee/ie/plugin/bho/cookie_events_funnel.h" | 19 #include "ceee/ie/plugin/bho/cookie_events_funnel.h" |
19 #include "net/base/cookie_monster.h" | 20 #include "net/base/cookie_monster.h" |
20 | 21 |
21 // The class that accounts for all cookie-related activity for a single IE | 22 // The class that accounts for all cookie-related activity for a single IE |
22 // browser session context. There should only need to be one of these allocated | 23 // browser session context. There should only need to be one of these allocated |
23 // per process; use ProductionCookieAccountant instead of using this class | 24 // per process; use ProductionCookieAccountant instead of using this class |
24 // directly. | 25 // directly. |
25 class CookieAccountant { | 26 class CookieAccountant { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 virtual void RecordCookie( | 61 virtual void RecordCookie( |
61 const std::string& url, const std::string& cookie_data, | 62 const std::string& url, const std::string& cookie_data, |
62 const base::Time& current_time); | 63 const base::Time& current_time); |
63 | 64 |
64 // Unit test seam. | 65 // Unit test seam. |
65 virtual CookieEventsFunnel& cookie_events_funnel() { | 66 virtual CookieEventsFunnel& cookie_events_funnel() { |
66 return cookie_events_funnel_; | 67 return cookie_events_funnel_; |
67 } | 68 } |
68 | 69 |
69 // Function patches that allow us to intercept scripted cookie changes. | 70 // Function patches that allow us to intercept scripted cookie changes. |
| 71 // Protected by CookieAccountant::lock_. |
70 app::win::IATPatchFunction internet_set_cookie_ex_a_patch_; | 72 app::win::IATPatchFunction internet_set_cookie_ex_a_patch_; |
71 app::win::IATPatchFunction internet_set_cookie_ex_w_patch_; | 73 app::win::IATPatchFunction internet_set_cookie_ex_w_patch_; |
72 | 74 |
| 75 // A lock that protects access to the function patches. |
| 76 Lock lock_; |
| 77 |
73 // Cached singleton instance. Useful for unit testing. | 78 // Cached singleton instance. Useful for unit testing. |
74 static CookieAccountant* singleton_instance_; | 79 static CookieAccountant* singleton_instance_; |
75 | 80 |
76 private: | 81 private: |
77 // Helper functions for extracting cookie information from a scripted cookie | 82 // Helper functions for extracting cookie information from a scripted cookie |
78 // being set, to pass to the cookie onChanged event. | 83 // being set, to pass to the cookie onChanged event. |
79 | 84 |
80 // Sets the cookie domain for a script cookie event. | 85 // Sets the cookie domain for a script cookie event. |
81 void SetScriptCookieDomain( | 86 void SetScriptCookieDomain( |
82 const net::CookieMonster::ParsedCookie& parsed_cookie, | 87 const net::CookieMonster::ParsedCookie& parsed_cookie, |
(...skipping 24 matching lines...) Expand all Loading... |
107 // be accessed for unit testing. | 112 // be accessed for unit testing. |
108 class ProductionCookieAccountant : public CookieAccountant, | 113 class ProductionCookieAccountant : public CookieAccountant, |
109 public Singleton<ProductionCookieAccountant> { | 114 public Singleton<ProductionCookieAccountant> { |
110 private: | 115 private: |
111 // This ensures no construction is possible outside of the class itself. | 116 // This ensures no construction is possible outside of the class itself. |
112 friend struct DefaultSingletonTraits<ProductionCookieAccountant>; | 117 friend struct DefaultSingletonTraits<ProductionCookieAccountant>; |
113 DISALLOW_IMPLICIT_CONSTRUCTORS(ProductionCookieAccountant); | 118 DISALLOW_IMPLICIT_CONSTRUCTORS(ProductionCookieAccountant); |
114 }; | 119 }; |
115 | 120 |
116 #endif // CEEE_IE_PLUGIN_BHO_COOKIE_ACCOUNTANT_H_ | 121 #endif // CEEE_IE_PLUGIN_BHO_COOKIE_ACCOUNTANT_H_ |
OLD | NEW |