| 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 177 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 188   if (!download_views_.empty()) | 188   if (!download_views_.empty()) | 
| 189     return download_views_.back(); | 189     return download_views_.back(); | 
| 190 | 190 | 
| 191   return show_all_view_; | 191   return show_all_view_; | 
| 192 } | 192 } | 
| 193 | 193 | 
| 194 void DownloadShelfView::OnPaintBorder(gfx::Canvas* canvas) { | 194 void DownloadShelfView::OnPaintBorder(gfx::Canvas* canvas) { | 
| 195   canvas->FillRect(gfx::Rect(0, 0, width(), 1), kBorderColor); | 195   canvas->FillRect(gfx::Rect(0, 0, width(), 1), kBorderColor); | 
| 196 } | 196 } | 
| 197 | 197 | 
| 198 void DownloadShelfView::OpenedDownload() { | 198 void DownloadShelfView::OnDownloadOpened() { | 
| 199   if (CanAutoClose()) | 199   TriggerAutoClose(); | 
| 200     mouse_watcher_.Start(); | 200 } | 
|  | 201 | 
|  | 202 void DownloadShelfView::OnDownloadShown() { | 
|  | 203   TriggerAutoClose(); | 
| 201 } | 204 } | 
| 202 | 205 | 
| 203 content::PageNavigator* DownloadShelfView::GetNavigator() { | 206 content::PageNavigator* DownloadShelfView::GetNavigator() { | 
| 204   return browser_; | 207   return browser_; | 
| 205 } | 208 } | 
| 206 | 209 | 
| 207 gfx::Size DownloadShelfView::GetPreferredSize() const { | 210 gfx::Size DownloadShelfView::GetPreferredSize() const { | 
| 208   gfx::Size prefsize(kEndPadding + kStartPadding + kCloseAndLinkPadding, 0); | 211   gfx::Size prefsize(kEndPadding + kStartPadding + kCloseAndLinkPadding, 0); | 
| 209   AdjustSize(close_button_, &prefsize); | 212   AdjustSize(close_button_, &prefsize); | 
| 210   AdjustSize(show_all_view_, &prefsize); | 213   AdjustSize(show_all_view_, &prefsize); | 
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 397   size_t i = 0; | 400   size_t i = 0; | 
| 398   while (i < download_views_.size()) { | 401   while (i < download_views_.size()) { | 
| 399     DownloadItem* download = download_views_[i]->download(); | 402     DownloadItem* download = download_views_[i]->download(); | 
| 400     DownloadItem::DownloadState state = download->GetState(); | 403     DownloadItem::DownloadState state = download->GetState(); | 
| 401     bool is_transfer_done = state == DownloadItem::COMPLETE || | 404     bool is_transfer_done = state == DownloadItem::COMPLETE || | 
| 402                             state == DownloadItem::CANCELLED || | 405                             state == DownloadItem::CANCELLED || | 
| 403                             state == DownloadItem::INTERRUPTED; | 406                             state == DownloadItem::INTERRUPTED; | 
| 404     if (is_transfer_done && !download->IsDangerous()) { | 407     if (is_transfer_done && !download->IsDangerous()) { | 
| 405       RemoveDownloadView(download_views_[i]); | 408       RemoveDownloadView(download_views_[i]); | 
| 406     } else { | 409     } else { | 
| 407       // Treat the item as opened when we close. This way if we get shown again | 410       // Treat the item as acted when we close. This way if we get shown again | 
| 408       // the user need not open this item for the shelf to auto-close. | 411       // the user need not open this item for the shelf to auto-close. | 
| 409       download->SetOpened(true); | 412       DownloadItemModel(download)->SetOpenedOrShown(true); | 
| 410       ++i; | 413       ++i; | 
| 411     } | 414     } | 
| 412   } | 415   } | 
| 413   SetVisible(false); | 416   SetVisible(false); | 
| 414 } | 417 } | 
| 415 | 418 | 
| 416 bool DownloadShelfView::CanAutoClose() { | 419 bool DownloadShelfView::CanAutoClose() { | 
| 417   for (size_t i = 0; i < download_views_.size(); ++i) { | 420   for (size_t i = 0; i < download_views_.size(); ++i) { | 
| 418     if (!download_views_[i]->download()->GetOpened()) | 421     if (DownloadItemModel(!download_views_[i]->download()).GetOpenedOrShown()) | 
| 419       return false; | 422       return false; | 
| 420   } | 423   } | 
| 421   return true; | 424   return true; | 
| 422 } | 425 } | 
|  | 426 | 
|  | 427 void DownloadShelfView::TriggerAutoClose() { | 
|  | 428   if (CanAutoClose()) | 
|  | 429     mouse_watcher_.Start(); | 
|  | 430 } | 
| OLD | NEW | 
|---|