Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(30)

Side by Side Diff: chrome/browser/ui/views/download/download_shelf_view.cc

Issue 209613002: Download shelf autohides on showing in shell, just same as regular open Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Implement a separate callbacks flow for 'shown in shell' event to not mix with 'opened' Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 154
155 void DownloadShelfView::OnPaintBorder(gfx::Canvas* canvas) { 155 void DownloadShelfView::OnPaintBorder(gfx::Canvas* canvas) {
156 canvas->FillRect(gfx::Rect(0, 0, width(), 1), kBorderColor); 156 canvas->FillRect(gfx::Rect(0, 0, width(), 1), kBorderColor);
157 } 157 }
158 158
159 void DownloadShelfView::OpenedDownload(DownloadItemView* view) { 159 void DownloadShelfView::OpenedDownload(DownloadItemView* view) {
160 if (CanAutoClose()) 160 if (CanAutoClose())
161 mouse_watcher_.Start(); 161 mouse_watcher_.Start();
162 } 162 }
163 163
164 void DownloadShelfView::ShownDownload(DownloadItemView* view) {
asanka 2014/05/14 18:40:59 Shall we rename this DownloadShown and also rename
DukeXar 2014/06/06 15:07:13 Renamed to match observer methods. Done.
165 if (CanAutoClose())
166 mouse_watcher_.Start();
167 }
168
164 content::PageNavigator* DownloadShelfView::GetNavigator() { 169 content::PageNavigator* DownloadShelfView::GetNavigator() {
165 return browser_; 170 return browser_;
166 } 171 }
167 172
168 gfx::Size DownloadShelfView::GetPreferredSize() { 173 gfx::Size DownloadShelfView::GetPreferredSize() {
169 gfx::Size prefsize(kRightPadding + kLeftPadding + kCloseAndLinkPadding, 0); 174 gfx::Size prefsize(kRightPadding + kLeftPadding + kCloseAndLinkPadding, 0);
170 AdjustSize(close_button_, &prefsize); 175 AdjustSize(close_button_, &prefsize);
171 AdjustSize(show_all_view_, &prefsize); 176 AdjustSize(show_all_view_, &prefsize);
172 // Add one download view to the preferred size. 177 // Add one download view to the preferred size.
173 if (!download_views_.empty()) { 178 if (!download_views_.empty()) {
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 DownloadItem::DownloadState state = download->GetState(); 407 DownloadItem::DownloadState state = download->GetState();
403 bool is_transfer_done = state == DownloadItem::COMPLETE || 408 bool is_transfer_done = state == DownloadItem::COMPLETE ||
404 state == DownloadItem::CANCELLED || 409 state == DownloadItem::CANCELLED ||
405 state == DownloadItem::INTERRUPTED; 410 state == DownloadItem::INTERRUPTED;
406 if (is_transfer_done && !download->IsDangerous()) { 411 if (is_transfer_done && !download->IsDangerous()) {
407 RemoveDownloadView(download_views_[i]); 412 RemoveDownloadView(download_views_[i]);
408 } else { 413 } else {
409 // Treat the item as opened when we close. This way if we get shown again 414 // Treat the item as opened when we close. This way if we get shown again
410 // the user need not open this item for the shelf to auto-close. 415 // the user need not open this item for the shelf to auto-close.
411 download->SetOpened(true); 416 download->SetOpened(true);
417 download->SetShownWhenComplete(true);
412 ++i; 418 ++i;
413 } 419 }
414 } 420 }
415 } 421 }
416 422
417 bool DownloadShelfView::CanAutoClose() { 423 bool DownloadShelfView::CanAutoClose() {
418 for (size_t i = 0; i < download_views_.size(); ++i) { 424 for (size_t i = 0; i < download_views_.size(); ++i) {
419 if (!download_views_[i]->download()->GetOpened()) 425 const content::DownloadItem * download = download_views_[i]->download();
426 if (!download->GetOpened() && !download->GetShownWhenComplete())
420 return false; 427 return false;
421 } 428 }
422 return true; 429 return true;
423 } 430 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698