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

Side by Side Diff: chrome/browser/download/download_util.cc

Issue 11016022: Don't show downloads from web intents picker in shelf (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix build 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
« no previous file with comments | « chrome/browser/download/download_util.h ('k') | chrome/browser/ui/browser.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 void RecordDownloadCount(ChromeDownloadCountTypes type) { 488 void RecordDownloadCount(ChromeDownloadCountTypes type) {
474 UMA_HISTOGRAM_ENUMERATION( 489 UMA_HISTOGRAM_ENUMERATION(
475 "Download.CountsChrome", type, CHROME_DOWNLOAD_COUNT_TYPES_LAST_ENTRY); 490 "Download.CountsChrome", type, CHROME_DOWNLOAD_COUNT_TYPES_LAST_ENTRY);
476 } 491 }
477 492
478 void RecordDownloadSource(ChromeDownloadSource source) { 493 void RecordDownloadSource(ChromeDownloadSource source) {
479 UMA_HISTOGRAM_ENUMERATION( 494 UMA_HISTOGRAM_ENUMERATION(
480 "Download.SourcesChrome", source, CHROME_DOWNLOAD_SOURCE_LAST_ENTRY); 495 "Download.SourcesChrome", source, CHROME_DOWNLOAD_SOURCE_LAST_ENTRY);
481 } 496 }
482 497
498 bool ShouldShowInShelf(content::DownloadItem* item) {
499 ShowInShelfData* data =
500 static_cast<ShowInShelfData*>(item->GetUserData(kShowInShelfKey));
501 return !data || data->should_show();
502 }
503
504 void SetShouldShowInShelf(content::DownloadItem* item, bool should_show) {
505 item->SetUserData(kShowInShelfKey, new ShowInShelfData(should_show));
506 }
507
483 } // namespace download_util 508 } // namespace download_util
OLDNEW
« no previous file with comments | « chrome/browser/download/download_util.h ('k') | chrome/browser/ui/browser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698