| 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 #include "chrome/browser/automation/automation_provider.h" | 5 #include "chrome/browser/automation/automation_provider.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "app/message_box_flags.h" | 9 #include "app/message_box_flags.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 1233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1244 } // namespace | 1244 } // namespace |
| 1245 | 1245 |
| 1246 void AutomationProvider::GetCookies(const GURL& url, int handle, | 1246 void AutomationProvider::GetCookies(const GURL& url, int handle, |
| 1247 int* value_size, | 1247 int* value_size, |
| 1248 std::string* value) { | 1248 std::string* value) { |
| 1249 *value_size = -1; | 1249 *value_size = -1; |
| 1250 if (url.is_valid() && tab_tracker_->ContainsHandle(handle)) { | 1250 if (url.is_valid() && tab_tracker_->ContainsHandle(handle)) { |
| 1251 NavigationController* tab = tab_tracker_->GetResource(handle); | 1251 NavigationController* tab = tab_tracker_->GetResource(handle); |
| 1252 | 1252 |
| 1253 // Since we are running on the UI thread don't call GetURLRequestContext(). | 1253 // Since we are running on the UI thread don't call GetURLRequestContext(). |
| 1254 scoped_refptr<URLRequestContextGetter> request_context = | 1254 *value = GetCookiesForURL(url, tab->profile()->GetRequestContext()); |
| 1255 tab->tab_contents()->request_context(); | |
| 1256 if (!request_context.get()) | |
| 1257 request_context = tab->profile()->GetRequestContext(); | |
| 1258 | |
| 1259 *value = GetCookiesForURL(url, request_context.get()); | |
| 1260 *value_size = static_cast<int>(value->size()); | 1255 *value_size = static_cast<int>(value->size()); |
| 1261 } | 1256 } |
| 1262 } | 1257 } |
| 1263 | 1258 |
| 1264 void AutomationProvider::SetCookie(const GURL& url, | 1259 void AutomationProvider::SetCookie(const GURL& url, |
| 1265 const std::string value, | 1260 const std::string value, |
| 1266 int handle, | 1261 int handle, |
| 1267 int* response_value) { | 1262 int* response_value) { |
| 1268 *response_value = -1; | 1263 *response_value = -1; |
| 1269 | 1264 |
| 1270 if (url.is_valid() && tab_tracker_->ContainsHandle(handle)) { | 1265 if (url.is_valid() && tab_tracker_->ContainsHandle(handle)) { |
| 1271 NavigationController* tab = tab_tracker_->GetResource(handle); | 1266 NavigationController* tab = tab_tracker_->GetResource(handle); |
| 1272 | 1267 |
| 1273 scoped_refptr<URLRequestContextGetter> request_context = | 1268 if (SetCookieForURL(url, value, tab->profile()->GetRequestContext())) |
| 1274 tab->tab_contents()->request_context(); | |
| 1275 if (!request_context.get()) | |
| 1276 request_context = tab->profile()->GetRequestContext(); | |
| 1277 | |
| 1278 if (SetCookieForURL(url, value, request_context.get())) | |
| 1279 *response_value = 1; | 1269 *response_value = 1; |
| 1280 } | 1270 } |
| 1281 } | 1271 } |
| 1282 | 1272 |
| 1283 void AutomationProvider::DeleteCookie(const GURL& url, | 1273 void AutomationProvider::DeleteCookie(const GURL& url, |
| 1284 const std::string& cookie_name, | 1274 const std::string& cookie_name, |
| 1285 int handle, bool* success) { | 1275 int handle, bool* success) { |
| 1286 *success = false; | 1276 *success = false; |
| 1287 if (url.is_valid() && tab_tracker_->ContainsHandle(handle)) { | 1277 if (url.is_valid() && tab_tracker_->ContainsHandle(handle)) { |
| 1288 NavigationController* tab = tab_tracker_->GetResource(handle); | 1278 NavigationController* tab = tab_tracker_->GetResource(handle); |
| (...skipping 3196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4485 } | 4475 } |
| 4486 | 4476 |
| 4487 void AutomationProvider::WaitForPopupMenuToOpen(IPC::Message* reply_message) { | 4477 void AutomationProvider::WaitForPopupMenuToOpen(IPC::Message* reply_message) { |
| 4488 NOTIMPLEMENTED(); | 4478 NOTIMPLEMENTED(); |
| 4489 } | 4479 } |
| 4490 #endif // !defined(TOOLKIT_VIEWS) | 4480 #endif // !defined(TOOLKIT_VIEWS) |
| 4491 | 4481 |
| 4492 void AutomationProvider::ResetToDefaultTheme() { | 4482 void AutomationProvider::ResetToDefaultTheme() { |
| 4493 profile_->ClearTheme(); | 4483 profile_->ClearTheme(); |
| 4494 } | 4484 } |
| OLD | NEW |