OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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_VIEWS_DONWLOAD_TAB_VIEW_H__ | 5 #ifndef CHROME_BROWSER_VIEWS_DONWLOAD_TAB_VIEW_H__ |
6 #define CHROME_BROWSER_VIEWS_DONWLOAD_TAB_VIEW_H__ | 6 #define CHROME_BROWSER_VIEWS_DONWLOAD_TAB_VIEW_H__ |
7 | 7 |
8 #include "base/hash_tables.h" | 8 #include "base/hash_tables.h" |
9 #include "chrome/browser/cancelable_request.h" | 9 #include "chrome/browser/cancelable_request.h" |
10 #include "chrome/browser/download/download_manager.h" | 10 #include "chrome/browser/download/download_manager.h" |
11 #include "chrome/browser/download/download_util.h" | 11 #include "chrome/browser/download/download_util.h" |
12 #include "chrome/browser/icon_manager.h" | 12 #include "chrome/browser/icon_manager.h" |
13 #include "chrome/browser/native_ui_contents.h" | 13 #include "chrome/browser/native_ui_contents.h" |
14 #include "chrome/views/event.h" | 14 #include "chrome/views/event.h" |
15 #include "chrome/views/label.h" | 15 #include "chrome/views/label.h" |
16 #include "chrome/views/link.h" | 16 #include "chrome/views/link.h" |
17 #include "chrome/views/scroll_view.h" | 17 #include "chrome/views/scroll_view.h" |
18 | 18 |
19 class DownloadTabView; | 19 class DownloadTabView; |
20 class SkBitmap; | 20 class SkBitmap; |
21 class Task; | 21 class Task; |
22 | 22 |
23 namespace base { | 23 namespace base { |
24 class Timer; | 24 class Timer; |
25 } | 25 } |
26 | 26 |
27 class DownloadItemTabView : public views::View, | 27 class DownloadItemTabView : public views::View, |
28 public views::LinkController, | 28 public views::LinkController, |
| 29 public views::ContextMenuController, |
29 public views::NativeButton::Listener { | 30 public views::NativeButton::Listener { |
30 public: | 31 public: |
31 DownloadItemTabView(); | 32 DownloadItemTabView(); |
32 virtual ~DownloadItemTabView(); | 33 virtual ~DownloadItemTabView(); |
33 | 34 |
34 // View overrides | 35 // View overrides |
35 virtual void Layout(); | 36 virtual void Layout(); |
36 virtual void Paint(ChromeCanvas* canvas); | 37 virtual void Paint(ChromeCanvas* canvas); |
37 void PaintBackground(ChromeCanvas* canvas); | 38 void PaintBackground(ChromeCanvas* canvas); |
38 virtual gfx::Size GetPreferredSize(); | 39 virtual gfx::Size GetPreferredSize(); |
| 40 virtual bool CanProcessTabKeyEvents(); |
| 41 virtual bool OnKeyPressed(const views::KeyEvent& event); |
39 virtual bool OnMousePressed(const views::MouseEvent& event); | 42 virtual bool OnMousePressed(const views::MouseEvent& event); |
40 virtual bool OnMouseDragged(const views::MouseEvent& event); | 43 virtual bool OnMouseDragged(const views::MouseEvent& event); |
41 | 44 |
| 45 // Invoked for this View, one of the buttons or the 'other' button. Shows the |
| 46 // appropriate context menu. |
| 47 virtual void ShowContextMenu(views::View* source, |
| 48 int x, |
| 49 int y, |
| 50 bool is_mouse_gesture); |
| 51 |
42 // Mode specific layouts | 52 // Mode specific layouts |
43 void LayoutDate(); | 53 void LayoutDate(); |
44 void LayoutComplete(); | 54 void LayoutComplete(); |
45 void LayoutCancelled(); | 55 void LayoutCancelled(); |
46 void LayoutInProgress(); | 56 void LayoutInProgress(); |
47 void LayoutPromptDangerousDownload(); | 57 void LayoutPromptDangerousDownload(); |
48 | 58 |
49 // LinkController overrides | 59 // LinkController overrides |
50 virtual void LinkActivated(views::Link* source, int event_flags); | 60 virtual void LinkActivated(views::Link* source, int event_flags); |
51 | 61 |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 | 151 |
142 // Determine if we should draw the date beside a particular download | 152 // Determine if we should draw the date beside a particular download |
143 bool ShouldDrawDateForDownload(DownloadItem* download); | 153 bool ShouldDrawDateForDownload(DownloadItem* download); |
144 | 154 |
145 virtual int GetPageScrollIncrement(views::ScrollView* scroll_view, | 155 virtual int GetPageScrollIncrement(views::ScrollView* scroll_view, |
146 bool is_horizontal, bool is_positive); | 156 bool is_horizontal, bool is_positive); |
147 virtual int GetLineScrollIncrement(views::ScrollView* scroll_view, | 157 virtual int GetLineScrollIncrement(views::ScrollView* scroll_view, |
148 bool is_horizontal, bool is_positive); | 158 bool is_horizontal, bool is_positive); |
149 | 159 |
150 int start_angle() const { return start_angle_; } | 160 int start_angle() const { return start_angle_; } |
151 | 161 int selected_index() const { return selected_index_; } |
| 162 int total_downloads() const { return static_cast<int>(downloads_.size()); } |
| 163 |
152 // Called by a DownloadItemTabView when it becomes selected. Passing a NULL | 164 // Called by a DownloadItemTabView when it becomes selected. Passing a NULL |
153 // for 'download' causes any selected download to become unselected. | 165 // for 'download' causes any selected download to become unselected. |
154 void ItemBecameSelected(const DownloadItem* download); | 166 void ItemBecameSelected(const DownloadItem* download); |
155 bool ItemIsSelected(DownloadItem* download); | 167 bool ItemIsSelected(DownloadItem* download); |
156 | 168 |
| 169 // Called by a DownloadItemTabView when navigating between download items. |
| 170 // Passing a -1 for |index| will select the newest item in the download list. |
| 171 void SelectItemAtIndex(int index); |
| 172 |
157 // The destination view's search box text has changed. | 173 // The destination view's search box text has changed. |
158 void SetSearchText(const std::wstring& search_text); | 174 void SetSearchText(const std::wstring& search_text); |
159 | 175 |
160 inline int big_icon_size() const { return big_icon_size_; } | 176 inline int big_icon_size() const { return big_icon_size_; } |
161 inline int big_icon_offset() const { return big_icon_offset_; } | 177 inline int big_icon_offset() const { return big_icon_offset_; } |
162 | 178 |
163 private: | 179 private: |
164 // Creates and attaches to the view the floating view at |index|. | 180 // Creates and attaches to the view the floating view at |index|. |
165 views::View* CreateFloatingViewForIndex(int index); | 181 views::View* CreateFloatingViewForIndex(int index); |
166 | 182 |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 // The view we return from GetView. The contents of this is the | 288 // The view we return from GetView. The contents of this is the |
273 // bookmarks_view_ | 289 // bookmarks_view_ |
274 SearchableUIContainer searchable_container_; | 290 SearchableUIContainer searchable_container_; |
275 | 291 |
276 DownloadTabView* download_tab_view_; | 292 DownloadTabView* download_tab_view_; |
277 | 293 |
278 DISALLOW_EVIL_CONSTRUCTORS(DownloadTabUI); | 294 DISALLOW_EVIL_CONSTRUCTORS(DownloadTabUI); |
279 }; | 295 }; |
280 | 296 |
281 #endif // CHROME_BROWSER_VIEWS_DONWLOAD_TAB_VIEW_H__ | 297 #endif // CHROME_BROWSER_VIEWS_DONWLOAD_TAB_VIEW_H__ |
OLD | NEW |