OLD | NEW |
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 #include "chrome/browser/automation/automation_profile_impl.h" | 5 #include "chrome/browser/automation/automation_profile_impl.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 | 8 |
9 #include "chrome/browser/automation/automation_resource_message_filter.h" | 9 #include "chrome/browser/automation/automation_resource_message_filter.h" |
10 #include "chrome/browser/chrome_thread.h" | 10 #include "chrome/browser/chrome_thread.h" |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 const std::string& cookie_name) { | 90 const std::string& cookie_name) { |
91 NOTREACHED() << "Should not get called for an automation profile"; | 91 NOTREACHED() << "Should not get called for an automation profile"; |
92 } | 92 } |
93 | 93 |
94 virtual net::CookieMonster* GetCookieMonster() { | 94 virtual net::CookieMonster* GetCookieMonster() { |
95 NOTREACHED() << "Should not get called for an automation profile"; | 95 NOTREACHED() << "Should not get called for an automation profile"; |
96 return NULL; | 96 return NULL; |
97 } | 97 } |
98 | 98 |
99 protected: | 99 protected: |
100 void SendIPCMessageOnIOThread(IPC::Message* m) { | |
101 if (ChromeThread::CurrentlyOn(ChromeThread::IO)) { | |
102 automation_client_->Send(m); | |
103 } else { | |
104 Task* task = NewRunnableMethod(this, | |
105 &AutomationCookieStore::SendIPCMessageOnIOThread, m); | |
106 ChromeThread::PostTask(ChromeThread::IO, FROM_HERE, task); | |
107 } | |
108 } | |
109 | |
110 net::CookieStore* original_cookie_store_; | 100 net::CookieStore* original_cookie_store_; |
111 scoped_refptr<AutomationResourceMessageFilter> automation_client_; | 101 scoped_refptr<AutomationResourceMessageFilter> automation_client_; |
112 int tab_handle_; | 102 int tab_handle_; |
113 std::string cookie_string_; | 103 std::string cookie_string_; |
114 | 104 |
115 private: | 105 private: |
116 DISALLOW_COPY_AND_ASSIGN(AutomationCookieStore); | 106 DISALLOW_COPY_AND_ASSIGN(AutomationCookieStore); |
117 }; | 107 }; |
118 | 108 |
119 // CookiePolicy specialization for automation specific cookie policies. | 109 // CookiePolicy specialization for automation specific cookie policies. |
120 class AutomationCookiePolicy : public net::CookiePolicy { | 110 class AutomationCookiePolicy : public net::CookiePolicy { |
121 public: | 111 public: |
122 AutomationCookiePolicy(AutomationResourceMessageFilter* automation_client, | 112 AutomationCookiePolicy(AutomationResourceMessageFilter* automation_client, |
123 int tab_handle, net::CookieStore* cookie_store) | 113 int tab_handle, net::CookieStore* cookie_store) |
124 : automation_client_(automation_client), | 114 : automation_client_(automation_client), |
125 tab_handle_(tab_handle), | 115 tab_handle_(tab_handle), |
126 cookie_store_(cookie_store) {} | 116 cookie_store_(cookie_store) {} |
127 | 117 |
128 virtual int CanGetCookies(const GURL& url, | 118 virtual int CanGetCookies(const GURL& url, |
129 const GURL& first_party_for_cookies, | 119 const GURL& first_party_for_cookies, |
130 net::CompletionCallback* callback) { | 120 net::CompletionCallback* callback) { |
131 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); | 121 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); |
132 | 122 |
133 if (automation_client_.get()) { | 123 AutomationResourceMessageFilter::GetCookiesForUrl(tab_handle_, url, |
134 automation_client_->GetCookiesForUrl(tab_handle_, url, callback, | 124 callback, |
135 cookie_store_.get()); | 125 cookie_store_.get()); |
136 return net::ERR_IO_PENDING; | 126 return net::ERR_IO_PENDING; |
137 } | |
138 return net::ERR_ACCESS_DENIED; | |
139 } | 127 } |
140 | 128 |
141 virtual int CanSetCookie(const GURL& url, | 129 virtual int CanSetCookie(const GURL& url, |
142 const GURL& first_party_for_cookies, | 130 const GURL& first_party_for_cookies, |
143 const std::string& cookie_line, | 131 const std::string& cookie_line, |
144 net::CompletionCallback* callback) { | 132 net::CompletionCallback* callback) { |
145 if (automation_client_.get()) { | 133 AutomationResourceMessageFilter::SetCookiesForUrl(tab_handle_, url, |
146 automation_client_->Send(new AutomationMsg_SetCookieAsync(0, | 134 cookie_line, |
147 tab_handle_, url, cookie_line)); | 135 callback); |
148 } | 136 return net::ERR_IO_PENDING; |
149 return net::ERR_ACCESS_DENIED; | |
150 } | 137 } |
151 | 138 |
152 private: | 139 private: |
153 scoped_refptr<AutomationResourceMessageFilter> automation_client_; | 140 scoped_refptr<AutomationResourceMessageFilter> automation_client_; |
154 int tab_handle_; | 141 int tab_handle_; |
155 scoped_refptr<net::CookieStore> cookie_store_; | 142 scoped_refptr<net::CookieStore> cookie_store_; |
156 | 143 |
157 DISALLOW_COPY_AND_ASSIGN(AutomationCookiePolicy); | 144 DISALLOW_COPY_AND_ASSIGN(AutomationCookiePolicy); |
158 }; | 145 }; |
159 | 146 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 ChromeURLRequestContextGetter* request_context = | 194 ChromeURLRequestContextGetter* request_context = |
208 new ChromeURLRequestContextGetter( | 195 new ChromeURLRequestContextGetter( |
209 NULL, // Don't register an observer on PrefService. | 196 NULL, // Don't register an observer on PrefService. |
210 new Factory(original_context, profile, automation_client, | 197 new Factory(original_context, profile, automation_client, |
211 tab_handle)); | 198 tab_handle)); |
212 return request_context; | 199 return request_context; |
213 } | 200 } |
214 | 201 |
215 } // namespace AutomationRequestContext | 202 } // namespace AutomationRequestContext |
216 | 203 |
OLD | NEW |