| 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_ |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 LPCWSTR lpszURL, LPCWSTR lpszCookieName, LPCWSTR lpszCookieData, | 47 LPCWSTR lpszURL, LPCWSTR lpszCookieName, LPCWSTR lpszCookieData, |
| 48 DWORD dwFlags, DWORD_PTR dwReserved); | 48 DWORD dwFlags, DWORD_PTR dwReserved); |
| 49 | 49 |
| 50 protected: | 50 protected: |
| 51 // Exposed to subclasses mainly for unit testing purposes; production code | 51 // Exposed to subclasses mainly for unit testing purposes; production code |
| 52 // should use the ProductionCookieAccountant class instead. | 52 // should use the ProductionCookieAccountant class instead. |
| 53 // Since this class has one instance per window, not per tab, we cannot | 53 // Since this class has one instance per window, not per tab, we cannot |
| 54 // queue the events sent to the broker. They don't need to be sent to the BHO | 54 // queue the events sent to the broker. They don't need to be sent to the BHO |
| 55 // because they don't need tab_id anyway. | 55 // because they don't need tab_id anyway. |
| 56 CookieAccountant() | 56 CookieAccountant() |
| 57 : cookie_events_funnel_(new BrokerRpcClient(true)), | 57 : broker_rpc_client_(true), |
| 58 cookie_events_funnel_(&broker_rpc_client_), |
| 58 patching_wininet_functions_(false) { | 59 patching_wininet_functions_(false) { |
| 60 HRESULT hr = broker_rpc_client_.Connect(true); |
| 61 DCHECK(SUCCEEDED(hr)); |
| 59 } | 62 } |
| 60 | 63 |
| 61 virtual ~CookieAccountant(); | 64 virtual ~CookieAccountant(); |
| 62 | 65 |
| 63 // Records the modification or creation of a cookie. Fires off a | 66 // Records the modification or creation of a cookie. Fires off a |
| 64 // cookies.onChanged event to Chrome Frame. | 67 // cookies.onChanged event to Chrome Frame. |
| 65 virtual void RecordCookie( | 68 virtual void RecordCookie( |
| 66 const std::string& url, const std::string& cookie_data, | 69 const std::string& url, const std::string& cookie_data, |
| 67 const base::Time& current_time); | 70 const base::Time& current_time); |
| 68 | 71 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 | 106 |
| 104 // Sets the cookie expiration date for a script cookie event. | 107 // Sets the cookie expiration date for a script cookie event. |
| 105 void SetScriptCookieExpirationDate( | 108 void SetScriptCookieExpirationDate( |
| 106 const net::CookieMonster::ParsedCookie& parsed_cookie, | 109 const net::CookieMonster::ParsedCookie& parsed_cookie, |
| 107 const base::Time& current_time, | 110 const base::Time& current_time, |
| 108 cookie_api::CookieInfo* cookie); | 111 cookie_api::CookieInfo* cookie); |
| 109 | 112 |
| 110 // Sets the cookie store ID for a script cookie event. | 113 // Sets the cookie store ID for a script cookie event. |
| 111 void SetScriptCookieStoreId(cookie_api::CookieInfo* cookie); | 114 void SetScriptCookieStoreId(cookie_api::CookieInfo* cookie); |
| 112 | 115 |
| 116 // Broker RPC client. |
| 117 BrokerRpcClient broker_rpc_client_; |
| 118 |
| 113 // The funnel for sending cookie events to the broker. | 119 // The funnel for sending cookie events to the broker. |
| 114 CookieEventsFunnel cookie_events_funnel_; | 120 CookieEventsFunnel cookie_events_funnel_; |
| 115 | 121 |
| 116 DISALLOW_COPY_AND_ASSIGN(CookieAccountant); | 122 DISALLOW_COPY_AND_ASSIGN(CookieAccountant); |
| 117 }; | 123 }; |
| 118 | 124 |
| 119 // A singleton that initializes and keeps the CookieAccountant used by | 125 // A singleton that initializes and keeps the CookieAccountant used by |
| 120 // production code. This class is separate so that CookieAccountant can still | 126 // production code. This class is separate so that CookieAccountant can still |
| 121 // be accessed for unit testing. | 127 // be accessed for unit testing. |
| 122 class ProductionCookieAccountant : public CookieAccountant, | 128 class ProductionCookieAccountant : public CookieAccountant, |
| 123 public Singleton<ProductionCookieAccountant> { | 129 public Singleton<ProductionCookieAccountant> { |
| 124 private: | 130 private: |
| 125 // This ensures no construction is possible outside of the class itself. | 131 // This ensures no construction is possible outside of the class itself. |
| 126 friend struct DefaultSingletonTraits<ProductionCookieAccountant>; | 132 friend struct DefaultSingletonTraits<ProductionCookieAccountant>; |
| 127 DISALLOW_IMPLICIT_CONSTRUCTORS(ProductionCookieAccountant); | 133 DISALLOW_IMPLICIT_CONSTRUCTORS(ProductionCookieAccountant); |
| 128 }; | 134 }; |
| 129 | 135 |
| 130 #endif // CEEE_IE_PLUGIN_BHO_COOKIE_ACCOUNTANT_H_ | 136 #endif // CEEE_IE_PLUGIN_BHO_COOKIE_ACCOUNTANT_H_ |
| OLD | NEW |