Chromium Code Reviews| 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" |
| 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/themes/theme_service.h" | |
| 16 #include "chrome/browser/themes/theme_service_factory.h" | |
| 15 #include "chrome/browser/ui/browser.h" | 17 #include "chrome/browser/ui/browser.h" |
| 16 #include "chrome/browser/ui/chrome_pages.h" | 18 #include "chrome/browser/ui/chrome_pages.h" |
| 17 #include "chrome/browser/ui/view_ids.h" | 19 #include "chrome/browser/ui/view_ids.h" |
| 18 #include "chrome/browser/ui/views/download/download_item_view.h" | 20 #include "chrome/browser/ui/views/download/download_item_view.h" |
| 19 #include "chrome/browser/ui/views/frame/browser_view.h" | 21 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 20 #include "chrome/grit/generated_resources.h" | 22 #include "chrome/grit/generated_resources.h" |
| 21 #include "chrome/grit/theme_resources.h" | 23 #include "chrome/grit/theme_resources.h" |
| 22 #include "components/strings/grit/components_strings.h" | 24 #include "components/strings/grit/components_strings.h" |
| 23 #include "content/public/browser/download_item.h" | 25 #include "content/public/browser/download_item.h" |
| 24 #include "content/public/browser/download_manager.h" | 26 #include "content/public/browser/download_manager.h" |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 302 kStartPadding; | 304 kStartPadding; |
| 303 if (available_width <= 0) | 305 if (available_width <= 0) |
| 304 return false; | 306 return false; |
| 305 | 307 |
| 306 gfx::Size item_size = (*download_views_.rbegin())->GetPreferredSize(); | 308 gfx::Size item_size = (*download_views_.rbegin())->GetPreferredSize(); |
| 307 return item_size.width() < available_width; | 309 return item_size.width() < available_width; |
| 308 } | 310 } |
| 309 | 311 |
| 310 void DownloadShelfView::UpdateColorsFromTheme() { | 312 void DownloadShelfView::UpdateColorsFromTheme() { |
| 311 if (show_all_view_ && close_button_ && GetThemeProvider()) { | 313 if (show_all_view_ && close_button_ && GetThemeProvider()) { |
| 312 set_background(views::Background::CreateSolidBackground( | 314 const SkColor bg_color = |
| 313 GetThemeProvider()->GetColor(ThemeProperties::COLOR_TOOLBAR))); | 315 GetThemeProvider()->GetColor(ThemeProperties::COLOR_TOOLBAR); |
| 316 set_background(views::Background::CreateSolidBackground(bg_color)); | |
| 314 show_all_view_->SetEnabledTextColors( | 317 show_all_view_->SetEnabledTextColors( |
| 315 GetThemeProvider()->GetColor(ThemeProperties::COLOR_BOOKMARK_TEXT)); | 318 GetThemeProvider()->GetColor(ThemeProperties::COLOR_BOOKMARK_TEXT)); |
| 319 if (ThemeServiceFactory::GetForProfile(browser_->profile()) | |
| 320 ->UsingDefaultTheme()) { | |
| 321 // For the normal theme, just use the default button bg color. | |
| 322 show_all_view_->SetBgColorOverride(base::Optional<SkColor>()); | |
| 323 } else { | |
| 324 // For custom themes, we have to make up a background color for the | |
| 325 // button. Use a slight tint of the shelf background. | |
| 326 show_all_view_->SetBgColorOverride( | |
| 327 color_utils::BlendTowardOppositeLuma(bg_color, 0x10)); | |
| 328 } | |
| 329 show_all_view_->SchedulePaint(); | |
|
sky
2016/10/06 17:09:45
In general I would expect changing properties on v
Evan Stade
2016/10/06 17:43:37
this was leftover from a previous iteration of the
| |
| 316 } | 330 } |
| 317 } | 331 } |
| 318 | 332 |
| 319 void DownloadShelfView::OnThemeChanged() { | 333 void DownloadShelfView::OnThemeChanged() { |
| 320 UpdateColorsFromTheme(); | 334 UpdateColorsFromTheme(); |
| 321 } | 335 } |
| 322 | 336 |
| 323 void DownloadShelfView::LinkClicked(views::Link* source, int event_flags) { | 337 void DownloadShelfView::LinkClicked(views::Link* source, int event_flags) { |
| 324 chrome::ShowDownloads(browser_); | 338 chrome::ShowDownloads(browser_); |
| 325 } | 339 } |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 392 SetVisible(false); | 406 SetVisible(false); |
| 393 } | 407 } |
| 394 | 408 |
| 395 bool DownloadShelfView::CanAutoClose() { | 409 bool DownloadShelfView::CanAutoClose() { |
| 396 for (size_t i = 0; i < download_views_.size(); ++i) { | 410 for (size_t i = 0; i < download_views_.size(); ++i) { |
| 397 if (!download_views_[i]->download()->GetOpened()) | 411 if (!download_views_[i]->download()->GetOpened()) |
| 398 return false; | 412 return false; |
| 399 } | 413 } |
| 400 return true; | 414 return true; |
| 401 } | 415 } |
| OLD | NEW |