| 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 1419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1430 reply_message_.get(), success); | 1430 reply_message_.get(), success); |
| 1431 automation_provider_->Send(reply_message_.release()); | 1431 automation_provider_->Send(reply_message_.release()); |
| 1432 } | 1432 } |
| 1433 delete this; | 1433 delete this; |
| 1434 } | 1434 } |
| 1435 | 1435 |
| 1436 AutomationProviderDownloadUpdatedObserver:: | 1436 AutomationProviderDownloadUpdatedObserver:: |
| 1437 AutomationProviderDownloadUpdatedObserver( | 1437 AutomationProviderDownloadUpdatedObserver( |
| 1438 AutomationProvider* provider, | 1438 AutomationProvider* provider, |
| 1439 IPC::Message* reply_message, | 1439 IPC::Message* reply_message, |
| 1440 bool wait_for_open) | 1440 bool wait_for_open, |
| 1441 Profile* profile) |
| 1441 : provider_(provider->AsWeakPtr()), | 1442 : provider_(provider->AsWeakPtr()), |
| 1442 reply_message_(reply_message), | 1443 reply_message_(reply_message), |
| 1443 wait_for_open_(wait_for_open) { | 1444 wait_for_open_(wait_for_open), |
| 1445 profile_(profile) { |
| 1444 } | 1446 } |
| 1445 | 1447 |
| 1446 AutomationProviderDownloadUpdatedObserver:: | 1448 AutomationProviderDownloadUpdatedObserver:: |
| 1447 ~AutomationProviderDownloadUpdatedObserver() {} | 1449 ~AutomationProviderDownloadUpdatedObserver() {} |
| 1448 | 1450 |
| 1449 void AutomationProviderDownloadUpdatedObserver::OnDownloadUpdated( | 1451 void AutomationProviderDownloadUpdatedObserver::OnDownloadUpdated( |
| 1450 DownloadItem* download) { | 1452 DownloadItem* download) { |
| 1451 // If this observer is watching for open, only send the reply if the download | 1453 // If this observer is watching for open, only send the reply if the download |
| 1452 // has been auto-opened. | 1454 // has been auto-opened. |
| 1453 if (wait_for_open_ && !download->GetAutoOpened()) | 1455 if (wait_for_open_ && !download->GetAutoOpened()) |
| 1454 return; | 1456 return; |
| 1455 | 1457 |
| 1456 download->RemoveObserver(this); | 1458 download->RemoveObserver(this); |
| 1457 | 1459 |
| 1458 if (provider_) { | 1460 if (provider_) { |
| 1459 scoped_ptr<DictionaryValue> return_value( | 1461 scoped_ptr<DictionaryValue> return_value( |
| 1460 provider_->GetDictionaryFromDownloadItem(download)); | 1462 provider_->GetDictionaryFromDownloadItem(download, profile_)); |
| 1461 AutomationJSONReply(provider_, reply_message_.release()).SendSuccess( | 1463 AutomationJSONReply(provider_, reply_message_.release()).SendSuccess( |
| 1462 return_value.get()); | 1464 return_value.get()); |
| 1463 } | 1465 } |
| 1464 delete this; | 1466 delete this; |
| 1465 } | 1467 } |
| 1466 | 1468 |
| 1467 void AutomationProviderDownloadUpdatedObserver::OnDownloadOpened( | 1469 void AutomationProviderDownloadUpdatedObserver::OnDownloadOpened( |
| 1468 DownloadItem* download) { | 1470 DownloadItem* download) { |
| 1469 download->RemoveObserver(this); | 1471 download->RemoveObserver(this); |
| 1470 | 1472 |
| 1471 if (provider_) { | 1473 if (provider_) { |
| 1472 scoped_ptr<DictionaryValue> return_value( | 1474 scoped_ptr<DictionaryValue> return_value( |
| 1473 provider_->GetDictionaryFromDownloadItem(download)); | 1475 provider_->GetDictionaryFromDownloadItem(download, profile_)); |
| 1474 AutomationJSONReply(provider_, reply_message_.release()).SendSuccess( | 1476 AutomationJSONReply(provider_, reply_message_.release()).SendSuccess( |
| 1475 return_value.get()); | 1477 return_value.get()); |
| 1476 } | 1478 } |
| 1477 delete this; | 1479 delete this; |
| 1478 } | 1480 } |
| 1479 | 1481 |
| 1480 AutomationProviderDownloadModelChangedObserver:: | 1482 AutomationProviderDownloadModelChangedObserver:: |
| 1481 AutomationProviderDownloadModelChangedObserver( | 1483 AutomationProviderDownloadModelChangedObserver( |
| 1482 AutomationProvider* provider, | 1484 AutomationProvider* provider, |
| 1483 IPC::Message* reply_message, | 1485 IPC::Message* reply_message, |
| (...skipping 1671 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3155 if (automation_) { | 3157 if (automation_) { |
| 3156 AutomationJSONReply(automation_, reply_message_.release()) | 3158 AutomationJSONReply(automation_, reply_message_.release()) |
| 3157 .SendSuccess(NULL); | 3159 .SendSuccess(NULL); |
| 3158 } | 3160 } |
| 3159 delete this; | 3161 delete this; |
| 3160 } | 3162 } |
| 3161 } else { | 3163 } else { |
| 3162 NOTREACHED(); | 3164 NOTREACHED(); |
| 3163 } | 3165 } |
| 3164 } | 3166 } |
| OLD | NEW |