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

Side by Side 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, 2 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 // Download utility implementation 5 // Download utility implementation
6 6
7 #define _USE_MATH_DEFINES // For VC++ to get M_PI. This has to be first. 7 #define _USE_MATH_DEFINES // For VC++ to get M_PI. This has to be first.
8 8
9 #include "chrome/browser/download/download_util.h" 9 #include "chrome/browser/download/download_util.h"
10 10
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 #endif 68 #endif
69 69
70 #if defined(USE_AURA) 70 #if defined(USE_AURA)
71 #include "ui/aura/client/drag_drop_client.h" 71 #include "ui/aura/client/drag_drop_client.h"
72 #include "ui/aura/root_window.h" 72 #include "ui/aura/root_window.h"
73 #include "ui/aura/window.h" 73 #include "ui/aura/window.h"
74 #endif 74 #endif
75 75
76 namespace { 76 namespace {
77 77
78 // Key used to attach ShowInShelfData to a DownloadItem.
79 const char kShowInShelfKey[] = "chrome.download_util.show_in_shelf";
80
81 // Class that tracks the "show in download shelf" setting for a download item.
82 class ShowInShelfData : public base::SupportsUserData::Data {
83 public:
84 explicit ShowInShelfData(bool should_show) : should_show_(should_show) {
85 }
86
87 bool should_show() const { return should_show_; }
88
89 private:
90 const bool should_show_;
91 };
92
78 // Get the opacity based on |animation_progress|, with values in [0.0, 1.0]. 93 // Get the opacity based on |animation_progress|, with values in [0.0, 1.0].
79 // Range of return value is [0, 255]. 94 // Range of return value is [0, 255].
80 int GetOpacity(double animation_progress) { 95 int GetOpacity(double animation_progress) {
81 DCHECK(animation_progress >= 0 && animation_progress <= 1); 96 DCHECK(animation_progress >= 0 && animation_progress <= 1);
82 97
83 // How many times to cycle the complete animation. This should be an odd 98 // How many times to cycle the complete animation. This should be an odd
84 // number so that the animation ends faded out. 99 // number so that the animation ends faded out.
85 static const int kCompleteAnimationCycles = 5; 100 static const int kCompleteAnimationCycles = 5;
86 double temp = animation_progress * kCompleteAnimationCycles * M_PI + M_PI_2; 101 double temp = animation_progress * kCompleteAnimationCycles * M_PI + M_PI_2;
87 temp = sin(temp) / 2 + 0.5; 102 temp = sin(temp) / 2 + 0.5;
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 void RecordDownloadCount(ChromeDownloadCountTypes type) { 492 void RecordDownloadCount(ChromeDownloadCountTypes type) {
478 UMA_HISTOGRAM_ENUMERATION( 493 UMA_HISTOGRAM_ENUMERATION(
479 "Download.CountsChrome", type, CHROME_DOWNLOAD_COUNT_TYPES_LAST_ENTRY); 494 "Download.CountsChrome", type, CHROME_DOWNLOAD_COUNT_TYPES_LAST_ENTRY);
480 } 495 }
481 496
482 void RecordDownloadSource(ChromeDownloadSource source) { 497 void RecordDownloadSource(ChromeDownloadSource source) {
483 UMA_HISTOGRAM_ENUMERATION( 498 UMA_HISTOGRAM_ENUMERATION(
484 "Download.SourcesChrome", source, CHROME_DOWNLOAD_SOURCE_LAST_ENTRY); 499 "Download.SourcesChrome", source, CHROME_DOWNLOAD_SOURCE_LAST_ENTRY);
485 } 500 }
486 501
502 bool GetShouldShowInShelf(content::DownloadItem* item) {
503 ShowInShelfData* data =
504 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.
505 return !data || data->should_show();
506 }
507
508 void SetShouldShowInShelf(content::DownloadItem* item, bool should_show) {
509 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(
510 }
511
487 } // namespace download_util 512 } // namespace download_util
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698