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

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

Issue 11673004: No need to pass DownloadItemModel ownership. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: DownloadShelfContextMenu class cleanup and require GetMenuModel() to return non-NULL Created 7 years, 11 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 // A ChromeView that implements one download on the Download shelf. 5 // A ChromeView that implements one download on the Download shelf.
6 // Each DownloadItemView contains an application icon, a text label 6 // Each DownloadItemView 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 DownloadItemView lives in the Browser, and has a corresponding 12 // The DownloadItemView 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_H__ 16 #ifndef CHROME_BROWSER_UI_VIEWS_DOWNLOAD_DOWNLOAD_ITEM_VIEW_H__
17 #define CHROME_BROWSER_UI_VIEWS_DOWNLOAD_DOWNLOAD_ITEM_VIEW_H__ 17 #define CHROME_BROWSER_UI_VIEWS_DOWNLOAD_DOWNLOAD_ITEM_VIEW_H__
18 18
19 #include <string> 19 #include <string>
20 20
21 #include "base/basictypes.h" 21 #include "base/basictypes.h"
22 #include "base/memory/scoped_ptr.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/string_util.h" 24 #include "base/string_util.h"
25 #include "base/time.h" 25 #include "base/time.h"
26 #include "base/timer.h" 26 #include "base/timer.h"
27 #include "chrome/browser/common/cancelable_request.h" 27 #include "chrome/browser/common/cancelable_request.h"
28 #include "chrome/browser/download/download_item_model.h"
28 #include "chrome/browser/icon_manager.h" 29 #include "chrome/browser/icon_manager.h"
29 #include "content/public/browser/download_item.h" 30 #include "content/public/browser/download_item.h"
30 #include "content/public/browser/download_manager.h" 31 #include "content/public/browser/download_manager.h"
31 #include "ui/base/animation/animation_delegate.h" 32 #include "ui/base/animation/animation_delegate.h"
32 #include "ui/gfx/font.h" 33 #include "ui/gfx/font.h"
33 #include "ui/views/context_menu_controller.h" 34 #include "ui/views/context_menu_controller.h"
34 #include "ui/views/controls/button/button.h" 35 #include "ui/views/controls/button/button.h"
35 #include "ui/views/view.h" 36 #include "ui/views/view.h"
36 37
37 class DownloadItemModel;
38 class DownloadShelfView; 38 class DownloadShelfView;
39 class DownloadShelfContextMenuView; 39 class DownloadShelfContextMenuView;
40 40
41 namespace gfx { 41 namespace gfx {
42 class Image; 42 class Image;
43 class ImageSkia; 43 class ImageSkia;
44 } 44 }
45 45
46 namespace ui { 46 namespace ui {
47 class SlideAnimation; 47 class SlideAnimation;
48 } 48 }
49 49
50 namespace views { 50 namespace views {
51 class Label; 51 class Label;
52 class TextButton; 52 class TextButton;
53 } 53 }
54 54
55 class DownloadItemView : public views::ButtonListener, 55 class DownloadItemView : public views::ButtonListener,
56 public views::View, 56 public views::View,
57 public views::ContextMenuController, 57 public views::ContextMenuController,
58 public content::DownloadItem::Observer, 58 public content::DownloadItem::Observer,
59 public ui::AnimationDelegate { 59 public ui::AnimationDelegate {
60 public: 60 public:
61 DownloadItemView(content::DownloadItem* download, 61 DownloadItemView(content::DownloadItem* download,
62 DownloadShelfView* parent, 62 DownloadShelfView* parent);
63 DownloadItemModel* model);
64 virtual ~DownloadItemView(); 63 virtual ~DownloadItemView();
65 64
66 // Timer callback for handling animations 65 // Timer callback for handling animations
67 void UpdateDownloadProgress(); 66 void UpdateDownloadProgress();
68 void StartDownloadProgress(); 67 void StartDownloadProgress();
69 void StopDownloadProgress(); 68 void StopDownloadProgress();
70 69
71 // IconManager::Client interface. 70 // IconManager::Client interface.
72 void OnExtractIconComplete(gfx::Image* icon); 71 void OnExtractIconComplete(gfx::Image* icon);
73 72
74 // Returns the DownloadItem model object belonging to this item. 73 // Returns the DownloadItem model object belonging to this item.
75 content::DownloadItem* download() const { return download_; } 74 content::DownloadItem* download() { return model_.download(); }
76 75
77 // DownloadItem::Observer methods 76 // DownloadItem::Observer methods
78 virtual void OnDownloadUpdated(content::DownloadItem* download) OVERRIDE; 77 virtual void OnDownloadUpdated(content::DownloadItem* download) OVERRIDE;
79 virtual void OnDownloadOpened(content::DownloadItem* download) OVERRIDE; 78 virtual void OnDownloadOpened(content::DownloadItem* download) OVERRIDE;
80 virtual void OnDownloadDestroyed(content::DownloadItem* download) OVERRIDE; 79 virtual void OnDownloadDestroyed(content::DownloadItem* download) OVERRIDE;
81 80
82 // Overridden from views::View: 81 // Overridden from views::View:
83 virtual void Layout() OVERRIDE; 82 virtual void Layout() OVERRIDE;
84 virtual gfx::Size GetPreferredSize() OVERRIDE; 83 virtual gfx::Size GetPreferredSize() OVERRIDE;
85 virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE; 84 virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE;
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 BodyImageSet pushed_body_image_set_; 225 BodyImageSet pushed_body_image_set_;
227 BodyImageSet dangerous_mode_body_image_set_; 226 BodyImageSet dangerous_mode_body_image_set_;
228 BodyImageSet malicious_mode_body_image_set_; 227 BodyImageSet malicious_mode_body_image_set_;
229 DropDownImageSet normal_drop_down_image_set_; 228 DropDownImageSet normal_drop_down_image_set_;
230 DropDownImageSet hot_drop_down_image_set_; 229 DropDownImageSet hot_drop_down_image_set_;
231 DropDownImageSet pushed_drop_down_image_set_; 230 DropDownImageSet pushed_drop_down_image_set_;
232 231
233 // The warning icon showns for dangerous downloads. 232 // The warning icon showns for dangerous downloads.
234 const gfx::ImageSkia* warning_icon_; 233 const gfx::ImageSkia* warning_icon_;
235 234
236 // The model we query for display information
237 content::DownloadItem* download_;
238
239 // The download shelf that owns us. 235 // The download shelf that owns us.
240 DownloadShelfView* shelf_; 236 DownloadShelfView* shelf_;
241 237
242 // Elements of our particular download 238 // Elements of our particular download
243 string16 status_text_; 239 string16 status_text_;
244 240
245 // The font used to print the file name and status. 241 // The font used to print the file name and status.
246 gfx::Font font_; 242 gfx::Font font_;
247 243
248 // The tooltip. Only displayed when not showing a warning dialog. 244 // The tooltip. Only displayed when not showing a warning dialog.
(...skipping 27 matching lines...) Expand all
276 272
277 // Whether we are tracking a possible drag. 273 // Whether we are tracking a possible drag.
278 bool starting_drag_; 274 bool starting_drag_;
279 275
280 // Position that a possible drag started at. 276 // Position that a possible drag started at.
281 gfx::Point drag_start_point_; 277 gfx::Point drag_start_point_;
282 278
283 // For canceling an in progress icon request. 279 // For canceling an in progress icon request.
284 CancelableTaskTracker cancelable_task_tracker_; 280 CancelableTaskTracker cancelable_task_tracker_;
285 281
286 // A model class to control the status text we display and the cancel 282 // A model class to control the status text we display.
287 // behavior. 283 DownloadItemModel model_;
288 // This class owns the pointer.
289 scoped_ptr<DownloadItemModel> model_;
290 284
291 // Hover animations for our body and drop buttons. 285 // Hover animations for our body and drop buttons.
292 scoped_ptr<ui::SlideAnimation> body_hover_animation_; 286 scoped_ptr<ui::SlideAnimation> body_hover_animation_;
293 scoped_ptr<ui::SlideAnimation> drop_hover_animation_; 287 scoped_ptr<ui::SlideAnimation> drop_hover_animation_;
294 288
295 // Animation for download complete. 289 // Animation for download complete.
296 scoped_ptr<ui::SlideAnimation> complete_animation_; 290 scoped_ptr<ui::SlideAnimation> complete_animation_;
297 291
298 // Progress animation 292 // Progress animation
299 base::RepeatingTimer<DownloadItemView> progress_timer_; 293 base::RepeatingTimer<DownloadItemView> progress_timer_;
(...skipping 29 matching lines...) Expand all
329 323
330 // The icon loaded in the download shelf is based on the file path of the 324 // The icon loaded in the download shelf is based on the file path of the
331 // item. Store the path used, so that we can detect a change in the path 325 // item. Store the path used, so that we can detect a change in the path
332 // and reload the icon. 326 // and reload the icon.
333 FilePath last_download_item_path_; 327 FilePath last_download_item_path_;
334 328
335 DISALLOW_COPY_AND_ASSIGN(DownloadItemView); 329 DISALLOW_COPY_AND_ASSIGN(DownloadItemView);
336 }; 330 };
337 331
338 #endif // CHROME_BROWSER_UI_VIEWS_DOWNLOAD_DOWNLOAD_ITEM_VIEW_H__ 332 #endif // CHROME_BROWSER_UI_VIEWS_DOWNLOAD_DOWNLOAD_ITEM_VIEW_H__
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/download/download_shelf_gtk.cc ('k') | chrome/browser/ui/views/download/download_item_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698