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

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

Issue 274273002: Views: Reverse Tab order of Download Shelf Items (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Insertion Order instead of Custom Focus 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 107
108 DownloadShelfView::~DownloadShelfView() { 108 DownloadShelfView::~DownloadShelfView() {
109 parent_->RemoveChildView(this); 109 parent_->RemoveChildView(this);
110 } 110 }
111 111
112 void DownloadShelfView::AddDownloadView(DownloadItemView* view) { 112 void DownloadShelfView::AddDownloadView(DownloadItemView* view) {
113 mouse_watcher_.Stop(); 113 mouse_watcher_.Stop();
114 114
115 DCHECK(view); 115 DCHECK(view);
116 download_views_.push_back(view); 116 download_views_.push_back(view);
117 AddChildView(view); 117
118 // Insert the new view at index 0 to maintain a newest to oldest tab order.
Peter Kasting 2014/05/22 18:23:14 Nit: How about: Insert the new view as the first
119 AddChildViewAt(view, 0);
118 if (download_views_.size() > kMaxDownloadViews) 120 if (download_views_.size() > kMaxDownloadViews)
119 RemoveDownloadView(*download_views_.begin()); 121 RemoveDownloadView(*download_views_.begin());
120 122
121 new_item_animation_->Reset(); 123 new_item_animation_->Reset();
122 new_item_animation_->Show(); 124 new_item_animation_->Show();
123 } 125 }
124 126
125 void DownloadShelfView::DoAddDownload(DownloadItem* download) { 127 void DownloadShelfView::DoAddDownload(DownloadItem* download) {
126 DownloadItemView* view = new DownloadItemView(download, this); 128 DownloadItemView* view = new DownloadItemView(download, this);
127 AddDownloadView(view); 129 AddDownloadView(view);
(...skipping 14 matching lines...) Expand all
142 if (download_views_.empty()) 144 if (download_views_.empty())
143 Close(AUTOMATIC); 145 Close(AUTOMATIC);
144 else if (CanAutoClose()) 146 else if (CanAutoClose())
145 mouse_watcher_.Start(); 147 mouse_watcher_.Start();
146 Layout(); 148 Layout();
147 SchedulePaint(); 149 SchedulePaint();
148 } 150 }
149 151
150 views::View* DownloadShelfView::GetDefaultFocusableChild() { 152 views::View* DownloadShelfView::GetDefaultFocusableChild() {
151 return download_views_.empty() ? 153 return download_views_.empty() ?
152 static_cast<View*>(show_all_view_) : download_views_[0]; 154 static_cast<View*>(show_all_view_) :
155 download_views_[download_views_.size() - 1];
Peter Kasting 2014/05/22 18:23:14 Nit: download_views_.back()
153 } 156 }
154 157
155 void DownloadShelfView::OnPaintBorder(gfx::Canvas* canvas) { 158 void DownloadShelfView::OnPaintBorder(gfx::Canvas* canvas) {
156 canvas->FillRect(gfx::Rect(0, 0, width(), 1), kBorderColor); 159 canvas->FillRect(gfx::Rect(0, 0, width(), 1), kBorderColor);
157 } 160 }
158 161
159 void DownloadShelfView::OpenedDownload(DownloadItemView* view) { 162 void DownloadShelfView::OpenedDownload(DownloadItemView* view) {
160 if (CanAutoClose()) 163 if (CanAutoClose())
161 mouse_watcher_.Start(); 164 mouse_watcher_.Start();
162 } 165 }
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 } 417 }
415 } 418 }
416 419
417 bool DownloadShelfView::CanAutoClose() { 420 bool DownloadShelfView::CanAutoClose() {
418 for (size_t i = 0; i < download_views_.size(); ++i) { 421 for (size_t i = 0; i < download_views_.size(); ++i) {
419 if (!download_views_[i]->download()->GetOpened()) 422 if (!download_views_[i]->download()->GetOpened())
420 return false; 423 return false;
421 } 424 }
422 return true; 425 return true;
423 } 426 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698