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

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

Issue 14307023: chrome: Use base::MessageLoop. (Part 2) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 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
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_item_view.h" 5 #include "chrome/browser/ui/views/download/download_item_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 shelf_->SchedulePaint(); 308 shelf_->SchedulePaint();
309 } 309 }
310 310
311 void DownloadItemView::OnDownloadDestroyed(DownloadItem* download) { 311 void DownloadItemView::OnDownloadDestroyed(DownloadItem* download) {
312 shelf_->RemoveDownloadView(this); // This will delete us! 312 shelf_->RemoveDownloadView(this); // This will delete us!
313 } 313 }
314 314
315 void DownloadItemView::OnDownloadOpened(DownloadItem* download) { 315 void DownloadItemView::OnDownloadOpened(DownloadItem* download) {
316 disabled_while_opening_ = true; 316 disabled_while_opening_ = true;
317 SetEnabled(false); 317 SetEnabled(false);
318 MessageLoop::current()->PostDelayedTask( 318 base::MessageLoop::current()->PostDelayedTask(
319 FROM_HERE, 319 FROM_HERE,
320 base::Bind(&DownloadItemView::Reenable, 320 base::Bind(&DownloadItemView::Reenable, weak_ptr_factory_.GetWeakPtr()),
321 weak_ptr_factory_.GetWeakPtr()),
322 base::TimeDelta::FromMilliseconds(kDisabledOnOpenDuration)); 321 base::TimeDelta::FromMilliseconds(kDisabledOnOpenDuration));
323 322
324 // Notify our parent. 323 // Notify our parent.
325 shelf_->OpenedDownload(this); 324 shelf_->OpenedDownload(this);
326 } 325 }
327 326
328 // View overrides 327 // View overrides
329 328
330 // In dangerous mode we have to layout our buttons. 329 // In dangerous mode we have to layout our buttons.
331 void DownloadItemView::Layout() { 330 void DownloadItemView::Layout() {
(...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after
887 // to drop down arrow button. 886 // to drop down arrow button.
888 if (!is_mouse_gesture) { 887 if (!is_mouse_gesture) {
889 drop_down_pressed_ = true; 888 drop_down_pressed_ = true;
890 SetState(NORMAL, PUSHED); 889 SetState(NORMAL, PUSHED);
891 point.SetPoint(drop_down_x_left_, box_y_); 890 point.SetPoint(drop_down_x_left_, box_y_);
892 size.SetSize(drop_down_x_right_ - drop_down_x_left_, box_height_); 891 size.SetSize(drop_down_x_right_ - drop_down_x_left_, box_height_);
893 } 892 }
894 // Post a task to release the button. When we call the Run method on the menu 893 // Post a task to release the button. When we call the Run method on the menu
895 // below, it runs an inner message loop that might cause us to be deleted. 894 // below, it runs an inner message loop that might cause us to be deleted.
896 // Posting a task with a WeakPtr lets us safely handle the button release. 895 // Posting a task with a WeakPtr lets us safely handle the button release.
897 MessageLoop::current()->PostNonNestableTask( 896 base::MessageLoop::current()->PostNonNestableTask(
898 FROM_HERE, 897 FROM_HERE,
899 base::Bind(&DownloadItemView::ReleaseDropDown, 898 base::Bind(&DownloadItemView::ReleaseDropDown,
900 weak_ptr_factory_.GetWeakPtr())); 899 weak_ptr_factory_.GetWeakPtr()));
901 views::View::ConvertPointToScreen(this, &point); 900 views::View::ConvertPointToScreen(this, &point);
902 901
903 if (!context_menu_.get()) { 902 if (!context_menu_.get()) {
904 context_menu_.reset( 903 context_menu_.reset(
905 new DownloadShelfContextMenuView(download(), shelf_->GetNavigator())); 904 new DownloadShelfContextMenuView(download(), shelf_->GetNavigator()));
906 } 905 }
907 context_menu_->Run(GetWidget()->GetTopLevelWidget(), 906 context_menu_->Run(GetWidget()->GetTopLevelWidget(),
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
1213 void DownloadItemView::AnimateStateTransition(State from, State to, 1212 void DownloadItemView::AnimateStateTransition(State from, State to,
1214 ui::SlideAnimation* animation) { 1213 ui::SlideAnimation* animation) {
1215 if (from == NORMAL && to == HOT) { 1214 if (from == NORMAL && to == HOT) {
1216 animation->Show(); 1215 animation->Show();
1217 } else if (from == HOT && to == NORMAL) { 1216 } else if (from == HOT && to == NORMAL) {
1218 animation->Hide(); 1217 animation->Hide();
1219 } else if (from != to) { 1218 } else if (from != to) {
1220 animation->Reset((to == HOT) ? 1.0 : 0.0); 1219 animation->Reset((to == HOT) ? 1.0 : 0.0);
1221 } 1220 }
1222 } 1221 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698