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

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

Issue 308583002: [Mac] Implement frame.[color|inactiveColor]. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@custom_frame_view
Patch Set: Created 6 years, 7 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 03bdf22050de1c0f938f72eed2347afe917d59ff..1a5b1d0405d8f5ac01770fff6d3bf566cae38470 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/render_widget_host_view.h"
#include "content/public/browser/web_contents.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,7 +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)setColor:(NSColor*)color
+ inactiveColor:(NSColor*)inactiveColor;
+
@end
@implementation ShellCustomFrameNSWindow
@@ -240,10 +250,19 @@ 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);
}
+- (void)setColor:(NSColor*)color
+ inactiveColor:(NSColor*)inactiveColor {
+ color_.reset([color retain]);
+ inactiveColor_.reset([inactiveColor retain]);
+}
+
@end
@interface ShellFramelessNSWindow : ShellNSWindow
@@ -303,17 +322,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(WebContents());
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];
}
@@ -334,6 +353,11 @@ NativeAppWindowCocoa::NativeAppWindowCocoa(
name = extension->name();
[window setTitle:base::SysUTF8ToNSString(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:)])
@@ -713,18 +737,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 {
@@ -918,7 +939,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