| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 // A view that implements one download on the Download shelf. | 5 // A view that implements one download on the Download shelf. |
| 6 // Each DownloadItemViewMd contains an application icon, a text label | 6 // Each DownloadItemViewMd contains an application icon, a text label |
| 7 // indicating the download's file name, a text label indicating the | 7 // indicating the download's file name, a text label indicating the |
| 8 // download's status (such as the number of bytes downloaded so far) | 8 // download's status (such as the number of bytes downloaded so far) |
| 9 // and a button for canceling an in progress download, or opening | 9 // and a button for canceling an in progress download, or opening |
| 10 // the completed download. | 10 // the completed download. |
| 11 // | 11 // |
| 12 // The DownloadItemViewMd lives in the Browser, and has a corresponding | 12 // The DownloadItemViewMd lives in the Browser, and has a corresponding |
| 13 // DownloadController that receives / writes data which lives in the | 13 // DownloadController that receives / writes data which lives in the |
| 14 // Renderer. | 14 // Renderer. |
| 15 | 15 |
| 16 #ifndef CHROME_BROWSER_UI_VIEWS_DOWNLOAD_DOWNLOAD_ITEM_VIEW_MD_H_ | 16 #ifndef CHROME_BROWSER_UI_VIEWS_DOWNLOAD_DOWNLOAD_ITEM_VIEW_MD_H_ |
| 17 #define CHROME_BROWSER_UI_VIEWS_DOWNLOAD_DOWNLOAD_ITEM_VIEW_MD_H_ | 17 #define CHROME_BROWSER_UI_VIEWS_DOWNLOAD_DOWNLOAD_ITEM_VIEW_MD_H_ |
| 18 | 18 |
| 19 #include <memory> |
| 19 #include <string> | 20 #include <string> |
| 20 | 21 |
| 21 #include "base/macros.h" | 22 #include "base/macros.h" |
| 22 #include "base/memory/scoped_ptr.h" | |
| 23 #include "base/memory/weak_ptr.h" | 23 #include "base/memory/weak_ptr.h" |
| 24 #include "base/strings/string_util.h" | 24 #include "base/strings/string_util.h" |
| 25 #include "base/task/cancelable_task_tracker.h" | 25 #include "base/task/cancelable_task_tracker.h" |
| 26 #include "base/time/time.h" | 26 #include "base/time/time.h" |
| 27 #include "base/timer/timer.h" | 27 #include "base/timer/timer.h" |
| 28 #include "chrome/browser/download/download_item_model.h" | 28 #include "chrome/browser/download/download_item_model.h" |
| 29 #include "chrome/browser/icon_manager.h" | 29 #include "chrome/browser/icon_manager.h" |
| 30 #include "content/public/browser/download_item.h" | 30 #include "content/public/browser/download_item.h" |
| 31 #include "content/public/browser/download_manager.h" | 31 #include "content/public/browser/download_manager.h" |
| 32 #include "ui/gfx/animation/animation_delegate.h" | 32 #include "ui/gfx/animation/animation_delegate.h" |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 void OnMouseReleased(const ui::MouseEvent& event) override; | 99 void OnMouseReleased(const ui::MouseEvent& event) override; |
| 100 void OnMouseCaptureLost() override; | 100 void OnMouseCaptureLost() override; |
| 101 bool OnKeyPressed(const ui::KeyEvent& event) override; | 101 bool OnKeyPressed(const ui::KeyEvent& event) override; |
| 102 bool GetTooltipText(const gfx::Point& p, | 102 bool GetTooltipText(const gfx::Point& p, |
| 103 base::string16* tooltip) const override; | 103 base::string16* tooltip) const override; |
| 104 void GetAccessibleState(ui::AXViewState* state) override; | 104 void GetAccessibleState(ui::AXViewState* state) override; |
| 105 void OnThemeChanged() override; | 105 void OnThemeChanged() override; |
| 106 | 106 |
| 107 // Overridden from view::InkDropHostView: | 107 // Overridden from view::InkDropHostView: |
| 108 void AddInkDropLayer(ui::Layer* ink_drop_layer) override; | 108 void AddInkDropLayer(ui::Layer* ink_drop_layer) override; |
| 109 scoped_ptr<views::InkDropAnimation> CreateInkDropAnimation() const override; | 109 std::unique_ptr<views::InkDropAnimation> CreateInkDropAnimation() |
| 110 scoped_ptr<views::InkDropHover> CreateInkDropHover() const override; | 110 const override; |
| 111 std::unique_ptr<views::InkDropHover> CreateInkDropHover() const override; |
| 111 | 112 |
| 112 // Overridden from ui::EventHandler: | 113 // Overridden from ui::EventHandler: |
| 113 void OnGestureEvent(ui::GestureEvent* event) override; | 114 void OnGestureEvent(ui::GestureEvent* event) override; |
| 114 | 115 |
| 115 // Overridden from views::ContextMenuController. | 116 // Overridden from views::ContextMenuController. |
| 116 void ShowContextMenuForView(View* source, | 117 void ShowContextMenuForView(View* source, |
| 117 const gfx::Point& point, | 118 const gfx::Point& point, |
| 118 ui::MenuSourceType source_type) override; | 119 ui::MenuSourceType source_type) override; |
| 119 | 120 |
| 120 // ButtonListener implementation. | 121 // ButtonListener implementation. |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 // Position that a possible drag started at. | 270 // Position that a possible drag started at. |
| 270 gfx::Point drag_start_point_; | 271 gfx::Point drag_start_point_; |
| 271 | 272 |
| 272 // For canceling an in progress icon request. | 273 // For canceling an in progress icon request. |
| 273 base::CancelableTaskTracker cancelable_task_tracker_; | 274 base::CancelableTaskTracker cancelable_task_tracker_; |
| 274 | 275 |
| 275 // A model class to control the status text we display. | 276 // A model class to control the status text we display. |
| 276 DownloadItemModel model_; | 277 DownloadItemModel model_; |
| 277 | 278 |
| 278 // Animation for download complete. | 279 // Animation for download complete. |
| 279 scoped_ptr<gfx::SlideAnimation> complete_animation_; | 280 std::unique_ptr<gfx::SlideAnimation> complete_animation_; |
| 280 | 281 |
| 281 views::ButtonInkDropDelegate ink_drop_delegate_; | 282 views::ButtonInkDropDelegate ink_drop_delegate_; |
| 282 | 283 |
| 283 // Progress animation | 284 // Progress animation |
| 284 base::RepeatingTimer progress_timer_; | 285 base::RepeatingTimer progress_timer_; |
| 285 | 286 |
| 286 // Dangerous mode buttons. | 287 // Dangerous mode buttons. |
| 287 views::LabelButton* save_button_; | 288 views::LabelButton* save_button_; |
| 288 views::LabelButton* discard_button_; | 289 views::LabelButton* discard_button_; |
| 289 | 290 |
| 290 // The drop down button. | 291 // The drop down button. |
| 291 BarControlButton* dropdown_button_; | 292 BarControlButton* dropdown_button_; |
| 292 | 293 |
| 293 // Dangerous mode label. | 294 // Dangerous mode label. |
| 294 views::Label* dangerous_download_label_; | 295 views::Label* dangerous_download_label_; |
| 295 | 296 |
| 296 // Whether the dangerous mode label has been sized yet. | 297 // Whether the dangerous mode label has been sized yet. |
| 297 bool dangerous_download_label_sized_; | 298 bool dangerous_download_label_sized_; |
| 298 | 299 |
| 299 // Whether we are currently disabled as part of opening the downloaded file. | 300 // Whether we are currently disabled as part of opening the downloaded file. |
| 300 bool disabled_while_opening_; | 301 bool disabled_while_opening_; |
| 301 | 302 |
| 302 // The time at which this view was created. | 303 // The time at which this view was created. |
| 303 base::Time creation_time_; | 304 base::Time creation_time_; |
| 304 | 305 |
| 305 // The time at which a dangerous download warning was displayed. | 306 // The time at which a dangerous download warning was displayed. |
| 306 base::Time time_download_warning_shown_; | 307 base::Time time_download_warning_shown_; |
| 307 | 308 |
| 308 // The currently running download context menu. | 309 // The currently running download context menu. |
| 309 scoped_ptr<DownloadShelfContextMenuView> context_menu_; | 310 std::unique_ptr<DownloadShelfContextMenuView> context_menu_; |
| 310 | 311 |
| 311 // The name of this view as reported to assistive technology. | 312 // The name of this view as reported to assistive technology. |
| 312 base::string16 accessible_name_; | 313 base::string16 accessible_name_; |
| 313 | 314 |
| 314 // The icon loaded in the download shelf is based on the file path of the | 315 // The icon loaded in the download shelf is based on the file path of the |
| 315 // item. Store the path used, so that we can detect a change in the path | 316 // item. Store the path used, so that we can detect a change in the path |
| 316 // and reload the icon. | 317 // and reload the icon. |
| 317 base::FilePath last_download_item_path_; | 318 base::FilePath last_download_item_path_; |
| 318 | 319 |
| 319 // ExperienceSampling: This tracks dangerous/malicious downloads warning UI | 320 // ExperienceSampling: This tracks dangerous/malicious downloads warning UI |
| 320 // and the user's decisions about it. | 321 // and the user's decisions about it. |
| 321 scoped_ptr<extensions::ExperienceSamplingEvent> sampling_event_; | 322 std::unique_ptr<extensions::ExperienceSamplingEvent> sampling_event_; |
| 322 | 323 |
| 323 // Method factory used to delay reenabling of the item when opening the | 324 // Method factory used to delay reenabling of the item when opening the |
| 324 // downloaded file. | 325 // downloaded file. |
| 325 base::WeakPtrFactory<DownloadItemViewMd> weak_ptr_factory_; | 326 base::WeakPtrFactory<DownloadItemViewMd> weak_ptr_factory_; |
| 326 | 327 |
| 327 DISALLOW_COPY_AND_ASSIGN(DownloadItemViewMd); | 328 DISALLOW_COPY_AND_ASSIGN(DownloadItemViewMd); |
| 328 }; | 329 }; |
| 329 | 330 |
| 330 #endif // CHROME_BROWSER_UI_VIEWS_DOWNLOAD_DOWNLOAD_ITEM_VIEW_MD_H_ | 331 #endif // CHROME_BROWSER_UI_VIEWS_DOWNLOAD_DOWNLOAD_ITEM_VIEW_MD_H_ |
| OLD | NEW |