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

Side by Side Diff: chrome/browser/ui/views/frame/browser_view.cc

Issue 1492423003: Rejigger ThemeService: move exposure of ThemeProvider interface to a (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix that unittest Created 5 years 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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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/frame/browser_view.h" 5 #include "chrome/browser/ui/views/frame/browser_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 20 matching lines...) Expand all
31 #include "chrome/browser/profiles/profile.h" 31 #include "chrome/browser/profiles/profile.h"
32 #include "chrome/browser/profiles/profile_avatar_icon_util.h" 32 #include "chrome/browser/profiles/profile_avatar_icon_util.h"
33 #include "chrome/browser/profiles/profile_info_cache.h" 33 #include "chrome/browser/profiles/profile_info_cache.h"
34 #include "chrome/browser/profiles/profile_manager.h" 34 #include "chrome/browser/profiles/profile_manager.h"
35 #include "chrome/browser/profiles/profile_window.h" 35 #include "chrome/browser/profiles/profile_window.h"
36 #include "chrome/browser/profiles/profiles_state.h" 36 #include "chrome/browser/profiles/profiles_state.h"
37 #include "chrome/browser/search/search.h" 37 #include "chrome/browser/search/search.h"
38 #include "chrome/browser/sessions/tab_restore_service_factory.h" 38 #include "chrome/browser/sessions/tab_restore_service_factory.h"
39 #include "chrome/browser/signin/chrome_signin_helper.h" 39 #include "chrome/browser/signin/chrome_signin_helper.h"
40 #include "chrome/browser/themes/theme_properties.h" 40 #include "chrome/browser/themes/theme_properties.h"
41 #include "chrome/browser/themes/theme_service_factory.h"
42 #include "chrome/browser/translate/chrome_translate_client.h" 41 #include "chrome/browser/translate/chrome_translate_client.h"
43 #include "chrome/browser/ui/ash/ash_util.h" 42 #include "chrome/browser/ui/ash/ash_util.h"
44 #include "chrome/browser/ui/bookmarks/bookmark_bar_constants.h" 43 #include "chrome/browser/ui/bookmarks/bookmark_bar_constants.h"
45 #include "chrome/browser/ui/bookmarks/bookmark_bubble_sign_in_delegate.h" 44 #include "chrome/browser/ui/bookmarks/bookmark_bubble_sign_in_delegate.h"
46 #include "chrome/browser/ui/browser.h" 45 #include "chrome/browser/ui/browser.h"
47 #include "chrome/browser/ui/browser_command_controller.h" 46 #include "chrome/browser/ui/browser_command_controller.h"
48 #include "chrome/browser/ui/browser_commands.h" 47 #include "chrome/browser/ui/browser_commands.h"
49 #include "chrome/browser/ui/browser_dialogs.h" 48 #include "chrome/browser/ui/browser_dialogs.h"
50 #include "chrome/browser/ui/browser_finder.h" 49 #include "chrome/browser/ui/browser_finder.h"
51 #include "chrome/browser/ui/browser_list.h" 50 #include "chrome/browser/ui/browser_list.h"
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 int y = at_top ? 0 : (view->height() - thickness); 202 int y = at_top ? 0 : (view->height() - thickness);
204 canvas->FillRect(gfx::Rect(0, y, view->width(), thickness), color); 203 canvas->FillRect(gfx::Rect(0, y, view->width(), thickness), color);
205 } 204 }
206 205
207 // TODO(kuan): These functions are temporarily for the bookmark bar while its 206 // TODO(kuan): These functions are temporarily for the bookmark bar while its
208 // detached state is at the top of the page; it'll be moved to float on the 207 // detached state is at the top of the page; it'll be moved to float on the
209 // content page in the very near future, at which time, these local functions 208 // content page in the very near future, at which time, these local functions
210 // will be removed. 209 // will be removed.
211 void PaintDetachedBookmarkBar(gfx::Canvas* canvas, 210 void PaintDetachedBookmarkBar(gfx::Canvas* canvas,
212 BookmarkBarView* view, 211 BookmarkBarView* view,
213 ThemeService* theme_service) { 212 Profile* profile) {
214 // Paint background for detached state; if animating, this is fade in/out. 213 // Paint background for detached state; if animating, this is fade in/out.
215 canvas->DrawColor( 214 canvas->DrawColor(chrome::GetDetachedBookmarkBarBackgroundColor(profile));
216 chrome::GetDetachedBookmarkBarBackgroundColor(theme_service));
217 // Draw the separators above and below bookmark bar; 215 // Draw the separators above and below bookmark bar;
218 // if animating, these are fading in/out. 216 // if animating, these are fading in/out.
219 SkColor separator_color = 217 SkColor separator_color =
220 chrome::GetDetachedBookmarkBarSeparatorColor(theme_service); 218 chrome::GetDetachedBookmarkBarSeparatorColor(profile);
221 219
222 if (ui::MaterialDesignController::IsModeMaterial()) { 220 if (ui::MaterialDesignController::IsModeMaterial()) {
223 BrowserView::Paint1pxHorizontalLine( 221 BrowserView::Paint1pxHorizontalLine(
224 canvas, separator_color, 222 canvas, separator_color,
225 gfx::Rect(0, 0, view->width(), 223 gfx::Rect(0, 0, view->width(),
226 views::NonClientFrameView::kClientEdgeThickness), 224 views::NonClientFrameView::kClientEdgeThickness),
227 true); 225 true);
228 } else { 226 } else {
229 PaintHorizontalBorder(canvas, view, true, separator_color); 227 PaintHorizontalBorder(canvas, view, true, separator_color);
230 } 228 }
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 browser_view_, 408 browser_view_,
411 browser_->host_desktop_type(), 409 browser_->host_desktop_type(),
412 toolbar_overlap); 410 toolbar_overlap);
413 return; 411 return;
414 } 412 }
415 413
416 // As 'hidden' according to the animation is the full in-tab state, we invert 414 // As 'hidden' according to the animation is the full in-tab state, we invert
417 // the value - when current_state is at '0', we expect the bar to be docked. 415 // the value - when current_state is at '0', we expect the bar to be docked.
418 double current_state = 1 - bookmark_bar_view_->GetAnimationValue(); 416 double current_state = 1 - bookmark_bar_view_->GetAnimationValue();
419 417
420 ThemeService* ts = ThemeServiceFactory::GetForProfile(browser_->profile());
421 if (current_state == 0.0 || current_state == 1.0) { 418 if (current_state == 0.0 || current_state == 1.0) {
422 PaintDetachedBookmarkBar(canvas, bookmark_bar_view_, ts); 419 PaintDetachedBookmarkBar(canvas, bookmark_bar_view_, browser_->profile());
423 return; 420 return;
424 } 421 }
425 // While animating, set opacity to cross-fade between attached and detached 422 // While animating, set opacity to cross-fade between attached and detached
426 // backgrounds including their respective separators. 423 // backgrounds including their respective separators.
427 int detached_alpha = static_cast<uint8>(current_state * 255); 424 int detached_alpha = static_cast<uint8>(current_state * 255);
428 int attached_alpha = 255 - detached_alpha; 425 int attached_alpha = 255 - detached_alpha;
429 if (browser_->bookmark_bar_state() == BookmarkBar::DETACHED) { 426 if (browser_->bookmark_bar_state() == BookmarkBar::DETACHED) {
430 // To animate from attached to detached state: 427 // To animate from attached to detached state:
431 // - fade out attached background 428 // - fade out attached background
432 // - fade in detached background. 429 // - fade in detached background.
433 canvas->SaveLayerAlpha(attached_alpha); 430 canvas->SaveLayerAlpha(attached_alpha);
434 PaintAttachedBookmarkBar(canvas, 431 PaintAttachedBookmarkBar(canvas,
435 bookmark_bar_view_, 432 bookmark_bar_view_,
436 browser_view_, 433 browser_view_,
437 browser_->host_desktop_type(), 434 browser_->host_desktop_type(),
438 toolbar_overlap); 435 toolbar_overlap);
439 canvas->Restore(); 436 canvas->Restore();
440 canvas->SaveLayerAlpha(detached_alpha); 437 canvas->SaveLayerAlpha(detached_alpha);
441 PaintDetachedBookmarkBar(canvas, bookmark_bar_view_, ts); 438 PaintDetachedBookmarkBar(canvas, bookmark_bar_view_, browser_->profile());
442 } else { 439 } else {
443 // To animate from detached to attached state: 440 // To animate from detached to attached state:
444 // - fade out detached background 441 // - fade out detached background
445 // - fade in attached background. 442 // - fade in attached background.
446 canvas->SaveLayerAlpha(detached_alpha); 443 canvas->SaveLayerAlpha(detached_alpha);
447 PaintDetachedBookmarkBar(canvas, bookmark_bar_view_, ts); 444 PaintDetachedBookmarkBar(canvas, bookmark_bar_view_, browser_->profile());
448 canvas->Restore(); 445 canvas->Restore();
449 canvas->SaveLayerAlpha(attached_alpha); 446 canvas->SaveLayerAlpha(attached_alpha);
450 PaintAttachedBookmarkBar(canvas, 447 PaintAttachedBookmarkBar(canvas,
451 bookmark_bar_view_, 448 bookmark_bar_view_,
452 browser_view_, 449 browser_view_,
453 browser_->host_desktop_type(), 450 browser_->host_desktop_type(),
454 toolbar_overlap); 451 toolbar_overlap);
455 } 452 }
456 canvas->Restore(); 453 canvas->Restore();
457 } 454 }
(...skipping 2239 matching lines...) Expand 10 before | Expand all | Expand 10 after
2697 return immersive_mode_controller()->IsEnabled(); 2694 return immersive_mode_controller()->IsEnabled();
2698 } 2695 }
2699 2696
2700 views::Widget* BrowserView::GetBubbleAssociatedWidget() { 2697 views::Widget* BrowserView::GetBubbleAssociatedWidget() {
2701 return GetWidget(); 2698 return GetWidget();
2702 } 2699 }
2703 2700
2704 gfx::Rect BrowserView::GetTopContainerBoundsInScreen() { 2701 gfx::Rect BrowserView::GetTopContainerBoundsInScreen() {
2705 return top_container_->GetBoundsInScreen(); 2702 return top_container_->GetBoundsInScreen();
2706 } 2703 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/frame/browser_frame.cc ('k') | chrome/browser/ui/views/toolbar/back_button.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698