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

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: Implement NativeAppWindow::[Active|Inactive]FrameColor 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 6e50b4cccb5897f3b1898a8a7edfe16ac9dc105f..23e8075f174dfc0f6921aba25f7b8a4bb70dfd5c 100644
--- a/chrome/browser/ui/cocoa/apps/native_app_window_cocoa.mm
+++ b/chrome/browser/ui/cocoa/apps/native_app_window_cocoa.mm
@@ -20,6 +20,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"
@@ -220,9 +221,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;
tapted 2014/04/29 00:43:29 nit: indent should be minimum 4 spaces (even if it
jackhou1 2014/04/29 02:57:50 Done.
@end
@@ -240,14 +247,22 @@ 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);
tapted 2014/04/29 00:43:29 I think ShellCustomFrameNSWindow is still used whe
jackhou1 2014/04/29 02:57:50 Around line 330, where we choose the subclass of N
}
+- (void)setColor:(NSColor*)color
+ inactiveColor:(NSColor*)inactiveColor {
tapted 2014/04/29 00:43:29 nit: indent 1 more space
jackhou1 2014/04/29 02:57:50 Done.
+ color_.reset([color retain]);
+ inactiveColor_.reset([inactiveColor retain]);
+}
+
@end
@interface ShellFramelessNSWindow : ShellCustomFrameNSWindow
-
@end
@implementation ShellFramelessNSWindow
@@ -303,17 +318,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];
tapted 2014/04/29 00:43:29 Does this mean any windows that are frame:true wil
jackhou1 2014/04/29 02:57:50 Nope, native frames will become the default.
} else {
window_class = [ShellFramelessNSWindow class];
tapted 2014/04/29 00:43:29 note I think this will also call drawCustomFrameRe
jackhou1 2014/04/29 02:57:50 Changed ShellFramelessNSWindow to subclass ShellNS
}
@@ -329,6 +344,11 @@ NativeAppWindowCocoa::NativeAppWindowCocoa(
defer:NO]);
[window setTitle:base::SysUTF8ToNSString(extension()->name())];
[[window contentView] cr_setWantsLayer:YES];
+ if (has_frame_ && has_frame_color_) {
+ [static_cast<ShellCustomFrameNSWindow*>(window)
tapted 2014/04/29 00:43:29 nit: use base::mac::ObjCCastStrict for objective C
jackhou1 2014/04/29 02:57:50 Done.
+ setColor:gfx::SkColorToSRGBNSColor(active_frame_color_)
+ inactiveColor:gfx::SkColorToSRGBNSColor(inactive_frame_color_)];
+ }
if (base::mac::IsOSSnowLeopard() &&
[window respondsToSelector:@selector(setBottomCornerRounded:)])
@@ -377,11 +397,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;
}
@@ -726,13 +743,11 @@ bool NativeAppWindowCocoa::HasFrameColor() const {
}
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 {
« 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