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

Side by Side Diff: chrome/browser/ui/cocoa/bookmarks/bookmark_bar_toolbar_view.mm

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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_toolbar_view.h" 5 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_toolbar_view.h"
6 6
7 #include "chrome/browser/search/search.h" 7 #include "chrome/browser/search/search.h"
8 #include "chrome/browser/themes/theme_properties.h" 8 #include "chrome/browser/themes/theme_properties.h"
9 #include "chrome/browser/themes/theme_service.h" 9 #include "chrome/browser/themes/theme_service.h"
10 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_constants.h" 10 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_constants.h"
(...skipping 28 matching lines...) Expand all
39 [controller_ isAnimatingToState:BookmarkBar::DETACHED] || 39 [controller_ isAnimatingToState:BookmarkBar::DETACHED] ||
40 [controller_ isAnimatingFromState:BookmarkBar::DETACHED]) { 40 [controller_ isAnimatingFromState:BookmarkBar::DETACHED]) {
41 [self drawAsDetachedBubble:dirtyRect]; 41 [self drawAsDetachedBubble:dirtyRect];
42 } else { 42 } else {
43 [self drawBackground:dirtyRect]; 43 [self drawBackground:dirtyRect];
44 } 44 }
45 } 45 }
46 46
47 - (void)drawAsDetachedBubble:(NSRect)dirtyRect { 47 - (void)drawAsDetachedBubble:(NSRect)dirtyRect {
48 CGFloat morph = [controller_ detachedMorphProgress]; 48 CGFloat morph = [controller_ detachedMorphProgress];
49 ThemeService* themeService = [controller_ themeService]; 49 Profile* profile = [controller_ profile];
50 if (!themeService) 50 if (!profile)
51 return; 51 return;
52 52
53 [[NSColor whiteColor] set]; 53 [[NSColor whiteColor] set];
54 NSRectFill(dirtyRect); 54 NSRectFill(dirtyRect);
55 55
56 // Overlay with a lighter background color. 56 // Overlay with a lighter background color.
57 NSColor* toolbarColor = skia::SkColorToCalibratedNSColor( 57 NSColor* toolbarColor = skia::SkColorToCalibratedNSColor(
58 chrome::GetDetachedBookmarkBarBackgroundColor(themeService)); 58 chrome::GetDetachedBookmarkBarBackgroundColor(profile));
59 CGFloat alpha = morph * [toolbarColor alphaComponent]; 59 CGFloat alpha = morph * [toolbarColor alphaComponent];
60 [[toolbarColor colorWithAlphaComponent:alpha] set]; 60 [[toolbarColor colorWithAlphaComponent:alpha] set];
61 NSRectFillUsingOperation(dirtyRect, NSCompositeSourceOver); 61 NSRectFillUsingOperation(dirtyRect, NSCompositeSourceOver);
62 62
63 // Fade in/out the background. 63 // Fade in/out the background.
64 { 64 {
65 gfx::ScopedNSGraphicsContextSaveGState bgScopedState; 65 gfx::ScopedNSGraphicsContextSaveGState bgScopedState;
66 NSGraphicsContext* context = [NSGraphicsContext currentContext]; 66 NSGraphicsContext* context = [NSGraphicsContext currentContext];
67 CGContextRef cgContext = static_cast<CGContextRef>([context graphicsPort]); 67 CGContextRef cgContext = static_cast<CGContextRef>([context graphicsPort]);
68 CGContextSetAlpha(cgContext, 1 - morph); 68 CGContextSetAlpha(cgContext, 1 - morph);
69 CGContextBeginTransparencyLayer(cgContext, NULL); 69 CGContextBeginTransparencyLayer(cgContext, NULL);
70 [self drawBackground:dirtyRect]; 70 [self drawBackground:dirtyRect];
71 CGContextEndTransparencyLayer(cgContext); 71 CGContextEndTransparencyLayer(cgContext);
72 } 72 }
73 73
74 // Bottom stroke. 74 // Bottom stroke.
75 NSRect strokeRect = [self bounds]; 75 NSRect strokeRect = [self bounds];
76 strokeRect.size.height = [self cr_lineWidth]; 76 strokeRect.size.height = [self cr_lineWidth];
77 if (NSIntersectsRect(strokeRect, dirtyRect)) { 77 if (NSIntersectsRect(strokeRect, dirtyRect)) {
78 NSColor* strokeColor = skia::SkColorToCalibratedNSColor( 78 NSColor* strokeColor = skia::SkColorToCalibratedNSColor(
79 chrome::GetDetachedBookmarkBarSeparatorColor(themeService)); 79 chrome::GetDetachedBookmarkBarSeparatorColor(profile));
80 strokeColor = [[self strokeColor] blendedColorWithFraction:morph 80 strokeColor = [[self strokeColor] blendedColorWithFraction:morph
81 ofColor:strokeColor]; 81 ofColor:strokeColor];
82 strokeColor = [strokeColor colorWithAlphaComponent:0.5]; 82 strokeColor = [strokeColor colorWithAlphaComponent:0.5];
83 [strokeColor set]; 83 [strokeColor set];
84 NSRectFillUsingOperation(NSIntersectionRect(strokeRect, dirtyRect), 84 NSRectFillUsingOperation(NSIntersectionRect(strokeRect, dirtyRect),
85 NSCompositeSourceOver); 85 NSCompositeSourceOver);
86 } 86 }
87 } 87 }
88 88
89 @end // @implementation BookmarkBarToolbarView 89 @end // @implementation BookmarkBarToolbarView
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698