| OLD | NEW |
| 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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 } | 127 } |
| 128 | 128 |
| 129 } // namespace | 129 } // namespace |
| 130 | 130 |
| 131 DownloadShelfView::DownloadShelfView(Browser* browser, BrowserView* parent) | 131 DownloadShelfView::DownloadShelfView(Browser* browser, BrowserView* parent) |
| 132 : browser_(browser), | 132 : browser_(browser), |
| 133 new_item_animation_(this), | 133 new_item_animation_(this), |
| 134 shelf_animation_(this), | 134 shelf_animation_(this), |
| 135 arrow_image_(nullptr), | 135 arrow_image_(nullptr), |
| 136 show_all_view_(nullptr), | 136 show_all_view_(nullptr), |
| 137 show_all_view_md_(nullptr), |
| 137 close_button_(nullptr), | 138 close_button_(nullptr), |
| 138 parent_(parent), | 139 parent_(parent), |
| 139 mouse_watcher_(new views::MouseWatcherViewHost(this, gfx::Insets()), | 140 mouse_watcher_(new views::MouseWatcherViewHost(this, gfx::Insets()), |
| 140 this) { | 141 this) { |
| 141 // Start out hidden: the shelf might be created but never shown in some | 142 // Start out hidden: the shelf might be created but never shown in some |
| 142 // cases, like when installing a theme. See DownloadShelf::AddDownload(). | 143 // cases, like when installing a theme. See DownloadShelf::AddDownload(). |
| 143 SetVisible(false); | 144 SetVisible(false); |
| 144 | 145 |
| 145 mouse_watcher_.set_notify_on_exit_time( | 146 mouse_watcher_.set_notify_on_exit_time( |
| 146 base::TimeDelta::FromMilliseconds(kNotifyOnExitTimeMS)); | 147 base::TimeDelta::FromMilliseconds(kNotifyOnExitTimeMS)); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 160 show_all_view_ = show_all_view; | 161 show_all_view_ = show_all_view; |
| 161 | 162 |
| 162 close_button_ = new views::ImageButton(this); | 163 close_button_ = new views::ImageButton(this); |
| 163 close_button_->SetImage(views::CustomButton::STATE_NORMAL, | 164 close_button_->SetImage(views::CustomButton::STATE_NORMAL, |
| 164 rb.GetImageSkiaNamed(IDR_CLOSE_1)); | 165 rb.GetImageSkiaNamed(IDR_CLOSE_1)); |
| 165 close_button_->SetImage(views::CustomButton::STATE_HOVERED, | 166 close_button_->SetImage(views::CustomButton::STATE_HOVERED, |
| 166 rb.GetImageSkiaNamed(IDR_CLOSE_1_H)); | 167 rb.GetImageSkiaNamed(IDR_CLOSE_1_H)); |
| 167 close_button_->SetImage(views::CustomButton::STATE_PRESSED, | 168 close_button_->SetImage(views::CustomButton::STATE_PRESSED, |
| 168 rb.GetImageSkiaNamed(IDR_CLOSE_1_P)); | 169 rb.GetImageSkiaNamed(IDR_CLOSE_1_P)); |
| 169 } else { | 170 } else { |
| 170 views::LabelButton* show_all_view = | 171 show_all_view_md_ = views::MdTextButton::CreateMdButton( |
| 171 views::MdTextButton::CreateStandardButton( | 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; | |
| 174 | 174 |
| 175 BarControlButton* close_button = new BarControlButton(this); | 175 BarControlButton* close_button = new BarControlButton(this); |
| 176 close_button->SetIcon(gfx::VectorIconId::BAR_CLOSE, | 176 close_button->SetIcon(gfx::VectorIconId::BAR_CLOSE, |
| 177 base::Bind(&DownloadShelfView::GetTextColorForIconMd, | 177 base::Bind(&DownloadShelfView::GetTextColorForIconMd, |
| 178 base::Unretained(this))); | 178 base::Unretained(this))); |
| 179 close_button_ = close_button; | 179 close_button_ = close_button; |
| 180 } | 180 } |
| 181 close_button_->SetAccessibleName( | 181 close_button_->SetAccessibleName( |
| 182 l10n_util::GetStringUTF16(IDS_ACCNAME_CLOSE)); | 182 l10n_util::GetStringUTF16(IDS_ACCNAME_CLOSE)); |
| 183 AddChildView(show_all_view_); | 183 AddChildView(show_all_view_); |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 | 385 |
| 386 gfx::Size item_size = (*download_views_.rbegin())->GetPreferredSize(); | 386 gfx::Size item_size = (*download_views_.rbegin())->GetPreferredSize(); |
| 387 return item_size.width() < available_width; | 387 return item_size.width() < available_width; |
| 388 } | 388 } |
| 389 | 389 |
| 390 void DownloadShelfView::UpdateColorsFromTheme() { | 390 void DownloadShelfView::UpdateColorsFromTheme() { |
| 391 if (show_all_view_ && close_button_ && GetThemeProvider()) { | 391 if (show_all_view_ && close_button_ && GetThemeProvider()) { |
| 392 set_background(views::Background::CreateSolidBackground( | 392 set_background(views::Background::CreateSolidBackground( |
| 393 GetThemeProvider()->GetColor(ThemeProperties::COLOR_TOOLBAR))); | 393 GetThemeProvider()->GetColor(ThemeProperties::COLOR_TOOLBAR))); |
| 394 | 394 |
| 395 if (!ui::MaterialDesignController::IsModeMaterial()) { | 395 if (ui::MaterialDesignController::IsModeMaterial()) { |
| 396 show_all_view_md_->SetEnabledTextColors( |
| 397 GetThemeProvider()->GetColor(ThemeProperties::COLOR_BOOKMARK_TEXT)); |
| 398 } else { |
| 396 views::Link* show_all_view = static_cast<views::Link*>(show_all_view_); | 399 views::Link* show_all_view = static_cast<views::Link*>(show_all_view_); |
| 397 show_all_view->SetBackgroundColor(background()->get_color()); | 400 show_all_view->SetBackgroundColor(background()->get_color()); |
| 398 show_all_view->SetEnabledColor( | 401 show_all_view->SetEnabledColor( |
| 399 GetThemeProvider()->GetColor(ThemeProperties::COLOR_BOOKMARK_TEXT)); | 402 GetThemeProvider()->GetColor(ThemeProperties::COLOR_BOOKMARK_TEXT)); |
| 400 | 403 |
| 401 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 404 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 402 close_button_->SetBackground( | 405 close_button_->SetBackground( |
| 403 GetThemeProvider()->GetColor(ThemeProperties::COLOR_TAB_TEXT), | 406 GetThemeProvider()->GetColor(ThemeProperties::COLOR_TAB_TEXT), |
| 404 rb.GetImageSkiaNamed(IDR_CLOSE_1), | 407 rb.GetImageSkiaNamed(IDR_CLOSE_1), |
| 405 rb.GetImageSkiaNamed(IDR_CLOSE_1_MASK)); | 408 rb.GetImageSkiaNamed(IDR_CLOSE_1_MASK)); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 489 | 492 |
| 490 content::DownloadItem* DownloadShelfView::GetDownloadItemForView(size_t i) { | 493 content::DownloadItem* DownloadShelfView::GetDownloadItemForView(size_t i) { |
| 491 if (ui::MaterialDesignController::IsModeMaterial()) | 494 if (ui::MaterialDesignController::IsModeMaterial()) |
| 492 return static_cast<DownloadItemViewMd*>(download_views_[i])->download(); | 495 return static_cast<DownloadItemViewMd*>(download_views_[i])->download(); |
| 493 return static_cast<DownloadItemView*>(download_views_[i])->download(); | 496 return static_cast<DownloadItemView*>(download_views_[i])->download(); |
| 494 } | 497 } |
| 495 | 498 |
| 496 SkColor DownloadShelfView::GetTextColorForIconMd() { | 499 SkColor DownloadShelfView::GetTextColorForIconMd() { |
| 497 return DownloadItemViewMd::GetTextColorForThemeProvider(GetThemeProvider()); | 500 return DownloadItemViewMd::GetTextColorForThemeProvider(GetThemeProvider()); |
| 498 } | 501 } |
| OLD | NEW |