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

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

Issue 1160073004: chrome/browser/ui: Remove use of MessageLoopProxy and deprecated MessageLoop APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Harmonize MessageLoop/TTRH usage. Created 5 years, 6 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_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"
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/files/file_path.h" 12 #include "base/files/file_path.h"
13 #include "base/i18n/break_iterator.h" 13 #include "base/i18n/break_iterator.h"
14 #include "base/i18n/rtl.h" 14 #include "base/i18n/rtl.h"
15 #include "base/location.h"
15 #include "base/metrics/histogram.h" 16 #include "base/metrics/histogram.h"
16 #include "base/prefs/pref_service.h" 17 #include "base/prefs/pref_service.h"
18 #include "base/single_thread_task_runner.h"
msw 2015/06/12 00:31:21 nit: remove sttr and ttrh headers.
Sami 2015/06/12 10:56:22 Done.
17 #include "base/strings/string_util.h" 19 #include "base/strings/string_util.h"
18 #include "base/strings/stringprintf.h" 20 #include "base/strings/stringprintf.h"
19 #include "base/strings/sys_string_conversions.h" 21 #include "base/strings/sys_string_conversions.h"
20 #include "base/strings/utf_string_conversions.h" 22 #include "base/strings/utf_string_conversions.h"
23 #include "base/thread_task_runner_handle.h"
21 #include "chrome/browser/browser_process.h" 24 #include "chrome/browser/browser_process.h"
22 #include "chrome/browser/download/chrome_download_manager_delegate.h" 25 #include "chrome/browser/download/chrome_download_manager_delegate.h"
23 #include "chrome/browser/download/download_item_model.h" 26 #include "chrome/browser/download/download_item_model.h"
24 #include "chrome/browser/download/download_stats.h" 27 #include "chrome/browser/download/download_stats.h"
25 #include "chrome/browser/download/drag_download_item.h" 28 #include "chrome/browser/download/drag_download_item.h"
26 #include "chrome/browser/extensions/api/experience_sampling_private/experience_s ampling.h" 29 #include "chrome/browser/extensions/api/experience_sampling_private/experience_s ampling.h"
27 #include "chrome/browser/profiles/profile.h" 30 #include "chrome/browser/profiles/profile.h"
28 #include "chrome/browser/safe_browsing/download_feedback_service.h" 31 #include "chrome/browser/safe_browsing/download_feedback_service.h"
29 #include "chrome/browser/safe_browsing/download_protection_service.h" 32 #include "chrome/browser/safe_browsing/download_protection_service.h"
30 #include "chrome/browser/safe_browsing/safe_browsing_service.h" 33 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 shelf_->SchedulePaint(); 346 shelf_->SchedulePaint();
344 } 347 }
345 348
346 void DownloadItemView::OnDownloadDestroyed(DownloadItem* download) { 349 void DownloadItemView::OnDownloadDestroyed(DownloadItem* download) {
347 shelf_->RemoveDownloadView(this); // This will delete us! 350 shelf_->RemoveDownloadView(this); // This will delete us!
348 } 351 }
349 352
350 void DownloadItemView::OnDownloadOpened(DownloadItem* download) { 353 void DownloadItemView::OnDownloadOpened(DownloadItem* download) {
351 disabled_while_opening_ = true; 354 disabled_while_opening_ = true;
352 SetEnabled(false); 355 SetEnabled(false);
353 base::MessageLoop::current()->PostDelayedTask( 356 base::MessageLoop::current()->task_runner()->PostDelayedTask(
354 FROM_HERE, 357 FROM_HERE,
355 base::Bind(&DownloadItemView::Reenable, weak_ptr_factory_.GetWeakPtr()), 358 base::Bind(&DownloadItemView::Reenable, weak_ptr_factory_.GetWeakPtr()),
356 base::TimeDelta::FromMilliseconds(kDisabledOnOpenDuration)); 359 base::TimeDelta::FromMilliseconds(kDisabledOnOpenDuration));
357 360
358 // Notify our parent. 361 // Notify our parent.
359 shelf_->OpenedDownload(this); 362 shelf_->OpenedDownload(this);
360 } 363 }
361 364
362 // View overrides 365 // View overrides
363 366
(...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after
1007 if (source_type != ui::MENU_SOURCE_MOUSE && 1010 if (source_type != ui::MENU_SOURCE_MOUSE &&
1008 source_type != ui::MENU_SOURCE_TOUCH) { 1011 source_type != ui::MENU_SOURCE_TOUCH) {
1009 drop_down_pressed_ = true; 1012 drop_down_pressed_ = true;
1010 SetState(NORMAL, PUSHED); 1013 SetState(NORMAL, PUSHED);
1011 point.SetPoint(drop_down_x_left_, box_y_); 1014 point.SetPoint(drop_down_x_left_, box_y_);
1012 size.SetSize(drop_down_x_right_ - drop_down_x_left_, box_height_); 1015 size.SetSize(drop_down_x_right_ - drop_down_x_left_, box_height_);
1013 } 1016 }
1014 // Post a task to release the button. When we call the Run method on the menu 1017 // Post a task to release the button. When we call the Run method on the menu
1015 // below, it runs an inner message loop that might cause us to be deleted. 1018 // below, it runs an inner message loop that might cause us to be deleted.
1016 // Posting a task with a WeakPtr lets us safely handle the button release. 1019 // Posting a task with a WeakPtr lets us safely handle the button release.
1017 base::MessageLoop::current()->PostNonNestableTask( 1020 base::MessageLoop::current()->task_runner()->PostNonNestableTask(
1018 FROM_HERE, 1021 FROM_HERE, base::Bind(&DownloadItemView::ReleaseDropDown,
1019 base::Bind(&DownloadItemView::ReleaseDropDown, 1022 weak_ptr_factory_.GetWeakPtr()));
1020 weak_ptr_factory_.GetWeakPtr()));
1021 views::View::ConvertPointToScreen(this, &point); 1023 views::View::ConvertPointToScreen(this, &point);
1022 1024
1023 if (!context_menu_.get()) 1025 if (!context_menu_.get())
1024 context_menu_.reset(new DownloadShelfContextMenuView(download())); 1026 context_menu_.reset(new DownloadShelfContextMenuView(download()));
1025 1027
1026 context_menu_->Run(GetWidget()->GetTopLevelWidget(), 1028 context_menu_->Run(GetWidget()->GetTopLevelWidget(),
1027 gfx::Rect(point, size), source_type); 1029 gfx::Rect(point, size), source_type);
1028 // We could be deleted now. 1030 // We could be deleted now.
1029 } 1031 }
1030 1032
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
1382 void DownloadItemView::AnimateStateTransition(State from, State to, 1384 void DownloadItemView::AnimateStateTransition(State from, State to,
1383 gfx::SlideAnimation* animation) { 1385 gfx::SlideAnimation* animation) {
1384 if (from == NORMAL && to == HOT) { 1386 if (from == NORMAL && to == HOT) {
1385 animation->Show(); 1387 animation->Show();
1386 } else if (from == HOT && to == NORMAL) { 1388 } else if (from == HOT && to == NORMAL) {
1387 animation->Hide(); 1389 animation->Hide();
1388 } else if (from != to) { 1390 } else if (from != to) {
1389 animation->Reset((to == HOT) ? 1.0 : 0.0); 1391 animation->Reset((to == HOT) ? 1.0 : 0.0);
1390 } 1392 }
1391 } 1393 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698