| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_observers.h" | 5 #include "chrome/browser/automation/automation_provider_observers.h" |
| 6 | 6 |
| 7 #include <deque> | 7 #include <deque> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 1416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1427 reply_message_.get(), success); | 1427 reply_message_.get(), success); |
| 1428 automation_provider_->Send(reply_message_.release()); | 1428 automation_provider_->Send(reply_message_.release()); |
| 1429 } | 1429 } |
| 1430 delete this; | 1430 delete this; |
| 1431 } | 1431 } |
| 1432 | 1432 |
| 1433 AutomationProviderDownloadUpdatedObserver:: | 1433 AutomationProviderDownloadUpdatedObserver:: |
| 1434 AutomationProviderDownloadUpdatedObserver( | 1434 AutomationProviderDownloadUpdatedObserver( |
| 1435 AutomationProvider* provider, | 1435 AutomationProvider* provider, |
| 1436 IPC::Message* reply_message, | 1436 IPC::Message* reply_message, |
| 1437 bool wait_for_open) | 1437 bool wait_for_open, |
| 1438 bool item_incognito) |
| 1438 : provider_(provider->AsWeakPtr()), | 1439 : provider_(provider->AsWeakPtr()), |
| 1439 reply_message_(reply_message), | 1440 reply_message_(reply_message), |
| 1440 wait_for_open_(wait_for_open) { | 1441 wait_for_open_(wait_for_open), |
| 1442 incognito_(item_incognito) { |
| 1441 } | 1443 } |
| 1442 | 1444 |
| 1443 AutomationProviderDownloadUpdatedObserver:: | 1445 AutomationProviderDownloadUpdatedObserver:: |
| 1444 ~AutomationProviderDownloadUpdatedObserver() {} | 1446 ~AutomationProviderDownloadUpdatedObserver() {} |
| 1445 | 1447 |
| 1446 void AutomationProviderDownloadUpdatedObserver::OnDownloadUpdated( | 1448 void AutomationProviderDownloadUpdatedObserver::OnDownloadUpdated( |
| 1447 DownloadItem* download) { | 1449 DownloadItem* download) { |
| 1448 // If this observer is watching for open, only send the reply if the download | 1450 // If this observer is watching for open, only send the reply if the download |
| 1449 // has been auto-opened. | 1451 // has been auto-opened. |
| 1450 if (wait_for_open_ && !download->GetAutoOpened()) | 1452 if (wait_for_open_ && !download->GetAutoOpened()) |
| 1451 return; | 1453 return; |
| 1452 | 1454 |
| 1453 download->RemoveObserver(this); | 1455 download->RemoveObserver(this); |
| 1454 | 1456 |
| 1455 if (provider_) { | 1457 if (provider_) { |
| 1456 scoped_ptr<DictionaryValue> return_value( | 1458 scoped_ptr<DictionaryValue> return_value( |
| 1457 provider_->GetDictionaryFromDownloadItem(download)); | 1459 provider_->GetDictionaryFromDownloadItem(download, incognito_)); |
| 1458 AutomationJSONReply(provider_, reply_message_.release()).SendSuccess( | 1460 AutomationJSONReply(provider_, reply_message_.release()).SendSuccess( |
| 1459 return_value.get()); | 1461 return_value.get()); |
| 1460 } | 1462 } |
| 1461 delete this; | 1463 delete this; |
| 1462 } | 1464 } |
| 1463 | 1465 |
| 1464 void AutomationProviderDownloadUpdatedObserver::OnDownloadOpened( | 1466 void AutomationProviderDownloadUpdatedObserver::OnDownloadOpened( |
| 1465 DownloadItem* download) { | 1467 DownloadItem* download) { |
| 1466 download->RemoveObserver(this); | 1468 download->RemoveObserver(this); |
| 1467 | 1469 |
| 1468 if (provider_) { | 1470 if (provider_) { |
| 1469 scoped_ptr<DictionaryValue> return_value( | 1471 scoped_ptr<DictionaryValue> return_value( |
| 1470 provider_->GetDictionaryFromDownloadItem(download)); | 1472 provider_->GetDictionaryFromDownloadItem(download, incognito_)); |
| 1471 AutomationJSONReply(provider_, reply_message_.release()).SendSuccess( | 1473 AutomationJSONReply(provider_, reply_message_.release()).SendSuccess( |
| 1472 return_value.get()); | 1474 return_value.get()); |
| 1473 } | 1475 } |
| 1474 delete this; | 1476 delete this; |
| 1475 } | 1477 } |
| 1476 | 1478 |
| 1477 AutomationProviderDownloadModelChangedObserver:: | 1479 AutomationProviderDownloadModelChangedObserver:: |
| 1478 AutomationProviderDownloadModelChangedObserver( | 1480 AutomationProviderDownloadModelChangedObserver( |
| 1479 AutomationProvider* provider, | 1481 AutomationProvider* provider, |
| 1480 IPC::Message* reply_message, | 1482 IPC::Message* reply_message, |
| (...skipping 1670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3151 if (automation_) { | 3153 if (automation_) { |
| 3152 AutomationJSONReply(automation_, reply_message_.release()) | 3154 AutomationJSONReply(automation_, reply_message_.release()) |
| 3153 .SendSuccess(NULL); | 3155 .SendSuccess(NULL); |
| 3154 } | 3156 } |
| 3155 delete this; | 3157 delete this; |
| 3156 } | 3158 } |
| 3157 } else { | 3159 } else { |
| 3158 NOTREACHED(); | 3160 NOTREACHED(); |
| 3159 } | 3161 } |
| 3160 } | 3162 } |
| OLD | NEW |