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

Unified Diff: chrome/browser/ui/cocoa/apps/native_app_window_cocoa.mm

Issue 251993002: [Mac] Implement frame.[color|inactiveColor]. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Only SetFullScreenCollectionBehavior on Lion or later. Created 6 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/cocoa/apps/native_app_window_cocoa.h ('k') | chrome/common/chrome_switches.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/cocoa/apps/native_app_window_cocoa.mm
diff --git a/chrome/browser/ui/cocoa/apps/native_app_window_cocoa.mm b/chrome/browser/ui/cocoa/apps/native_app_window_cocoa.mm
index 1b4af00c233e59d6bd8852160a0956b28d7474ab..ef35007322dd2774c0e04fcaf9bc9f162b36caee 100644
--- a/chrome/browser/ui/cocoa/apps/native_app_window_cocoa.mm
+++ b/chrome/browser/ui/cocoa/apps/native_app_window_cocoa.mm
@@ -6,6 +6,7 @@
#include "apps/app_shim/extension_app_shim_handler_mac.h"
#include "base/command_line.h"
+#include "base/mac/foundation_util.h"
#include "base/mac/mac_util.h"
#include "base/strings/sys_string_conversions.h"
#include "chrome/browser/profiles/profile.h"
@@ -20,6 +21,7 @@
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_view.h"
#include "extensions/common/extension.h"
+#include "skia/ext/skia_utils_mac.h"
#include "third_party/skia/include/core/SkRegion.h"
#include "ui/gfx/skia_util.h"
@@ -223,9 +225,15 @@ std::vector<gfx::Rect> CalculateNonDraggableRegions(
@implementation ShellNSWindow
@end
-@interface ShellCustomFrameNSWindow : ShellNSWindow
+@interface ShellCustomFrameNSWindow : ShellNSWindow {
+ @private
+ base::scoped_nsobject<NSColor> color_;
+ base::scoped_nsobject<NSColor> inactiveColor_;
+}
- (void)drawCustomFrameRect:(NSRect)rect forView:(NSView*)view;
+- (void)setColor:(NSColor*)color
+ inactiveColor:(NSColor*)inactiveColor;
@end
@@ -243,18 +251,30 @@ std::vector<gfx::Rect> CalculateNonDraggableRegions(
[[NSBezierPath bezierPathWithRoundedRect:[view bounds]
xRadius:cornerRadius
yRadius:cornerRadius] addClip];
- [[NSColor whiteColor] set];
+ if ([self isMainWindow] || [self isKeyWindow])
+ [color_ set];
+ else
+ [inactiveColor_ set];
NSRectFill(rect);
}
-@end
+- (void)setColor:(NSColor*)color
+ inactiveColor:(NSColor*)inactiveColor {
+ color_.reset([color retain]);
+ inactiveColor_.reset([inactiveColor retain]);
+}
-@interface ShellFramelessNSWindow : ShellCustomFrameNSWindow
+@end
+@interface ShellFramelessNSWindow : ShellNSWindow
+- (void)drawCustomFrameRect:(NSRect)rect forView:(NSView*)view;
@end
@implementation ShellFramelessNSWindow
+- (void)drawCustomFrameRect:(NSRect)rect forView:(NSView*)view {
+}
+
+ (NSRect)frameRectForContentRect:(NSRect)contentRect
styleMask:(NSUInteger)mask {
return contentRect;
@@ -306,17 +326,17 @@ NativeAppWindowCocoa::NativeAppWindowCocoa(
is_resizable_(params.resizable),
shows_resize_controls_(true),
shows_fullscreen_controls_(true),
+ has_frame_color_(params.has_frame_color),
+ active_frame_color_(params.active_frame_color),
+ inactive_frame_color_(params.inactive_frame_color),
attention_request_id_(0) {
Observe(web_contents());
base::scoped_nsobject<NSWindow> window;
Class window_class;
if (has_frame_) {
- bool should_use_native_frame =
- CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kAppsUseNativeFrame);
- window_class = should_use_native_frame ?
- [ShellNSWindow class] : [ShellCustomFrameNSWindow class];
+ window_class = has_frame_color_ ?
+ [ShellCustomFrameNSWindow class] : [ShellNSWindow class];
} else {
window_class = [ShellFramelessNSWindow class];
}
@@ -332,6 +352,11 @@ NativeAppWindowCocoa::NativeAppWindowCocoa(
defer:NO]);
[window setTitle:base::SysUTF8ToNSString(extension()->name())];
[[window contentView] cr_setWantsLayer:YES];
+ if (has_frame_ && has_frame_color_) {
+ [base::mac::ObjCCastStrict<ShellCustomFrameNSWindow>(window)
+ setColor:gfx::SkColorToSRGBNSColor(active_frame_color_)
+ inactiveColor:gfx::SkColorToSRGBNSColor(inactive_frame_color_)];
+ }
if (base::mac::IsOSSnowLeopard() &&
[window respondsToSelector:@selector(setBottomCornerRounded:)])
@@ -373,11 +398,8 @@ NSUInteger NativeAppWindowCocoa::GetWindowStyleMask() const {
NSMiniaturizableWindowMask;
if (shows_resize_controls_)
style_mask |= NSResizableWindowMask;
- if (!has_frame_ ||
- !CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kAppsUseNativeFrame)) {
+ if (!has_frame_)
style_mask |= NSTexturedBackgroundWindowMask;
- }
return style_mask;
}
@@ -719,18 +741,15 @@ bool NativeAppWindowCocoa::IsFrameless() const {
}
bool NativeAppWindowCocoa::HasFrameColor() const {
- // TODO(benwells): Implement this.
- return false;
+ return has_frame_color_;
}
SkColor NativeAppWindowCocoa::ActiveFrameColor() const {
- // TODO(benwells): Implement this.
- return SkColor();
+ return active_frame_color_;
}
SkColor NativeAppWindowCocoa::InactiveFrameColor() const {
- // TODO(benwells): Implement this.
- return SkColor();
+ return inactive_frame_color_;
}
gfx::Insets NativeAppWindowCocoa::GetFrameInsets() const {
@@ -825,8 +844,10 @@ void NativeAppWindowCocoa::WindowDidFinishResize() {
is_fullscreen_ = ([window() styleMask] & NSFullScreenWindowMask) != 0;
// If not fullscreen but the window is constrained, disable the fullscreen UI
// control.
- if (!is_fullscreen_ && !shows_fullscreen_controls_)
+ if (!is_fullscreen_ && !shows_fullscreen_controls_ &&
+ base::mac::IsOSLionOrLater()) {
SetFullScreenCollectionBehavior(window(), false);
+ }
UpdateRestoredBounds();
}
@@ -916,7 +937,8 @@ void NativeAppWindowCocoa::SetContentSizeConstraints(
// Set the window to participate in Lion Fullscreen mode. Setting this flag
// has no effect on Snow Leopard or earlier. UI controls for fullscreen are
// only shown for apps that have unbounded size.
- SetFullScreenCollectionBehavior(window(), shows_fullscreen_controls_);
+ if (base::mac::IsOSLionOrLater())
+ SetFullScreenCollectionBehavior(window(), shows_fullscreen_controls_);
}
if (has_frame_) {
« no previous file with comments | « chrome/browser/ui/cocoa/apps/native_app_window_cocoa.h ('k') | chrome/common/chrome_switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698