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

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

Issue 2744463002: Add VectorIconButton functionality to ImageButton. (Closed)
Patch Set: fix cros build Created 3 years, 9 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
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 #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 #include <vector> 8 #include <vector>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 17 matching lines...) Expand all
28 #include "ui/base/l10n/l10n_util.h" 28 #include "ui/base/l10n/l10n_util.h"
29 #include "ui/base/resource/resource_bundle.h" 29 #include "ui/base/resource/resource_bundle.h"
30 #include "ui/base/theme_provider.h" 30 #include "ui/base/theme_provider.h"
31 #include "ui/gfx/animation/slide_animation.h" 31 #include "ui/gfx/animation/slide_animation.h"
32 #include "ui/gfx/canvas.h" 32 #include "ui/gfx/canvas.h"
33 #include "ui/resources/grit/ui_resources.h" 33 #include "ui/resources/grit/ui_resources.h"
34 #include "ui/vector_icons/vector_icons.h" 34 #include "ui/vector_icons/vector_icons.h"
35 #include "ui/views/background.h" 35 #include "ui/views/background.h"
36 #include "ui/views/border.h" 36 #include "ui/views/border.h"
37 #include "ui/views/controls/button/md_text_button.h" 37 #include "ui/views/controls/button/md_text_button.h"
38 #include "ui/views/controls/button/vector_icon_button.h"
39 #include "ui/views/controls/link.h" 38 #include "ui/views/controls/link.h"
40 #include "ui/views/mouse_watcher_view_host.h" 39 #include "ui/views/mouse_watcher_view_host.h"
41 40
42 using content::DownloadItem; 41 using content::DownloadItem;
43 42
44 namespace { 43 namespace {
45 44
46 // Max number of download views we'll contain. Any time a view is added and 45 // Max number of download views we'll contain. Any time a view is added and
47 // we already have this many download views, one is removed. 46 // we already have this many download views, one is removed.
48 const size_t kMaxDownloadViews = 15; 47 const size_t kMaxDownloadViews = 15;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 104
106 mouse_watcher_.set_notify_on_exit_time( 105 mouse_watcher_.set_notify_on_exit_time(
107 base::TimeDelta::FromMilliseconds(kNotifyOnExitTimeMS)); 106 base::TimeDelta::FromMilliseconds(kNotifyOnExitTimeMS));
108 set_id(VIEW_ID_DOWNLOAD_SHELF); 107 set_id(VIEW_ID_DOWNLOAD_SHELF);
109 parent->AddChildView(this); 108 parent->AddChildView(this);
110 109
111 show_all_view_ = views::MdTextButton::Create( 110 show_all_view_ = views::MdTextButton::Create(
112 this, l10n_util::GetStringUTF16(IDS_SHOW_ALL_DOWNLOADS)); 111 this, l10n_util::GetStringUTF16(IDS_SHOW_ALL_DOWNLOADS));
113 AddChildView(show_all_view_); 112 AddChildView(show_all_view_);
114 113
115 views::VectorIconButton* close_button = new views::VectorIconButton(this); 114 close_button_ =
116 close_button->SetIcon(ui::kCloseIcon); 115 views::ImageButton::CreateDefaultVectorIconButton(ui::kCloseIcon, this);
117 close_button_ = close_button;
118 close_button_->SetAccessibleName( 116 close_button_->SetAccessibleName(
119 l10n_util::GetStringUTF16(IDS_ACCNAME_CLOSE)); 117 l10n_util::GetStringUTF16(IDS_ACCNAME_CLOSE));
120 AddChildView(close_button_); 118 AddChildView(close_button_);
121 119
122 new_item_animation_.SetSlideDuration(kNewItemAnimationDurationMs); 120 new_item_animation_.SetSlideDuration(kNewItemAnimationDurationMs);
123 shelf_animation_.SetSlideDuration(kShelfAnimationDurationMs); 121 shelf_animation_.SetSlideDuration(kShelfAnimationDurationMs);
124 } 122 }
125 123
126 DownloadShelfView::~DownloadShelfView() { 124 DownloadShelfView::~DownloadShelfView() {
127 parent_->RemoveChildView(this); 125 parent_->RemoveChildView(this);
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 void DownloadShelfView::ButtonPressed( 346 void DownloadShelfView::ButtonPressed(
349 views::Button* button, const ui::Event& event) { 347 views::Button* button, const ui::Event& event) {
350 if (button == close_button_) 348 if (button == close_button_)
351 Close(USER_ACTION); 349 Close(USER_ACTION);
352 else if (button == show_all_view_) 350 else if (button == show_all_view_)
353 chrome::ShowDownloads(browser_); 351 chrome::ShowDownloads(browser_);
354 else 352 else
355 NOTREACHED(); 353 NOTREACHED();
356 } 354 }
357 355
358 SkColor DownloadShelfView::GetVectorIconBaseColor() const { 356 SkColor DownloadShelfView::GetVectorIconColor() const {
359 return DownloadItemView::GetTextColorForThemeProvider(GetThemeProvider()); 357 return DownloadItemView::GetTextColorForThemeProvider(GetThemeProvider());
360 } 358 }
361 359
362 bool DownloadShelfView::IsShowing() const { 360 bool DownloadShelfView::IsShowing() const {
363 return visible() && shelf_animation_.IsShowing(); 361 return visible() && shelf_animation_.IsShowing();
364 } 362 }
365 363
366 bool DownloadShelfView::IsClosing() const { 364 bool DownloadShelfView::IsClosing() const {
367 return shelf_animation_.IsClosing(); 365 return shelf_animation_.IsClosing();
368 } 366 }
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 SetVisible(false); 423 SetVisible(false);
426 } 424 }
427 425
428 bool DownloadShelfView::CanAutoClose() { 426 bool DownloadShelfView::CanAutoClose() {
429 for (size_t i = 0; i < download_views_.size(); ++i) { 427 for (size_t i = 0; i < download_views_.size(); ++i) {
430 if (!download_views_[i]->download()->GetOpened()) 428 if (!download_views_[i]->download()->GetOpened())
431 return false; 429 return false;
432 } 430 }
433 return true; 431 return true;
434 } 432 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698