| 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 #import "chrome/browser/ui/cocoa/framed_browser_window.h" | 5 #import "chrome/browser/ui/cocoa/framed_browser_window.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/mac/sdk_forward_declarations.h" | 10 #include "base/mac/sdk_forward_declarations.h" |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 else if (active && !incognito) | 269 else if (active && !incognito) |
| 270 themeImageID = IDR_THEME_FRAME; | 270 themeImageID = IDR_THEME_FRAME; |
| 271 else if (!active && incognito) | 271 else if (!active && incognito) |
| 272 themeImageID = IDR_THEME_FRAME_INCOGNITO_INACTIVE; | 272 themeImageID = IDR_THEME_FRAME_INCOGNITO_INACTIVE; |
| 273 else | 273 else |
| 274 themeImageID = IDR_THEME_FRAME_INACTIVE; | 274 themeImageID = IDR_THEME_FRAME_INACTIVE; |
| 275 if (themeProvider->HasCustomImage(IDR_THEME_FRAME)) | 275 if (themeProvider->HasCustomImage(IDR_THEME_FRAME)) |
| 276 themeImageColor = themeProvider->GetNSImageColorNamed(themeImageID); | 276 themeImageColor = themeProvider->GetNSImageColorNamed(themeImageID); |
| 277 } | 277 } |
| 278 | 278 |
| 279 // If not Material Design, use a gradient if Incognito and no theme image. | |
| 280 NSGradient* gradient = nil; | |
| 281 if (!ui::MaterialDesignController::IsModeMaterial() && | |
| 282 !themeImageColor && incognito) | |
| 283 gradient = themeProvider->GetNSGradient( | |
| 284 active ? ThemeProperties::GRADIENT_FRAME_INCOGNITO : | |
| 285 ThemeProperties::GRADIENT_FRAME_INCOGNITO_INACTIVE); | |
| 286 | |
| 287 BOOL themed = NO; | 279 BOOL themed = NO; |
| 288 if (themeImageColor) { | 280 if (themeImageColor) { |
| 289 // Default to replacing any existing pixels with the theme image, but if | 281 // Default to replacing any existing pixels with the theme image, but if |
| 290 // asked paint black first and blend the theme with black. | 282 // asked paint black first and blend the theme with black. |
| 291 NSCompositingOperation operation = NSCompositeCopy; | 283 NSCompositingOperation operation = NSCompositeCopy; |
| 292 if (forceBlackBackground) { | 284 if (forceBlackBackground) { |
| 293 [[NSColor blackColor] set]; | 285 [[NSColor blackColor] set]; |
| 294 NSRectFill(dirtyRect); | 286 NSRectFill(dirtyRect); |
| 295 operation = NSCompositeSourceOver; | 287 operation = NSCompositeSourceOver; |
| 296 } | 288 } |
| 297 | 289 |
| 298 NSPoint position = [[view window] themeImagePositionForAlignment: | 290 NSPoint position = [[view window] themeImagePositionForAlignment: |
| 299 THEME_IMAGE_ALIGN_WITH_FRAME]; | 291 THEME_IMAGE_ALIGN_WITH_FRAME]; |
| 300 [[NSGraphicsContext currentContext] cr_setPatternPhase:position | 292 [[NSGraphicsContext currentContext] cr_setPatternPhase:position |
| 301 forView:view]; | 293 forView:view]; |
| 302 | 294 |
| 303 [themeImageColor set]; | 295 [themeImageColor set]; |
| 304 NSRectFillUsingOperation(dirtyRect, operation); | 296 NSRectFillUsingOperation(dirtyRect, operation); |
| 305 themed = YES; | 297 themed = YES; |
| 306 } else if (gradient) { | |
| 307 NSPoint startPoint = NSMakePoint(NSMinX(bounds), NSMaxY(bounds)); | |
| 308 NSPoint endPoint = startPoint; | |
| 309 endPoint.y -= kBrowserFrameViewPaintHeight; | |
| 310 [gradient drawFromPoint:startPoint toPoint:endPoint options:0]; | |
| 311 themed = YES; | |
| 312 } | 298 } |
| 313 | 299 |
| 314 // Check to see if we have an overlay image. | 300 // Check to see if we have an overlay image. |
| 315 NSImage* overlayImage = nil; | 301 NSImage* overlayImage = nil; |
| 316 if (themeProvider->HasCustomImage(IDR_THEME_FRAME_OVERLAY) && !incognito && | 302 if (themeProvider->HasCustomImage(IDR_THEME_FRAME_OVERLAY) && !incognito && |
| 317 !popup) { | 303 !popup) { |
| 318 overlayImage = themeProvider-> | 304 overlayImage = themeProvider-> |
| 319 GetNSImageNamed(active ? IDR_THEME_FRAME_OVERLAY : | 305 GetNSImageNamed(active ? IDR_THEME_FRAME_OVERLAY : |
| 320 IDR_THEME_FRAME_OVERLAY_INACTIVE); | 306 IDR_THEME_FRAME_OVERLAY_INACTIVE); |
| 321 } | 307 } |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 [self childWindowsDidChange]; | 348 [self childWindowsDidChange]; |
| 363 } | 349 } |
| 364 | 350 |
| 365 - (void)childWindowsDidChange { | 351 - (void)childWindowsDidChange { |
| 366 id delegate = [self delegate]; | 352 id delegate = [self delegate]; |
| 367 if ([delegate respondsToSelector:@selector(childWindowsDidChange)]) | 353 if ([delegate respondsToSelector:@selector(childWindowsDidChange)]) |
| 368 [delegate childWindowsDidChange]; | 354 [delegate childWindowsDidChange]; |
| 369 } | 355 } |
| 370 | 356 |
| 371 @end | 357 @end |
| OLD | NEW |