| Index: chrome/browser/ui/cocoa/tab_contents/tab_contents_controller.mm
|
| diff --git a/chrome/browser/ui/cocoa/tab_contents/tab_contents_controller.mm b/chrome/browser/ui/cocoa/tab_contents/tab_contents_controller.mm
|
| index 65dbbcc9d6d8611ee95bf904db4c21aa0a340033..c0c314c8c203a3c4f523b5b510a280afb16c5918 100644
|
| --- a/chrome/browser/ui/cocoa/tab_contents/tab_contents_controller.mm
|
| +++ b/chrome/browser/ui/cocoa/tab_contents/tab_contents_controller.mm
|
| @@ -16,6 +16,7 @@
|
| #import "chrome/browser/themes/theme_service.h"
|
| #import "chrome/browser/ui/cocoa/themed_window.h"
|
| #include "chrome/browser/ui/view_ids.h"
|
| +#include "chrome/grit/theme_resources.h"
|
| #include "content/public/browser/render_view_host.h"
|
| #include "content/public/browser/render_widget_host.h"
|
| #include "content/public/browser/render_widget_host_view.h"
|
| @@ -90,7 +91,7 @@ @interface TabContentsContainerView : NSView {
|
| TabContentsController* delegate_; // weak
|
| }
|
|
|
| -- (void)updateBackgroundColor;
|
| +- (void)updateBackgroundColorFromWindowTheme:(NSWindow*)window;
|
| @end
|
|
|
| @implementation TabContentsContainerView
|
| @@ -102,7 +103,6 @@ - (id)initWithDelegate:(TabContentsController*)delegate {
|
| base::scoped_nsobject<CALayer> layer([[CALayer alloc] init]);
|
| [self setLayer:layer];
|
| [self setWantsLayer:YES];
|
| - [self updateBackgroundColor];
|
| }
|
| return self;
|
| }
|
| @@ -135,17 +135,27 @@ - (void)resizeSubviewsWithOldSize:(NSSize)oldBoundsSize {
|
| // Update the background layer's color whenever the view needs to repaint.
|
| - (void)setNeedsDisplayInRect:(NSRect)rect {
|
| [super setNeedsDisplayInRect:rect];
|
| - [self updateBackgroundColor];
|
| + [self updateBackgroundColorFromWindowTheme:[self window]];
|
| }
|
|
|
| -- (void)updateBackgroundColor {
|
| +- (void)updateBackgroundColorFromWindowTheme:(NSWindow*)window {
|
| // This view is sometimes flashed into visibility (e.g, when closing
|
| // windows or opening new tabs), so ensure that the flash be the theme
|
| // background color in those cases.
|
| - SkColor skBackgroundColor = SK_ColorWHITE;
|
| - const ThemeProvider* theme = [[self window] themeProvider];
|
| - if (theme)
|
| - skBackgroundColor = theme->GetColor(ThemeProperties::COLOR_NTP_BACKGROUND);
|
| + const ThemeProvider* theme = [window themeProvider];
|
| + ThemedWindowStyle windowStyle = [window themedWindowStyle];
|
| + if (!theme)
|
| + return;
|
| +
|
| + // This logic and hard-coded color value are duplicated from the function
|
| + // NTPResourceCache::CreateNewTabIncognitoCSS. This logic should exist in only
|
| + // one location.
|
| + // https://crbug.com/719236
|
| + SkColor skBackgroundColor =
|
| + theme->GetColor(ThemeProperties::COLOR_NTP_BACKGROUND);
|
| + bool incognito = windowStyle & THEMED_INCOGNITO;
|
| + if (incognito && !theme->HasCustomImage(IDR_THEME_NTP_BACKGROUND))
|
| + skBackgroundColor = SkColorSetRGB(0x32, 0x32, 0x32);
|
|
|
| // If the page is in fullscreen tab capture mode, change the background color
|
| // to be a dark tint of the new tab page's background color.
|
| @@ -164,6 +174,10 @@ - (void)updateBackgroundColor {
|
| [[self layer] setBackgroundColor:cgBackgroundColor];
|
| }
|
|
|
| +- (void)viewWillMoveToWindow:(NSWindow*)newWindow {
|
| + [self updateBackgroundColorFromWindowTheme:newWindow];
|
| +}
|
| +
|
| - (ViewID)viewID {
|
| return VIEW_ID_TAB_CONTAINER;
|
| }
|
|
|