| 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/ui/views/download/download_shelf_view.h" |    5 #include "chrome/browser/ui/views/download/download_shelf_view.h" | 
|    6  |    6  | 
|    7 #include <algorithm> |    7 #include <algorithm> | 
|    8 #include <vector> |    8 #include <vector> | 
|    9  |    9  | 
|   10 #include "base/logging.h" |   10 #include "base/logging.h" | 
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  153  |  153  | 
|  154 views::View* DownloadShelfView::GetDefaultFocusableChild() { |  154 views::View* DownloadShelfView::GetDefaultFocusableChild() { | 
|  155   return download_views_.empty() ? |  155   return download_views_.empty() ? | 
|  156       static_cast<View*>(show_all_view_) : download_views_.back(); |  156       static_cast<View*>(show_all_view_) : download_views_.back(); | 
|  157 } |  157 } | 
|  158  |  158  | 
|  159 void DownloadShelfView::OnPaintBorder(gfx::Canvas* canvas) { |  159 void DownloadShelfView::OnPaintBorder(gfx::Canvas* canvas) { | 
|  160   canvas->FillRect(gfx::Rect(0, 0, width(), 1), kBorderColor); |  160   canvas->FillRect(gfx::Rect(0, 0, width(), 1), kBorderColor); | 
|  161 } |  161 } | 
|  162  |  162  | 
|  163 void DownloadShelfView::OpenedDownload(DownloadItemView* view) { |  163 void DownloadShelfView::OnDownloadOpened(DownloadItemView* view) { | 
|  164   if (CanAutoClose()) |  164   if (CanAutoClose()) | 
|  165     mouse_watcher_.Start(); |  165     mouse_watcher_.Start(); | 
|  166 } |  166 } | 
 |  167  | 
 |  168 void DownloadShelfView::OnDownloadShown(DownloadItemView* view) { | 
 |  169   if (CanAutoClose()) | 
 |  170     mouse_watcher_.Start(); | 
 |  171 } | 
|  167  |  172  | 
|  168 content::PageNavigator* DownloadShelfView::GetNavigator() { |  173 content::PageNavigator* DownloadShelfView::GetNavigator() { | 
|  169   return browser_; |  174   return browser_; | 
|  170 } |  175 } | 
|  171  |  176  | 
|  172 gfx::Size DownloadShelfView::GetPreferredSize() const { |  177 gfx::Size DownloadShelfView::GetPreferredSize() const { | 
|  173   gfx::Size prefsize(kRightPadding + kLeftPadding + kCloseAndLinkPadding, 0); |  178   gfx::Size prefsize(kRightPadding + kLeftPadding + kCloseAndLinkPadding, 0); | 
|  174   AdjustSize(close_button_, &prefsize); |  179   AdjustSize(close_button_, &prefsize); | 
|  175   AdjustSize(show_all_view_, &prefsize); |  180   AdjustSize(show_all_view_, &prefsize); | 
|  176   // Add one download view to the preferred size. |  181   // Add one download view to the preferred size. | 
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  403   size_t i = 0; |  408   size_t i = 0; | 
|  404   while (i < download_views_.size()) { |  409   while (i < download_views_.size()) { | 
|  405     DownloadItem* download = download_views_[i]->download(); |  410     DownloadItem* download = download_views_[i]->download(); | 
|  406     DownloadItem::DownloadState state = download->GetState(); |  411     DownloadItem::DownloadState state = download->GetState(); | 
|  407     bool is_transfer_done = state == DownloadItem::COMPLETE || |  412     bool is_transfer_done = state == DownloadItem::COMPLETE || | 
|  408                             state == DownloadItem::CANCELLED || |  413                             state == DownloadItem::CANCELLED || | 
|  409                             state == DownloadItem::INTERRUPTED; |  414                             state == DownloadItem::INTERRUPTED; | 
|  410     if (is_transfer_done && !download->IsDangerous()) { |  415     if (is_transfer_done && !download->IsDangerous()) { | 
|  411       RemoveDownloadView(download_views_[i]); |  416       RemoveDownloadView(download_views_[i]); | 
|  412     } else { |  417     } else { | 
|  413       // Treat the item as opened when we close. This way if we get shown again |  418       // Treat the item as acted when we close. This way if we get shown again | 
|  414       // the user need not open this item for the shelf to auto-close. |  419       // the user need not act on this item for the shelf to auto-close. | 
|  415       download->SetOpened(true); |  420       DownloadItemModel(download).SetUserActed(true); | 
|  416       ++i; |  421       ++i; | 
|  417     } |  422     } | 
|  418   } |  423   } | 
|  419 } |  424 } | 
|  420  |  425  | 
|  421 bool DownloadShelfView::CanAutoClose() { |  426 bool DownloadShelfView::CanAutoClose() { | 
|  422   for (size_t i = 0; i < download_views_.size(); ++i) { |  427   for (size_t i = 0; i < download_views_.size(); ++i) { | 
|  423     if (!download_views_[i]->download()->GetOpened()) |  428     if (!DownloadItemModel(download_views_[i]->download()).GetUserActed()) | 
|  424       return false; |  429       return false; | 
|  425   } |  430   } | 
|  426   return true; |  431   return true; | 
|  427 } |  432 } | 
| OLD | NEW |