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

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

Issue 2439873002: Make all text buttons on download shelf work well with themes, not just (Closed)
Patch Set: dont set bg Created 4 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
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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 RemoveChildView(view); 160 RemoveChildView(view);
161 delete view; 161 delete view;
162 if (download_views_.empty()) 162 if (download_views_.empty())
163 Close(AUTOMATIC); 163 Close(AUTOMATIC);
164 else if (CanAutoClose()) 164 else if (CanAutoClose())
165 mouse_watcher_.Start(); 165 mouse_watcher_.Start();
166 Layout(); 166 Layout();
167 SchedulePaint(); 167 SchedulePaint();
168 } 168 }
169 169
170 void DownloadShelfView::ConfigureButtonForTheme(views::MdTextButton* button) {
171 DCHECK(GetThemeProvider());
172
173 button->SetEnabledTextColors(
174 GetThemeProvider()->GetColor(ThemeProperties::COLOR_BOOKMARK_TEXT));
175 // For the normal theme, just use the default button bg color.
176 base::Optional<SkColor> bg_color;
177 if (!ThemeServiceFactory::GetForProfile(browser_->profile())
178 ->UsingDefaultTheme()) {
179 // For custom themes, we have to make up a background color for the
180 // button. Use a slight tint of the shelf background.
181 bg_color = color_utils::BlendTowardOppositeLuma(
182 GetThemeProvider()->GetColor(ThemeProperties::COLOR_TOOLBAR), 0x10);
183 }
184 button->SetBgColorOverride(bg_color);
185 }
186
170 views::View* DownloadShelfView::GetDefaultFocusableChild() { 187 views::View* DownloadShelfView::GetDefaultFocusableChild() {
171 if (!download_views_.empty()) 188 if (!download_views_.empty())
172 return download_views_.back(); 189 return download_views_.back();
173 190
174 return show_all_view_; 191 return show_all_view_;
175 } 192 }
176 193
177 void DownloadShelfView::OnPaintBorder(gfx::Canvas* canvas) { 194 void DownloadShelfView::OnPaintBorder(gfx::Canvas* canvas) {
178 canvas->FillRect(gfx::Rect(0, 0, width(), 1), kBorderColor); 195 canvas->FillRect(gfx::Rect(0, 0, width(), 1), kBorderColor);
179 } 196 }
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 kCloseAndLinkPadding - show_all_size.width() - 320 kCloseAndLinkPadding - show_all_size.width() -
304 kStartPadding; 321 kStartPadding;
305 if (available_width <= 0) 322 if (available_width <= 0)
306 return false; 323 return false;
307 324
308 gfx::Size item_size = (*download_views_.rbegin())->GetPreferredSize(); 325 gfx::Size item_size = (*download_views_.rbegin())->GetPreferredSize();
309 return item_size.width() < available_width; 326 return item_size.width() < available_width;
310 } 327 }
311 328
312 void DownloadShelfView::UpdateColorsFromTheme() { 329 void DownloadShelfView::UpdateColorsFromTheme() {
313 if (show_all_view_ && close_button_ && GetThemeProvider()) { 330 if (!GetThemeProvider())
314 const SkColor bg_color = 331 return;
315 GetThemeProvider()->GetColor(ThemeProperties::COLOR_TOOLBAR); 332
316 set_background(views::Background::CreateSolidBackground(bg_color)); 333 if (show_all_view_)
317 show_all_view_->SetEnabledTextColors( 334 ConfigureButtonForTheme(show_all_view_);
318 GetThemeProvider()->GetColor(ThemeProperties::COLOR_BOOKMARK_TEXT)); 335
319 if (ThemeServiceFactory::GetForProfile(browser_->profile()) 336 set_background(views::Background::CreateSolidBackground(
320 ->UsingDefaultTheme()) { 337 GetThemeProvider()->GetColor(ThemeProperties::COLOR_TOOLBAR)));
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 }
330 } 338 }
331 339
332 void DownloadShelfView::OnThemeChanged() { 340 void DownloadShelfView::OnThemeChanged() {
333 UpdateColorsFromTheme(); 341 UpdateColorsFromTheme();
334 } 342 }
335 343
336 void DownloadShelfView::LinkClicked(views::Link* source, int event_flags) { 344 void DownloadShelfView::LinkClicked(views::Link* source, int event_flags) {
337 chrome::ShowDownloads(browser_); 345 chrome::ShowDownloads(browser_);
338 } 346 }
339 347
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 SetVisible(false); 413 SetVisible(false);
406 } 414 }
407 415
408 bool DownloadShelfView::CanAutoClose() { 416 bool DownloadShelfView::CanAutoClose() {
409 for (size_t i = 0; i < download_views_.size(); ++i) { 417 for (size_t i = 0; i < download_views_.size(); ++i) {
410 if (!download_views_[i]->download()->GetOpened()) 418 if (!download_views_[i]->download()->GetOpened())
411 return false; 419 return false;
412 } 420 }
413 return true; 421 return true;
414 } 422 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/download/download_shelf_view.h ('k') | ui/views/controls/button/md_text_button.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698