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

Side by Side Diff: chrome/browser/ui/views/download/download_shelf_view.cc

Issue 8008021: Add new UMA stats to get a handle on Downloads UI Usage (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: comments Created 9 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #include "chrome/browser/ui/views/download/download_shelf_view.h" 5 #include "chrome/browser/ui/views/download/download_shelf_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
11 #include "chrome/browser/download/download_item_model.h" 11 #include "chrome/browser/download/download_item_model.h"
12 #include "chrome/browser/themes/theme_service.h" 12 #include "chrome/browser/themes/theme_service.h"
13 #include "chrome/browser/ui/browser.h" 13 #include "chrome/browser/ui/browser.h"
14 #include "chrome/browser/ui/view_ids.h" 14 #include "chrome/browser/ui/view_ids.h"
15 #include "chrome/browser/ui/views/download/download_item_view.h" 15 #include "chrome/browser/ui/views/download/download_item_view.h"
16 #include "chrome/browser/ui/views/frame/browser_view.h" 16 #include "chrome/browser/ui/views/frame/browser_view.h"
17 #include "content/browser/download/download_item.h" 17 #include "content/browser/download/download_item.h"
18 #include "content/browser/download/download_stats.h"
18 #include "content/browser/download/download_manager.h" 19 #include "content/browser/download/download_manager.h"
19 #include "content/browser/tab_contents/navigation_entry.h" 20 #include "content/browser/tab_contents/navigation_entry.h"
20 #include "grit/generated_resources.h" 21 #include "grit/generated_resources.h"
21 #include "grit/theme_resources.h" 22 #include "grit/theme_resources.h"
22 #include "grit/theme_resources_standard.h" 23 #include "grit/theme_resources_standard.h"
23 #include "ui/base/animation/slide_animation.h" 24 #include "ui/base/animation/slide_animation.h"
24 #include "ui/base/l10n/l10n_util.h" 25 #include "ui/base/l10n/l10n_util.h"
25 #include "ui/base/resource/resource_bundle.h" 26 #include "ui/base/resource/resource_bundle.h"
26 #include "ui/gfx/canvas.h" 27 #include "ui/gfx/canvas.h"
27 #include "views/background.h" 28 #include "views/background.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 81
81 int CenterPosition(int size, int target_size) { 82 int CenterPosition(int size, int target_size) {
82 return std::max((target_size - size) / 2, kTopBottomPadding); 83 return std::max((target_size - size) / 2, kTopBottomPadding);
83 } 84 }
84 85
85 } // namespace 86 } // namespace
86 87
87 DownloadShelfView::DownloadShelfView(Browser* browser, BrowserView* parent) 88 DownloadShelfView::DownloadShelfView(Browser* browser, BrowserView* parent)
88 : browser_(browser), 89 : browser_(browser),
89 parent_(parent), 90 parent_(parent),
91 auto_closed_(false),
90 ALLOW_THIS_IN_INITIALIZER_LIST( 92 ALLOW_THIS_IN_INITIALIZER_LIST(
91 mouse_watcher_(this, this, gfx::Insets())) { 93 mouse_watcher_(this, this, gfx::Insets())) {
92 mouse_watcher_.set_notify_on_exit_time_ms(kNotifyOnExitTimeMS); 94 mouse_watcher_.set_notify_on_exit_time_ms(kNotifyOnExitTimeMS);
93 set_id(VIEW_ID_DOWNLOAD_SHELF); 95 set_id(VIEW_ID_DOWNLOAD_SHELF);
94 parent->AddChildView(this); 96 parent->AddChildView(this);
95 Init(); 97 Init();
96 } 98 }
97 99
98 DownloadShelfView::~DownloadShelfView() { 100 DownloadShelfView::~DownloadShelfView() {
99 parent_->RemoveChildView(this); 101 parent_->RemoveChildView(this);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 new_item_animation_->Show(); 147 new_item_animation_->Show();
146 } 148 }
147 149
148 void DownloadShelfView::AddDownload(BaseDownloadItemModel* download_model) { 150 void DownloadShelfView::AddDownload(BaseDownloadItemModel* download_model) {
149 DownloadItemView* view = new DownloadItemView( 151 DownloadItemView* view = new DownloadItemView(
150 download_model->download(), this, download_model); 152 download_model->download(), this, download_model);
151 AddDownloadView(view); 153 AddDownloadView(view);
152 } 154 }
153 155
154 void DownloadShelfView::MouseMovedOutOfView() { 156 void DownloadShelfView::MouseMovedOutOfView() {
157 auto_closed_ = true;
Randy Smith (Not in Mondays) 2011/10/04 18:34:31 This seems weird to me. Are you sure? Two concer
benjhayden 2011/10/06 21:25:16 Done.
155 Close(); 158 Close();
156 } 159 }
157 160
158 void DownloadShelfView::FocusWillChange(views::View* focused_before, 161 void DownloadShelfView::FocusWillChange(views::View* focused_before,
159 views::View* focused_now) { 162 views::View* focused_now) {
160 SchedulePaintForDownloadItem(focused_before); 163 SchedulePaintForDownloadItem(focused_before);
161 SchedulePaintForDownloadItem(focused_now); 164 SchedulePaintForDownloadItem(focused_now);
162 AccessiblePaneView::FocusWillChange(focused_before, focused_now); 165 AccessiblePaneView::FocusWillChange(focused_before, focused_now);
163 } 166 }
164 167
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 379
377 bool DownloadShelfView::IsClosing() const { 380 bool DownloadShelfView::IsClosing() const {
378 return shelf_animation_->IsClosing(); 381 return shelf_animation_->IsClosing();
379 } 382 }
380 383
381 void DownloadShelfView::Show() { 384 void DownloadShelfView::Show() {
382 shelf_animation_->Show(); 385 shelf_animation_->Show();
383 } 386 }
384 387
385 void DownloadShelfView::Close() { 388 void DownloadShelfView::Close() {
389 int num_pending = 0;
390 for (size_t i = 0; i < download_views_.size(); ++i) {
391 if (download_views_[i]->download()->IsInProgress())
392 ++num_pending;
393 }
394 download_stats::RecordShelfClose(
395 download_views_.size(), num_pending, auto_closed_);
386 parent_->SetDownloadShelfVisible(false); 396 parent_->SetDownloadShelfVisible(false);
387 shelf_animation_->Hide(); 397 shelf_animation_->Hide();
388 } 398 }
389 399
390 Browser* DownloadShelfView::browser() const { 400 Browser* DownloadShelfView::browser() const {
391 return browser_; 401 return browser_;
392 } 402 }
393 403
394 void DownloadShelfView::Closed() { 404 void DownloadShelfView::Closed() {
395 // When the close animation is complete, remove all completed downloads. 405 // When the close animation is complete, remove all completed downloads.
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 const DownloadItemView* download_item_view) { 453 const DownloadItemView* download_item_view) {
444 gfx::Rect bounds = download_item_view->bounds(); 454 gfx::Rect bounds = download_item_view->bounds();
445 455
446 #if defined(TOOLKIT_VIEWS) 456 #if defined(TOOLKIT_VIEWS)
447 bounds.set_height(bounds.height() - 1); 457 bounds.set_height(bounds.height() - 1);
448 bounds.Offset(0, 3); 458 bounds.Offset(0, 3);
449 #endif 459 #endif
450 460
451 return bounds; 461 return bounds;
452 } 462 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698