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

Side by Side Diff: chrome/browser/ui/gtk/download/download_item_gtk.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 #ifndef CHROME_BROWSER_UI_GTK_DOWNLOAD_DOWNLOAD_ITEM_GTK_H_ 5 #ifndef CHROME_BROWSER_UI_GTK_DOWNLOAD_DOWNLOAD_ITEM_GTK_H_
6 #define CHROME_BROWSER_UI_GTK_DOWNLOAD_DOWNLOAD_ITEM_GTK_H_ 6 #define CHROME_BROWSER_UI_GTK_DOWNLOAD_DOWNLOAD_ITEM_GTK_H_
7 7
8 #include <gtk/gtk.h> 8 #include <gtk/gtk.h>
9 9
10 #include <string> 10 #include <string>
11 11
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
15 #include "base/time.h" 15 #include "base/time.h"
16 #include "base/timer.h" 16 #include "base/timer.h"
17 #include "chrome/browser/download/download_item_model.h"
17 #include "chrome/browser/icon_manager.h" 18 #include "chrome/browser/icon_manager.h"
18 #include "chrome/common/cancelable_task_tracker.h" 19 #include "chrome/common/cancelable_task_tracker.h"
19 #include "content/public/browser/download_item.h" 20 #include "content/public/browser/download_item.h"
20 #include "content/public/browser/notification_observer.h" 21 #include "content/public/browser/notification_observer.h"
21 #include "content/public/browser/notification_registrar.h" 22 #include "content/public/browser/notification_registrar.h"
22 #include "ui/base/animation/animation_delegate.h" 23 #include "ui/base/animation/animation_delegate.h"
23 #include "ui/base/animation/slide_animation.h" 24 #include "ui/base/animation/slide_animation.h"
24 #include "ui/base/gtk/gtk_signal.h" 25 #include "ui/base/gtk/gtk_signal.h"
25 #include "ui/base/gtk/owned_widget_gtk.h" 26 #include "ui/base/gtk/owned_widget_gtk.h"
26 27
27 class DownloadItemModel;
28 class DownloadShelfContextMenuGtk; 28 class DownloadShelfContextMenuGtk;
29 class DownloadShelfGtk; 29 class DownloadShelfGtk;
30 class GtkThemeService; 30 class GtkThemeService;
31 class NineBox; 31 class NineBox;
32 32
33 namespace gfx { 33 namespace gfx {
34 class Image; 34 class Image;
35 } 35 }
36 36
37 namespace ui { 37 namespace ui {
38 class SlideAnimation; 38 class SlideAnimation;
39 } 39 }
40 40
41 class DownloadItemGtk : public content::DownloadItem::Observer, 41 class DownloadItemGtk : public content::DownloadItem::Observer,
42 public ui::AnimationDelegate, 42 public ui::AnimationDelegate,
43 public content::NotificationObserver { 43 public content::NotificationObserver {
44 public: 44 public:
45 // DownloadItemGtk takes ownership of |download_item_model|. 45 // DownloadItemGtk takes ownership of |download_item_model|.
46 DownloadItemGtk(DownloadShelfGtk* parent_shelf, 46 DownloadItemGtk(DownloadShelfGtk* parent_shelf,
47 DownloadItemModel* download_item_model); 47 content::DownloadItem* download_item);
48 48
49 // Destroys all widgets belonging to this DownloadItemGtk. 49 // Destroys all widgets belonging to this DownloadItemGtk.
50 virtual ~DownloadItemGtk(); 50 virtual ~DownloadItemGtk();
51 51
52 // content::DownloadItem::Observer implementation. 52 // content::DownloadItem::Observer implementation.
53 virtual void OnDownloadUpdated(content::DownloadItem* download) OVERRIDE; 53 virtual void OnDownloadUpdated(content::DownloadItem* download) OVERRIDE;
54 virtual void OnDownloadDestroyed(content::DownloadItem* download) OVERRIDE; 54 virtual void OnDownloadDestroyed(content::DownloadItem* download) OVERRIDE;
55 virtual void OnDownloadOpened(content::DownloadItem* download) OVERRIDE; 55 virtual void OnDownloadOpened(content::DownloadItem* download) OVERRIDE;
56 56
57 // ui::AnimationDelegate implementation. 57 // ui::AnimationDelegate implementation.
58 virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE; 58 virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE;
59 59
60 // Overridden from content::NotificationObserver: 60 // Overridden from content::NotificationObserver:
61 virtual void Observe(int type, 61 virtual void Observe(int type,
62 const content::NotificationSource& source, 62 const content::NotificationSource& source,
63 const content::NotificationDetails& details) OVERRIDE; 63 const content::NotificationDetails& details) OVERRIDE;
64 64
65 // Called when the icon manager has finished loading the icon. We take 65 // Called when the icon manager has finished loading the icon. We take
66 // ownership of |icon_bitmap|. 66 // ownership of |icon_bitmap|.
67 void OnLoadSmallIconComplete(gfx::Image* image); 67 void OnLoadSmallIconComplete(gfx::Image* image);
68 void OnLoadLargeIconComplete(gfx::Image* image); 68 void OnLoadLargeIconComplete(gfx::Image* image);
69 69
70 // Returns the DownloadItem model object belonging to this item. 70 // Returns the DownloadItem model object belonging to this item.
71 content::DownloadItem* get_download(); 71 content::DownloadItem* download() { return download_model_.download(); }
72 72
73 private: 73 private:
74 friend class DownloadShelfContextMenuGtk; 74 friend class DownloadShelfContextMenuGtk;
75 75
76 // Functions for controlling the progress animation. 76 // Functions for controlling the progress animation.
77 // Repaint the download progress. 77 // Repaint the download progress.
78 void UpdateDownloadProgress(); 78 void UpdateDownloadProgress();
79 79
80 // Starts a repeating timer for UpdateDownloadProgress. 80 // Starts a repeating timer for UpdateDownloadProgress.
81 void StartDownloadProgress(); 81 void StartDownloadProgress();
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 ui::OwnedWidgetGtk progress_area_; 192 ui::OwnedWidgetGtk progress_area_;
193 193
194 // In degrees. Only used for downloads with no known total size. 194 // In degrees. Only used for downloads with no known total size.
195 int progress_angle_; 195 int progress_angle_;
196 196
197 // The menu that pops down when the user presses |menu_button_|. We do not 197 // The menu that pops down when the user presses |menu_button_|. We do not
198 // create this until the first time we actually need it. 198 // create this until the first time we actually need it.
199 scoped_ptr<DownloadShelfContextMenuGtk> menu_; 199 scoped_ptr<DownloadShelfContextMenuGtk> menu_;
200 200
201 // The download item model we represent. 201 // The download item model we represent.
202 scoped_ptr<DownloadItemModel> download_model_; 202 DownloadItemModel download_model_;
203 203
204 // The dangerous download dialog. This will be null for safe downloads. 204 // The dangerous download dialog. This will be null for safe downloads.
205 GtkWidget* dangerous_prompt_; 205 GtkWidget* dangerous_prompt_;
206 GtkWidget* dangerous_image_; 206 GtkWidget* dangerous_image_;
207 GtkWidget* dangerous_label_; 207 GtkWidget* dangerous_label_;
208 208
209 // An hbox for holding components of the dangerous download dialog. 209 // An hbox for holding components of the dangerous download dialog.
210 ui::OwnedWidgetGtk dangerous_hbox_; 210 ui::OwnedWidgetGtk dangerous_hbox_;
211 int dangerous_hbox_start_width_; 211 int dangerous_hbox_start_width_;
212 int dangerous_hbox_full_width_; 212 int dangerous_hbox_full_width_;
(...skipping 30 matching lines...) Expand all
243 243
244 // Whether we are currently disabled as part of opening the downloaded file. 244 // Whether we are currently disabled as part of opening the downloaded file.
245 bool disabled_while_opening_; 245 bool disabled_while_opening_;
246 246
247 // Method factory used to delay reenabling of the item when opening the 247 // Method factory used to delay reenabling of the item when opening the
248 // downloaded file. 248 // downloaded file.
249 base::WeakPtrFactory<DownloadItemGtk> weak_ptr_factory_; 249 base::WeakPtrFactory<DownloadItemGtk> weak_ptr_factory_;
250 }; 250 };
251 251
252 #endif // CHROME_BROWSER_UI_GTK_DOWNLOAD_DOWNLOAD_ITEM_GTK_H_ 252 #endif // CHROME_BROWSER_UI_GTK_DOWNLOAD_DOWNLOAD_ITEM_GTK_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/download/download_shelf_mac.mm ('k') | chrome/browser/ui/gtk/download/download_item_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698