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

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

Issue 2305933002: Update dialog close buttons to use vector icons and ripples. (Closed)
Patch Set: delegate Created 4 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 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"
11 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
12 #include "chrome/browser/download/download_item_model.h" 12 #include "chrome/browser/download/download_item_model.h"
13 #include "chrome/browser/download/download_stats.h" 13 #include "chrome/browser/download/download_stats.h"
14 #include "chrome/browser/themes/theme_properties.h" 14 #include "chrome/browser/themes/theme_properties.h"
15 #include "chrome/browser/ui/browser.h" 15 #include "chrome/browser/ui/browser.h"
16 #include "chrome/browser/ui/chrome_pages.h" 16 #include "chrome/browser/ui/chrome_pages.h"
17 #include "chrome/browser/ui/view_ids.h" 17 #include "chrome/browser/ui/view_ids.h"
18 #include "chrome/browser/ui/views/bar_control_button.h"
19 #include "chrome/browser/ui/views/download/download_item_view.h" 18 #include "chrome/browser/ui/views/download/download_item_view.h"
20 #include "chrome/browser/ui/views/download/download_item_view_md.h" 19 #include "chrome/browser/ui/views/download/download_item_view_md.h"
21 #include "chrome/browser/ui/views/frame/browser_view.h" 20 #include "chrome/browser/ui/views/frame/browser_view.h"
22 #include "chrome/grit/generated_resources.h" 21 #include "chrome/grit/generated_resources.h"
23 #include "chrome/grit/theme_resources.h" 22 #include "chrome/grit/theme_resources.h"
24 #include "components/strings/grit/components_strings.h" 23 #include "components/strings/grit/components_strings.h"
25 #include "content/public/browser/download_item.h" 24 #include "content/public/browser/download_item.h"
26 #include "content/public/browser/download_manager.h" 25 #include "content/public/browser/download_manager.h"
27 #include "content/public/browser/page_navigator.h" 26 #include "content/public/browser/page_navigator.h"
28 #include "ui/base/l10n/l10n_util.h" 27 #include "ui/base/l10n/l10n_util.h"
29 #include "ui/base/material_design/material_design_controller.h" 28 #include "ui/base/material_design/material_design_controller.h"
30 #include "ui/base/resource/resource_bundle.h" 29 #include "ui/base/resource/resource_bundle.h"
31 #include "ui/base/theme_provider.h" 30 #include "ui/base/theme_provider.h"
32 #include "ui/gfx/animation/slide_animation.h" 31 #include "ui/gfx/animation/slide_animation.h"
33 #include "ui/gfx/canvas.h" 32 #include "ui/gfx/canvas.h"
34 #include "ui/gfx/vector_icons_public.h" 33 #include "ui/gfx/vector_icons_public.h"
35 #include "ui/resources/grit/ui_resources.h" 34 #include "ui/resources/grit/ui_resources.h"
36 #include "ui/views/background.h" 35 #include "ui/views/background.h"
37 #include "ui/views/border.h" 36 #include "ui/views/border.h"
38 #include "ui/views/controls/button/image_button.h" 37 #include "ui/views/controls/button/image_button.h"
39 #include "ui/views/controls/button/md_text_button.h" 38 #include "ui/views/controls/button/md_text_button.h"
39 #include "ui/views/controls/button/vector_icon_button.h"
40 #include "ui/views/controls/image_view.h" 40 #include "ui/views/controls/image_view.h"
41 #include "ui/views/controls/link.h" 41 #include "ui/views/controls/link.h"
42 #include "ui/views/mouse_watcher_view_host.h" 42 #include "ui/views/mouse_watcher_view_host.h"
43 43
44 using content::DownloadItem; 44 using content::DownloadItem;
45 45
46 namespace { 46 namespace {
47 47
48 // Max number of download views we'll contain. Any time a view is added and 48 // Max number of download views we'll contain. Any time a view is added and
49 // we already have this many download views, one is removed. 49 // we already have this many download views, one is removed.
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 rb.GetImageSkiaNamed(IDR_CLOSE_1)); 165 rb.GetImageSkiaNamed(IDR_CLOSE_1));
166 close_button_->SetImage(views::CustomButton::STATE_HOVERED, 166 close_button_->SetImage(views::CustomButton::STATE_HOVERED,
167 rb.GetImageSkiaNamed(IDR_CLOSE_1_H)); 167 rb.GetImageSkiaNamed(IDR_CLOSE_1_H));
168 close_button_->SetImage(views::CustomButton::STATE_PRESSED, 168 close_button_->SetImage(views::CustomButton::STATE_PRESSED,
169 rb.GetImageSkiaNamed(IDR_CLOSE_1_P)); 169 rb.GetImageSkiaNamed(IDR_CLOSE_1_P));
170 } else { 170 } else {
171 show_all_view_md_ = views::MdTextButton::CreateMdButton( 171 show_all_view_md_ = views::MdTextButton::CreateMdButton(
172 this, l10n_util::GetStringUTF16(IDS_SHOW_ALL_DOWNLOADS_MD)); 172 this, l10n_util::GetStringUTF16(IDS_SHOW_ALL_DOWNLOADS_MD));
173 show_all_view_ = show_all_view_md_; 173 show_all_view_ = show_all_view_md_;
174 174
175 BarControlButton* close_button = new BarControlButton(this); 175 views::VectorIconButton* close_button = new views::VectorIconButton(this);
176 close_button->SetIcon(gfx::VectorIconId::BAR_CLOSE, 176 close_button->SetIcon(gfx::VectorIconId::BAR_CLOSE);
177 base::Bind(&DownloadShelfView::GetTextColorForIconMd,
178 base::Unretained(this)));
179 close_button_ = close_button; 177 close_button_ = close_button;
180 } 178 }
181 close_button_->SetAccessibleName( 179 close_button_->SetAccessibleName(
182 l10n_util::GetStringUTF16(IDS_ACCNAME_CLOSE)); 180 l10n_util::GetStringUTF16(IDS_ACCNAME_CLOSE));
183 AddChildView(show_all_view_); 181 AddChildView(show_all_view_);
184 AddChildView(close_button_); 182 AddChildView(close_button_);
185 183
186 new_item_animation_.SetSlideDuration(kNewItemAnimationDurationMs); 184 new_item_animation_.SetSlideDuration(kNewItemAnimationDurationMs);
187 shelf_animation_.SetSlideDuration(kShelfAnimationDurationMs); 185 shelf_animation_.SetSlideDuration(kShelfAnimationDurationMs);
188 } 186 }
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 void DownloadShelfView::ButtonPressed( 419 void DownloadShelfView::ButtonPressed(
422 views::Button* button, const ui::Event& event) { 420 views::Button* button, const ui::Event& event) {
423 if (button == close_button_) 421 if (button == close_button_)
424 Close(USER_ACTION); 422 Close(USER_ACTION);
425 else if (button == show_all_view_) 423 else if (button == show_all_view_)
426 chrome::ShowDownloads(browser_); 424 chrome::ShowDownloads(browser_);
427 else 425 else
428 NOTREACHED(); 426 NOTREACHED();
429 } 427 }
430 428
429 SkColor DownloadShelfView::GetVectorIconBaseColor() const {
430 return DownloadItemViewMd::GetTextColorForThemeProvider(GetThemeProvider());
431 }
432
431 bool DownloadShelfView::IsShowing() const { 433 bool DownloadShelfView::IsShowing() const {
432 return visible() && shelf_animation_.IsShowing(); 434 return visible() && shelf_animation_.IsShowing();
433 } 435 }
434 436
435 bool DownloadShelfView::IsClosing() const { 437 bool DownloadShelfView::IsClosing() const {
436 return shelf_animation_.IsClosing(); 438 return shelf_animation_.IsClosing();
437 } 439 }
438 440
439 void DownloadShelfView::DoShow() { 441 void DownloadShelfView::DoShow() {
440 SetVisible(true); 442 SetVisible(true);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 return false; 490 return false;
489 } 491 }
490 return true; 492 return true;
491 } 493 }
492 494
493 content::DownloadItem* DownloadShelfView::GetDownloadItemForView(size_t i) { 495 content::DownloadItem* DownloadShelfView::GetDownloadItemForView(size_t i) {
494 if (ui::MaterialDesignController::IsModeMaterial()) 496 if (ui::MaterialDesignController::IsModeMaterial())
495 return static_cast<DownloadItemViewMd*>(download_views_[i])->download(); 497 return static_cast<DownloadItemViewMd*>(download_views_[i])->download();
496 return static_cast<DownloadItemView*>(download_views_[i])->download(); 498 return static_cast<DownloadItemView*>(download_views_[i])->download();
497 } 499 }
498
499 SkColor DownloadShelfView::GetTextColorForIconMd() {
500 return DownloadItemViewMd::GetTextColorForThemeProvider(GetThemeProvider());
501 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698