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

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

Issue 2439533002: Download Feedback Service should upload all eligible downloads (Closed)
Patch Set: nit function renaming Created 4 years, 1 month 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
OLDNEW
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 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 <memory> 19 #include <memory>
20 #include <string> 20 #include <string>
21 21
22 #include "base/macros.h" 22 #include "base/macros.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_commands.h"
28 #include "chrome/browser/download/download_item_model.h" 29 #include "chrome/browser/download/download_item_model.h"
29 #include "chrome/browser/icon_manager.h" 30 #include "chrome/browser/icon_manager.h"
30 #include "content/public/browser/download_item.h" 31 #include "content/public/browser/download_item.h"
31 #include "content/public/browser/download_manager.h" 32 #include "content/public/browser/download_manager.h"
32 #include "ui/gfx/animation/animation_delegate.h" 33 #include "ui/gfx/animation/animation_delegate.h"
33 #include "ui/gfx/font_list.h" 34 #include "ui/gfx/font_list.h"
34 #include "ui/views/animation/ink_drop_host_view.h" 35 #include "ui/views/animation/ink_drop_host_view.h"
35 #include "ui/views/context_menu_controller.h" 36 #include "ui/views/context_menu_controller.h"
36 #include "ui/views/controls/button/vector_icon_button_delegate.h" 37 #include "ui/views/controls/button/vector_icon_button_delegate.h"
37 38
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 78
78 // Returns the base color for text on this download item, based on |theme|. 79 // Returns the base color for text on this download item, based on |theme|.
79 static SkColor GetTextColorForThemeProvider(const ui::ThemeProvider* theme); 80 static SkColor GetTextColorForThemeProvider(const ui::ThemeProvider* theme);
80 81
81 // IconManager::Client interface. 82 // IconManager::Client interface.
82 void OnExtractIconComplete(gfx::Image* icon); 83 void OnExtractIconComplete(gfx::Image* icon);
83 84
84 // Returns the DownloadItem model object belonging to this item. 85 // Returns the DownloadItem model object belonging to this item.
85 content::DownloadItem* download() { return model_.download(); } 86 content::DownloadItem* download() { return model_.download(); }
86 87
88 // If download is bad && download feedback feature is available &&
89 // not incognito.
90 bool ShouldAllowDownloadFeedback();
Peter Kasting 2016/10/24 21:39:07 Nit: I suggest a comment that states the purpose o
Jialiu Lin 2016/10/25 21:07:09 Function merged into MaybeSubmitDownloadToFeedback
91
92 // Submit download to download feedback service if user opts in safe browsing
93 // extended reporting (SBER) service, then perform the specified
94 // |download_command|. If user hasn't seen SBER opt-in text before,
95 // show SBER opt-in dialog first.
96 void MaybeSubmitDownloadToFeedbackService(
Peter Kasting 2016/10/24 21:39:07 It's very confusing that you have both MaybeSubmit
Jialiu Lin 2016/10/25 21:07:09 Good suggestion! I have renamed the second functio
97 DownloadCommands::Command download_command);
98
87 // DownloadItem::Observer methods 99 // DownloadItem::Observer methods
88 void OnDownloadUpdated(content::DownloadItem* download) override; 100 void OnDownloadUpdated(content::DownloadItem* download) override;
89 void OnDownloadOpened(content::DownloadItem* download) override; 101 void OnDownloadOpened(content::DownloadItem* download) override;
90 void OnDownloadDestroyed(content::DownloadItem* download) override; 102 void OnDownloadDestroyed(content::DownloadItem* download) override;
91 103
92 // Overridden from views::View: 104 // Overridden from views::View:
93 void Layout() override; 105 void Layout() override;
94 gfx::Size GetPreferredSize() const override; 106 gfx::Size GetPreferredSize() const override;
95 bool OnMousePressed(const ui::MouseEvent& event) override; 107 bool OnMousePressed(const ui::MouseEvent& event) override;
96 bool OnMouseDragged(const ui::MouseEvent& event) override; 108 bool OnMouseDragged(const ui::MouseEvent& event) override;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 }; 152 };
141 153
142 void OpenDownload(); 154 void OpenDownload();
143 155
144 // Submits the downloaded file to the safebrowsing download feedback service. 156 // Submits the downloaded file to the safebrowsing download feedback service.
145 // Returns whether submission was successful. On successful submission, 157 // Returns whether submission was successful. On successful submission,
146 // |this| and the DownloadItem will have been deleted. 158 // |this| and the DownloadItem will have been deleted.
147 bool SubmitDownloadToFeedbackService(); 159 bool SubmitDownloadToFeedbackService();
148 160
149 // If the user has |enabled| uploading, calls SubmitDownloadToFeedbackService. 161 // If the user has |enabled| uploading, calls SubmitDownloadToFeedbackService.
150 // Otherwise, it simply removes the DownloadItem without uploading. 162 // Otherwise, apply the download command (DISCARD or KEEP) without uploading.
151 void PossiblySubmitDownloadToFeedbackService(bool enabled); 163 void PossiblySubmitDownloadToFeedbackService(
Peter Kasting 2016/10/24 21:39:07 Nit: Call this function something more precise. I
Jialiu Lin 2016/10/25 21:07:09 Done.
164 DownloadCommands::Command download_command_id,
165 bool enabled);
Peter Kasting 2016/10/24 21:39:07 Nit: I would rename this |feedback_enabled| and pu
Jialiu Lin 2016/10/25 21:07:09 Renamed |enabled| to |feedback_enabled|, though I
152 166
153 // This function calculates the vertical coordinate to draw the file name text 167 // This function calculates the vertical coordinate to draw the file name text
154 // relative to local bounds. 168 // relative to local bounds.
155 int GetYForFilenameText() const; 169 int GetYForFilenameText() const;
156 170
157 // Painting of various download item bits. 171 // Painting of various download item bits.
158 void DrawStatusText(gfx::Canvas* canvas); 172 void DrawStatusText(gfx::Canvas* canvas);
159 void DrawFilename(gfx::Canvas* canvas); 173 void DrawFilename(gfx::Canvas* canvas);
160 void DrawIcon(gfx::Canvas* canvas); 174 void DrawIcon(gfx::Canvas* canvas);
161 175
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 std::unique_ptr<extensions::ExperienceSamplingEvent> sampling_event_; 334 std::unique_ptr<extensions::ExperienceSamplingEvent> sampling_event_;
321 335
322 // Method factory used to delay reenabling of the item when opening the 336 // Method factory used to delay reenabling of the item when opening the
323 // downloaded file. 337 // downloaded file.
324 base::WeakPtrFactory<DownloadItemView> weak_ptr_factory_; 338 base::WeakPtrFactory<DownloadItemView> weak_ptr_factory_;
325 339
326 DISALLOW_COPY_AND_ASSIGN(DownloadItemView); 340 DISALLOW_COPY_AND_ASSIGN(DownloadItemView);
327 }; 341 };
328 342
329 #endif // CHROME_BROWSER_UI_VIEWS_DOWNLOAD_DOWNLOAD_ITEM_VIEW_H_ 343 #endif // CHROME_BROWSER_UI_VIEWS_DOWNLOAD_DOWNLOAD_ITEM_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698