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

Unified Diff: chrome/browser/download/download_util.cc

Issue 10980002: Mac Web Intents Part 1: Show extension download progress (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/download/download_util.cc
diff --git a/chrome/browser/download/download_util.cc b/chrome/browser/download/download_util.cc
index d18d876eaf52646108b17f8b19f50102fa8a8469..32eaa2f861161d676b35ac1e0da04454712f20dd 100644
--- a/chrome/browser/download/download_util.cc
+++ b/chrome/browser/download/download_util.cc
@@ -75,6 +75,21 @@
namespace {
+// Key used to attach ShowInShelfData to a DownloadItem.
+const char kShowInShelfKey[] = "chrome.download_util.show_in_shelf";
+
+// Class that tracks the "show in download shelf" setting for a download item.
+class ShowInShelfData : public base::SupportsUserData::Data {
+ public:
+ explicit ShowInShelfData(bool should_show) : should_show_(should_show) {
+ }
+
+ bool should_show() const { return should_show_; }
+
+ private:
+ const bool should_show_;
+};
+
// Get the opacity based on |animation_progress|, with values in [0.0, 1.0].
// Range of return value is [0, 255].
int GetOpacity(double animation_progress) {
@@ -484,4 +499,14 @@ void RecordDownloadSource(ChromeDownloadSource source) {
"Download.SourcesChrome", source, CHROME_DOWNLOAD_SOURCE_LAST_ENTRY);
}
+bool GetShouldShowInShelf(content::DownloadItem* item) {
+ ShowInShelfData* data =
+ static_cast<ShowInShelfData*>(item->GetUserData(kShowInShelfKey));
Greg Billock 2012/09/25 07:15:46 Do we not have a type token wrapper for getting da
sail 2012/10/02 18:57:01 Done. Removed code.
+ return !data || data->should_show();
+}
+
+void SetShouldShowInShelf(content::DownloadItem* item, bool should_show) {
+ item->SetUserData(kShowInShelfKey, new ShowInShelfData(should_show));
Nico 2012/09/25 03:07:18 Can't you just add a bool to DownloadItem?
Steve McKay 2012/09/25 18:56:04 That'd probably work if you generalize the propert
sail 2012/10/02 18:57:01 Done. Added DownloadItem::ShouldShowInDownloadsUI(
+}
+
} // namespace download_util

Powered by Google App Engine
This is Rietveld 408576698