| 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 1430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1441 automation_provider_->Send(reply_message_.release()); | 1441 automation_provider_->Send(reply_message_.release()); |
| 1442 } | 1442 } |
| 1443 } | 1443 } |
| 1444 delete this; | 1444 delete this; |
| 1445 } | 1445 } |
| 1446 | 1446 |
| 1447 AutomationProviderDownloadUpdatedObserver:: | 1447 AutomationProviderDownloadUpdatedObserver:: |
| 1448 AutomationProviderDownloadUpdatedObserver( | 1448 AutomationProviderDownloadUpdatedObserver( |
| 1449 AutomationProvider* provider, | 1449 AutomationProvider* provider, |
| 1450 IPC::Message* reply_message, | 1450 IPC::Message* reply_message, |
| 1451 bool wait_for_open) | 1451 bool wait_for_open, |
| 1452 bool incognito) |
| 1452 : provider_(provider->AsWeakPtr()), | 1453 : provider_(provider->AsWeakPtr()), |
| 1453 reply_message_(reply_message), | 1454 reply_message_(reply_message), |
| 1454 wait_for_open_(wait_for_open) { | 1455 wait_for_open_(wait_for_open), |
| 1456 incognito_(incognito) { |
| 1455 } | 1457 } |
| 1456 | 1458 |
| 1457 AutomationProviderDownloadUpdatedObserver:: | 1459 AutomationProviderDownloadUpdatedObserver:: |
| 1458 ~AutomationProviderDownloadUpdatedObserver() {} | 1460 ~AutomationProviderDownloadUpdatedObserver() {} |
| 1459 | 1461 |
| 1460 void AutomationProviderDownloadUpdatedObserver::OnDownloadUpdated( | 1462 void AutomationProviderDownloadUpdatedObserver::OnDownloadUpdated( |
| 1461 DownloadItem* download) { | 1463 DownloadItem* download) { |
| 1462 // If this observer is watching for open, only send the reply if the download | 1464 // If this observer is watching for open, only send the reply if the download |
| 1463 // has been auto-opened. | 1465 // has been auto-opened. |
| 1464 if (wait_for_open_ && !download->GetAutoOpened()) | 1466 if (wait_for_open_ && !download->GetAutoOpened()) |
| 1465 return; | 1467 return; |
| 1466 | 1468 |
| 1467 download->RemoveObserver(this); | 1469 download->RemoveObserver(this); |
| 1468 | 1470 |
| 1469 if (provider_) { | 1471 if (provider_) { |
| 1470 scoped_ptr<DictionaryValue> return_value( | 1472 scoped_ptr<DictionaryValue> return_value( |
| 1471 provider_->GetDictionaryFromDownloadItem(download)); | 1473 provider_->GetDictionaryFromDownloadItem(download, incognito_)); |
| 1472 AutomationJSONReply(provider_, reply_message_.release()).SendSuccess( | 1474 AutomationJSONReply(provider_, reply_message_.release()).SendSuccess( |
| 1473 return_value.get()); | 1475 return_value.get()); |
| 1474 } | 1476 } |
| 1475 delete this; | 1477 delete this; |
| 1476 } | 1478 } |
| 1477 | 1479 |
| 1478 void AutomationProviderDownloadUpdatedObserver::OnDownloadOpened( | 1480 void AutomationProviderDownloadUpdatedObserver::OnDownloadOpened( |
| 1479 DownloadItem* download) { | 1481 DownloadItem* download) { |
| 1480 download->RemoveObserver(this); | 1482 download->RemoveObserver(this); |
| 1481 | 1483 |
| 1482 if (provider_) { | 1484 if (provider_) { |
| 1483 scoped_ptr<DictionaryValue> return_value( | 1485 scoped_ptr<DictionaryValue> return_value( |
| 1484 provider_->GetDictionaryFromDownloadItem(download)); | 1486 provider_->GetDictionaryFromDownloadItem(download, incognito_)); |
| 1485 AutomationJSONReply(provider_, reply_message_.release()).SendSuccess( | 1487 AutomationJSONReply(provider_, reply_message_.release()).SendSuccess( |
| 1486 return_value.get()); | 1488 return_value.get()); |
| 1487 } | 1489 } |
| 1488 delete this; | 1490 delete this; |
| 1489 } | 1491 } |
| 1490 | 1492 |
| 1491 AutomationProviderDownloadModelChangedObserver:: | 1493 AutomationProviderDownloadModelChangedObserver:: |
| 1492 AutomationProviderDownloadModelChangedObserver( | 1494 AutomationProviderDownloadModelChangedObserver( |
| 1493 AutomationProvider* provider, | 1495 AutomationProvider* provider, |
| 1494 IPC::Message* reply_message, | 1496 IPC::Message* reply_message, |
| (...skipping 1672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3167 if (automation_) { | 3169 if (automation_) { |
| 3168 AutomationJSONReply(automation_, reply_message_.release()) | 3170 AutomationJSONReply(automation_, reply_message_.release()) |
| 3169 .SendSuccess(NULL); | 3171 .SendSuccess(NULL); |
| 3170 } | 3172 } |
| 3171 delete this; | 3173 delete this; |
| 3172 } | 3174 } |
| 3173 } else { | 3175 } else { |
| 3174 NOTREACHED(); | 3176 NOTREACHED(); |
| 3175 } | 3177 } |
| 3176 } | 3178 } |
| OLD | NEW |