OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 1490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1501 wait_for_open_(wait_for_open) { | 1501 wait_for_open_(wait_for_open) { |
1502 } | 1502 } |
1503 | 1503 |
1504 AutomationProviderDownloadUpdatedObserver:: | 1504 AutomationProviderDownloadUpdatedObserver:: |
1505 ~AutomationProviderDownloadUpdatedObserver() {} | 1505 ~AutomationProviderDownloadUpdatedObserver() {} |
1506 | 1506 |
1507 void AutomationProviderDownloadUpdatedObserver::OnDownloadUpdated( | 1507 void AutomationProviderDownloadUpdatedObserver::OnDownloadUpdated( |
1508 DownloadItem* download) { | 1508 DownloadItem* download) { |
1509 // If this observer is watching for open, only send the reply if the download | 1509 // If this observer is watching for open, only send the reply if the download |
1510 // has been auto-opened. | 1510 // has been auto-opened. |
1511 if (wait_for_open_ && !download->auto_opened()) | 1511 if (wait_for_open_ && !download->GetAutoOpened()) |
1512 return; | 1512 return; |
1513 | 1513 |
1514 download->RemoveObserver(this); | 1514 download->RemoveObserver(this); |
1515 | 1515 |
1516 if (provider_) { | 1516 if (provider_) { |
1517 scoped_ptr<DictionaryValue> return_value( | 1517 scoped_ptr<DictionaryValue> return_value( |
1518 provider_->GetDictionaryFromDownloadItem(download)); | 1518 provider_->GetDictionaryFromDownloadItem(download)); |
1519 AutomationJSONReply(provider_, reply_message_.release()).SendSuccess( | 1519 AutomationJSONReply(provider_, reply_message_.release()).SendSuccess( |
1520 return_value.get()); | 1520 return_value.get()); |
1521 } | 1521 } |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1581 | 1581 |
1582 AllDownloadsCompleteObserver::~AllDownloadsCompleteObserver() {} | 1582 AllDownloadsCompleteObserver::~AllDownloadsCompleteObserver() {} |
1583 | 1583 |
1584 void AllDownloadsCompleteObserver::ModelChanged() { | 1584 void AllDownloadsCompleteObserver::ModelChanged() { |
1585 // The set of downloads in the download manager has changed. If there are | 1585 // The set of downloads in the download manager has changed. If there are |
1586 // any new downloads that are still in progress, add them to the pending list. | 1586 // any new downloads that are still in progress, add them to the pending list. |
1587 std::vector<DownloadItem*> downloads; | 1587 std::vector<DownloadItem*> downloads; |
1588 download_manager_->GetAllDownloads(FilePath(), &downloads); | 1588 download_manager_->GetAllDownloads(FilePath(), &downloads); |
1589 for (std::vector<DownloadItem*>::iterator it = downloads.begin(); | 1589 for (std::vector<DownloadItem*>::iterator it = downloads.begin(); |
1590 it != downloads.end(); ++it) { | 1590 it != downloads.end(); ++it) { |
1591 if ((*it)->state() == DownloadItem::IN_PROGRESS && | 1591 if ((*it)->GetState() == DownloadItem::IN_PROGRESS && |
1592 pre_download_ids_.find((*it)->id()) == pre_download_ids_.end()) { | 1592 pre_download_ids_.find((*it)->GetId()) == pre_download_ids_.end()) { |
1593 (*it)->AddObserver(this); | 1593 (*it)->AddObserver(this); |
1594 pending_downloads_.insert(*it); | 1594 pending_downloads_.insert(*it); |
1595 } | 1595 } |
1596 } | 1596 } |
1597 ReplyIfNecessary(); | 1597 ReplyIfNecessary(); |
1598 } | 1598 } |
1599 | 1599 |
1600 void AllDownloadsCompleteObserver::OnDownloadUpdated(DownloadItem* download) { | 1600 void AllDownloadsCompleteObserver::OnDownloadUpdated(DownloadItem* download) { |
1601 // If the current download's status has changed to a final state (not state | 1601 // If the current download's status has changed to a final state (not state |
1602 // "in progress"), remove it from the pending list. | 1602 // "in progress"), remove it from the pending list. |
1603 if (download->state() != DownloadItem::IN_PROGRESS) { | 1603 if (download->GetState() != DownloadItem::IN_PROGRESS) { |
1604 download->RemoveObserver(this); | 1604 download->RemoveObserver(this); |
1605 pending_downloads_.erase(download); | 1605 pending_downloads_.erase(download); |
1606 ReplyIfNecessary(); | 1606 ReplyIfNecessary(); |
1607 } | 1607 } |
1608 } | 1608 } |
1609 | 1609 |
1610 void AllDownloadsCompleteObserver::ReplyIfNecessary() { | 1610 void AllDownloadsCompleteObserver::ReplyIfNecessary() { |
1611 if (!pending_downloads_.empty()) | 1611 if (!pending_downloads_.empty()) |
1612 return; | 1612 return; |
1613 | 1613 |
(...skipping 1311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2925 if (automation_) { | 2925 if (automation_) { |
2926 AutomationJSONReply(automation_, reply_message_.release()) | 2926 AutomationJSONReply(automation_, reply_message_.release()) |
2927 .SendSuccess(NULL); | 2927 .SendSuccess(NULL); |
2928 } | 2928 } |
2929 delete this; | 2929 delete this; |
2930 } | 2930 } |
2931 } else { | 2931 } else { |
2932 NOTREACHED(); | 2932 NOTREACHED(); |
2933 } | 2933 } |
2934 } | 2934 } |
OLD | NEW |