| 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/l10n_util.h" | 9 #include "app/l10n_util.h" |
| 10 #include "app/message_box_flags.h" | 10 #include "app/message_box_flags.h" |
| (...skipping 1227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1238 } // namespace | 1238 } // namespace |
| 1239 | 1239 |
| 1240 void AutomationProvider::GetCookies(const GURL& url, int handle, | 1240 void AutomationProvider::GetCookies(const GURL& url, int handle, |
| 1241 int* value_size, | 1241 int* value_size, |
| 1242 std::string* value) { | 1242 std::string* value) { |
| 1243 *value_size = -1; | 1243 *value_size = -1; |
| 1244 if (url.is_valid() && tab_tracker_->ContainsHandle(handle)) { | 1244 if (url.is_valid() && tab_tracker_->ContainsHandle(handle)) { |
| 1245 NavigationController* tab = tab_tracker_->GetResource(handle); | 1245 NavigationController* tab = tab_tracker_->GetResource(handle); |
| 1246 | 1246 |
| 1247 // Since we are running on the UI thread don't call GetURLRequestContext(). | 1247 // Since we are running on the UI thread don't call GetURLRequestContext(). |
| 1248 scoped_refptr<URLRequestContextGetter> request_context = | 1248 *value = GetCookiesForURL(url, tab->profile()->GetRequestContext()); |
| 1249 tab->tab_contents()->request_context(); | |
| 1250 if (!request_context.get()) | |
| 1251 request_context = tab->profile()->GetRequestContext(); | |
| 1252 | |
| 1253 *value = GetCookiesForURL(url, request_context.get()); | |
| 1254 *value_size = static_cast<int>(value->size()); | 1249 *value_size = static_cast<int>(value->size()); |
| 1255 } | 1250 } |
| 1256 } | 1251 } |
| 1257 | 1252 |
| 1258 void AutomationProvider::SetCookie(const GURL& url, | 1253 void AutomationProvider::SetCookie(const GURL& url, |
| 1259 const std::string value, | 1254 const std::string value, |
| 1260 int handle, | 1255 int handle, |
| 1261 int* response_value) { | 1256 int* response_value) { |
| 1262 *response_value = -1; | 1257 *response_value = -1; |
| 1263 | 1258 |
| 1264 if (url.is_valid() && tab_tracker_->ContainsHandle(handle)) { | 1259 if (url.is_valid() && tab_tracker_->ContainsHandle(handle)) { |
| 1265 NavigationController* tab = tab_tracker_->GetResource(handle); | 1260 NavigationController* tab = tab_tracker_->GetResource(handle); |
| 1266 | 1261 |
| 1267 scoped_refptr<URLRequestContextGetter> request_context = | 1262 if (SetCookieForURL(url, value, tab->profile()->GetRequestContext())) |
| 1268 tab->tab_contents()->request_context(); | |
| 1269 if (!request_context.get()) | |
| 1270 request_context = tab->profile()->GetRequestContext(); | |
| 1271 | |
| 1272 if (SetCookieForURL(url, value, request_context.get())) | |
| 1273 *response_value = 1; | 1263 *response_value = 1; |
| 1274 } | 1264 } |
| 1275 } | 1265 } |
| 1276 | 1266 |
| 1277 void AutomationProvider::DeleteCookie(const GURL& url, | 1267 void AutomationProvider::DeleteCookie(const GURL& url, |
| 1278 const std::string& cookie_name, | 1268 const std::string& cookie_name, |
| 1279 int handle, bool* success) { | 1269 int handle, bool* success) { |
| 1280 *success = false; | 1270 *success = false; |
| 1281 if (url.is_valid() && tab_tracker_->ContainsHandle(handle)) { | 1271 if (url.is_valid() && tab_tracker_->ContainsHandle(handle)) { |
| 1282 NavigationController* tab = tab_tracker_->GetResource(handle); | 1272 NavigationController* tab = tab_tracker_->GetResource(handle); |
| (...skipping 2749 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4032 } | 4022 } |
| 4033 | 4023 |
| 4034 void AutomationProvider::WaitForPopupMenuToOpen(IPC::Message* reply_message) { | 4024 void AutomationProvider::WaitForPopupMenuToOpen(IPC::Message* reply_message) { |
| 4035 NOTIMPLEMENTED(); | 4025 NOTIMPLEMENTED(); |
| 4036 } | 4026 } |
| 4037 #endif // !defined(TOOLKIT_VIEWS) | 4027 #endif // !defined(TOOLKIT_VIEWS) |
| 4038 | 4028 |
| 4039 void AutomationProvider::ResetToDefaultTheme() { | 4029 void AutomationProvider::ResetToDefaultTheme() { |
| 4040 profile_->ClearTheme(); | 4030 profile_->ClearTheme(); |
| 4041 } | 4031 } |
| OLD | NEW |