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

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: make windows bots happy 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 // Submits download to download feedback service if the user has approved and
89 // the download is suitable for submission, then apply |download_command|.
90 // If user hasn't seen SBER opt-in text before, show SBER opt-in dialog first.
91 void MaybeSubmitDownloadToFeedbackService(
92 DownloadCommands::Command download_command);
93
87 // DownloadItem::Observer methods 94 // DownloadItem::Observer methods
88 void OnDownloadUpdated(content::DownloadItem* download) override; 95 void OnDownloadUpdated(content::DownloadItem* download) override;
89 void OnDownloadOpened(content::DownloadItem* download) override; 96 void OnDownloadOpened(content::DownloadItem* download) override;
90 void OnDownloadDestroyed(content::DownloadItem* download) override; 97 void OnDownloadDestroyed(content::DownloadItem* download) override;
91 98
92 // Overridden from views::View: 99 // Overridden from views::View:
93 void Layout() override; 100 void Layout() override;
94 gfx::Size GetPreferredSize() const override; 101 gfx::Size GetPreferredSize() const override;
95 bool OnMousePressed(const ui::MouseEvent& event) override; 102 bool OnMousePressed(const ui::MouseEvent& event) override;
96 bool OnMouseDragged(const ui::MouseEvent& event) override; 103 bool OnMouseDragged(const ui::MouseEvent& event) override;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 143
137 enum Mode { 144 enum Mode {
138 NORMAL_MODE = 0, // Showing download item. 145 NORMAL_MODE = 0, // Showing download item.
139 DANGEROUS_MODE, // Displaying the dangerous download warning. 146 DANGEROUS_MODE, // Displaying the dangerous download warning.
140 MALICIOUS_MODE // Displaying the malicious download warning. 147 MALICIOUS_MODE // Displaying the malicious download warning.
141 }; 148 };
142 149
143 void OpenDownload(); 150 void OpenDownload();
144 151
145 // Submits the downloaded file to the safebrowsing download feedback service. 152 // Submits the downloaded file to the safebrowsing download feedback service.
146 // Returns whether submission was successful. On successful submission, 153 // Returns whether submission was successful. Applies |download_command|, if
147 // |this| and the DownloadItem will have been deleted. 154 // submission fails.
148 bool SubmitDownloadToFeedbackService(); 155 bool SubmitDownloadToFeedbackService(
156 DownloadCommands::Command download_command);
149 157
150 // If the user has |enabled| uploading, calls SubmitDownloadToFeedbackService. 158 // If the user has |enabled| uploading, calls SubmitDownloadToFeedbackService.
151 // Otherwise, it simply removes the DownloadItem without uploading. 159 // Otherwise, apply |download_command|.
152 void PossiblySubmitDownloadToFeedbackService(bool enabled); 160 void SubmitDownloadWhenFeedbackServiceEnabled(
161 DownloadCommands::Command download_command,
162 bool feedback_enabled);
153 163
154 // This function calculates the vertical coordinate to draw the file name text 164 // This function calculates the vertical coordinate to draw the file name text
155 // relative to local bounds. 165 // relative to local bounds.
156 int GetYForFilenameText() const; 166 int GetYForFilenameText() const;
157 167
158 // Painting of various download item bits. 168 // Painting of various download item bits.
159 void DrawStatusText(gfx::Canvas* canvas); 169 void DrawStatusText(gfx::Canvas* canvas);
160 void DrawFilename(gfx::Canvas* canvas); 170 void DrawFilename(gfx::Canvas* canvas);
161 void DrawIcon(gfx::Canvas* canvas); 171 void DrawIcon(gfx::Canvas* canvas);
162 172
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 std::unique_ptr<extensions::ExperienceSamplingEvent> sampling_event_; 331 std::unique_ptr<extensions::ExperienceSamplingEvent> sampling_event_;
322 332
323 // Method factory used to delay reenabling of the item when opening the 333 // Method factory used to delay reenabling of the item when opening the
324 // downloaded file. 334 // downloaded file.
325 base::WeakPtrFactory<DownloadItemView> weak_ptr_factory_; 335 base::WeakPtrFactory<DownloadItemView> weak_ptr_factory_;
326 336
327 DISALLOW_COPY_AND_ASSIGN(DownloadItemView); 337 DISALLOW_COPY_AND_ASSIGN(DownloadItemView);
328 }; 338 };
329 339
330 #endif // CHROME_BROWSER_UI_VIEWS_DOWNLOAD_DOWNLOAD_ITEM_VIEW_H_ 340 #endif // CHROME_BROWSER_UI_VIEWS_DOWNLOAD_DOWNLOAD_ITEM_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698