#include "chrome/browser/ui/cocoa/apps/native_app_window_cocoa.h"
-#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/mac/sdk_forward_declarations.h"
#include "base/strings/sys_string_conversions.h"
+#include "chrome/browser/apps/app_shim/extension_app_shim_handler_mac.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/cocoa/browser_window_utils.h"
#import "chrome/browser/ui/cocoa/chrome_event_processing_window.h"
// windowWillUseStandardFrame, as the window would not restore back to the
// desired size.
-using apps::AppWindow;
+using extensions::AppWindow;
@interface NSWindow (NSPrivateApis)
- (void)setBottomCornerRounded:(BOOL)rounded;
[window setCollectionBehavior:behavior];
}
+void SetWorkspacesCollectionBehavior(NSWindow* window, bool always_visible) {
+ NSWindowCollectionBehavior behavior = [window collectionBehavior];
+ if (always_visible)
+ behavior |= NSWindowCollectionBehaviorCanJoinAllSpaces;
+ else
+ behavior &= ~NSWindowCollectionBehaviorCanJoinAllSpaces;
+ [window setCollectionBehavior:behavior];
+}
+
void InitCollectionBehavior(NSWindow* window) {
// Since always-on-top windows have a higher window level
// than NSNormalWindowLevel, they will default to
}
NSRect GfxToCocoaBounds(gfx::Rect bounds) {
- typedef apps::AppWindow::BoundsSpecification BoundsSpecification;
+ typedef AppWindow::BoundsSpecification BoundsSpecification;
NSRect main_screen_rect = [[[NSScreen screens] objectAtIndex:0] frame];
- (CGFloat)roundedCornerRadius;
@end
-// TODO(jamescook): Should these be AppNSWindow to match apps::AppWindow?
+// TODO(jamescook): Should these be AppNSWindow to match AppWindow?
// http://crbug.com/344082
@interface ShellNSWindow : ChromeEventProcessingWindow
@end
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) {
+ inactive_frame_color_(params.inactive_frame_color) {
Observe(WebContents());
base::scoped_nsobject<NSWindow> window;
[window setLevel:AlwaysOnTopWindowLevel()];
InitCollectionBehavior(window);
+ SetWorkspacesCollectionBehavior(window, params.visible_on_all_workspaces);
+
window_controller_.reset(
[[NativeAppWindowController alloc] initWithWindow:window.release()]);
return is_fullscreen_;
}
-bool NativeAppWindowCocoa::IsDetached() const {
- return false;
-}
-
gfx::NativeWindow NativeAppWindowCocoa::GetNativeWindow() {
return window();
}
if (is_hidden_with_app_) {
// If there is a shim to gently request attention, return here. Otherwise
// show the window as usual.
- if (apps::ExtensionAppShimHandler::RequestUserAttentionForWindow(
+ if (apps::ExtensionAppShimHandler::ActivateAndRequestUserAttentionForWindow(
app_window_)) {
return;
}
}
void NativeAppWindowCocoa::FlashFrame(bool flash) {
- if (flash) {
- attention_request_id_ = [NSApp requestUserAttention:NSInformationalRequest];
- } else {
- [NSApp cancelUserAttentionRequest:attention_request_id_];
- attention_request_id_ = 0;
- }
+ apps::ExtensionAppShimHandler::RequestUserAttentionForWindow(
+ app_window_,
+ flash ? apps::APP_SHIM_ATTENTION_CRITICAL
+ : apps::APP_SHIM_ATTENTION_CANCEL);
}
bool NativeAppWindowCocoa::IsAlwaysOnTop() const {
minimum_size.height())];
gfx::Size maximum_size = size_constraints_.GetMaximumSize();
- const int kUnboundedSize = apps::SizeConstraints::kUnboundedSize;
+ const int kUnboundedSize = extensions::SizeConstraints::kUnboundedSize;
CGFloat max_width = maximum_size.width() == kUnboundedSize ?
CGFLOAT_MAX : maximum_size.width();
CGFloat max_height = maximum_size.height() == kUnboundedSize ?
NSNormalWindowLevel)];
}
+void NativeAppWindowCocoa::SetVisibleOnAllWorkspaces(bool always_visible) {
+ SetWorkspacesCollectionBehavior(window(), always_visible);
+}
+
NativeAppWindowCocoa::~NativeAppWindowCocoa() {
}