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_item_view_md.h" | 5 #include "chrome/browser/ui/views/download/download_item_view_md.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/callback.h" | 13 #include "base/callback.h" |
14 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
15 #include "base/i18n/break_iterator.h" | 15 #include "base/i18n/break_iterator.h" |
16 #include "base/i18n/rtl.h" | 16 #include "base/i18n/rtl.h" |
17 #include "base/location.h" | 17 #include "base/location.h" |
18 #include "base/macros.h" | 18 #include "base/macros.h" |
| 19 #include "base/memory/ptr_util.h" |
19 #include "base/metrics/histogram.h" | 20 #include "base/metrics/histogram.h" |
20 #include "base/strings/string_util.h" | 21 #include "base/strings/string_util.h" |
21 #include "base/strings/stringprintf.h" | 22 #include "base/strings/stringprintf.h" |
22 #include "base/strings/sys_string_conversions.h" | 23 #include "base/strings/sys_string_conversions.h" |
23 #include "base/strings/utf_string_conversions.h" | 24 #include "base/strings/utf_string_conversions.h" |
24 #include "chrome/browser/browser_process.h" | 25 #include "chrome/browser/browser_process.h" |
25 #include "chrome/browser/download/chrome_download_manager_delegate.h" | 26 #include "chrome/browser/download/chrome_download_manager_delegate.h" |
26 #include "chrome/browser/download/download_item_model.h" | 27 #include "chrome/browser/download/download_item_model.h" |
27 #include "chrome/browser/download/download_stats.h" | 28 #include "chrome/browser/download/download_stats.h" |
28 #include "chrome/browser/download/drag_download_item.h" | 29 #include "chrome/browser/download/drag_download_item.h" |
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
465 SchedulePaint(); | 466 SchedulePaint(); |
466 } | 467 } |
467 | 468 |
468 void DownloadItemViewMd::AddInkDropLayer(ui::Layer* ink_drop_layer) { | 469 void DownloadItemViewMd::AddInkDropLayer(ui::Layer* ink_drop_layer) { |
469 InkDropHostView::AddInkDropLayer(ink_drop_layer); | 470 InkDropHostView::AddInkDropLayer(ink_drop_layer); |
470 // The layer that's added to host the ink drop layer must mask to bounds | 471 // The layer that's added to host the ink drop layer must mask to bounds |
471 // so the hover effect is clipped while animating open. | 472 // so the hover effect is clipped while animating open. |
472 layer()->SetMasksToBounds(true); | 473 layer()->SetMasksToBounds(true); |
473 } | 474 } |
474 | 475 |
475 scoped_ptr<views::InkDropAnimation> DownloadItemViewMd::CreateInkDropAnimation() | 476 std::unique_ptr<views::InkDropAnimation> |
476 const { | 477 DownloadItemViewMd::CreateInkDropAnimation() const { |
477 return make_scoped_ptr(new views::FloodFillInkDropAnimation( | 478 return base::WrapUnique(new views::FloodFillInkDropAnimation( |
478 size(), ink_drop_delegate_.last_ink_drop_location(), | 479 size(), ink_drop_delegate_.last_ink_drop_location(), |
479 color_utils::DeriveDefaultIconColor(GetTextColor()))); | 480 color_utils::DeriveDefaultIconColor(GetTextColor()))); |
480 } | 481 } |
481 | 482 |
482 scoped_ptr<views::InkDropHover> DownloadItemViewMd::CreateInkDropHover() const { | 483 std::unique_ptr<views::InkDropHover> DownloadItemViewMd::CreateInkDropHover() |
| 484 const { |
483 if (IsShowingWarningDialog()) | 485 if (IsShowingWarningDialog()) |
484 return nullptr; | 486 return nullptr; |
485 | 487 |
486 gfx::Size size = GetPreferredSize(); | 488 gfx::Size size = GetPreferredSize(); |
487 return make_scoped_ptr(new views::InkDropHover( | 489 return base::WrapUnique(new views::InkDropHover( |
488 size, kInkDropSmallCornerRadius, gfx::Rect(size).CenterPoint(), | 490 size, kInkDropSmallCornerRadius, gfx::Rect(size).CenterPoint(), |
489 color_utils::DeriveDefaultIconColor(GetTextColor()))); | 491 color_utils::DeriveDefaultIconColor(GetTextColor()))); |
490 } | 492 } |
491 | 493 |
492 void DownloadItemViewMd::OnGestureEvent(ui::GestureEvent* event) { | 494 void DownloadItemViewMd::OnGestureEvent(ui::GestureEvent* event) { |
493 if (event->type() == ui::ET_GESTURE_TAP_DOWN) { | 495 if (event->type() == ui::ET_GESTURE_TAP_DOWN) { |
494 HandlePressEvent(*event, true); | 496 HandlePressEvent(*event, true); |
495 event->SetHandled(); | 497 event->SetHandled(); |
496 return; | 498 return; |
497 } | 499 } |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
786 | 788 |
787 LoadIcon(); | 789 LoadIcon(); |
788 } | 790 } |
789 | 791 |
790 void DownloadItemViewMd::UpdateColorsFromTheme() { | 792 void DownloadItemViewMd::UpdateColorsFromTheme() { |
791 if (!GetThemeProvider()) | 793 if (!GetThemeProvider()) |
792 return; | 794 return; |
793 | 795 |
794 if (dangerous_download_label_) | 796 if (dangerous_download_label_) |
795 dangerous_download_label_->SetEnabledColor(GetTextColor()); | 797 dangerous_download_label_->SetEnabledColor(GetTextColor()); |
796 SetBorder(make_scoped_ptr(new SeparatorBorder( | 798 SetBorder(base::WrapUnique(new SeparatorBorder(GetThemeProvider()->GetColor( |
797 GetThemeProvider()->GetColor( | 799 ThemeProperties::COLOR_TOOLBAR_BOTTOM_SEPARATOR)))); |
798 ThemeProperties::COLOR_TOOLBAR_BOTTOM_SEPARATOR)))); | |
799 } | 800 } |
800 | 801 |
801 void DownloadItemViewMd::ShowContextMenuImpl(const gfx::Rect& rect, | 802 void DownloadItemViewMd::ShowContextMenuImpl(const gfx::Rect& rect, |
802 ui::MenuSourceType source_type) { | 803 ui::MenuSourceType source_type) { |
803 // Similar hack as in MenuButton. | 804 // Similar hack as in MenuButton. |
804 // We're about to show the menu from a mouse press. By showing from the | 805 // We're about to show the menu from a mouse press. By showing from the |
805 // mouse press event we block RootView in mouse dispatching. This also | 806 // mouse press event we block RootView in mouse dispatching. This also |
806 // appears to cause RootView to get a mouse pressed BEFORE the mouse | 807 // appears to cause RootView to get a mouse pressed BEFORE the mouse |
807 // release is seen, which means RootView sends us another mouse press no | 808 // release is seen, which means RootView sends us another mouse press no |
808 // matter where the user pressed. To force RootView to recalculate the | 809 // matter where the user pressed. To force RootView to recalculate the |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1112 SchedulePaint(); | 1113 SchedulePaint(); |
1113 } | 1114 } |
1114 | 1115 |
1115 SkColor DownloadItemViewMd::GetTextColor() const { | 1116 SkColor DownloadItemViewMd::GetTextColor() const { |
1116 return GetTextColorForThemeProvider(GetThemeProvider()); | 1117 return GetTextColorForThemeProvider(GetThemeProvider()); |
1117 } | 1118 } |
1118 | 1119 |
1119 SkColor DownloadItemViewMd::GetDimmedTextColor() const { | 1120 SkColor DownloadItemViewMd::GetDimmedTextColor() const { |
1120 return SkColorSetA(GetTextColor(), 0xC7); | 1121 return SkColorSetA(GetTextColor(), 0xC7); |
1121 } | 1122 } |
OLD | NEW |