diff --git a/exo_shell.gyp b/exo_shell.gyp index 8c62c8f..441c0ea 100644 --- a/exo_shell.gyp +++ b/exo_shell.gyp @@ -5,6 +5,7 @@ 'variables': { 'project_name': 'exo_shell', 'product_name': 'ExoShell', + 'framework_name': 'ExoShell Framework', 'app_sources': [ 'src/browser/resources/win/exo_shell.rc', 'src/browser/resources/win/resource.h', @@ -138,6 +139,18 @@ 'includes': [ 'vendor/brightray/brightray.gypi', ], + 'target_defaults': { + 'includes': [ + # Rules for excluding e.g. foo_win.cc from the build on non-Windows. + 'filename_rules.gypi', + ], + 'configurations': { + 'Debug': { + 'defines': [ 'DEBUG' ], + 'cflags': [ '-g', '-O0' ], + }, + }, + }, 'targets': [ { 'target_name': '<(project_name)', @@ -168,7 +181,7 @@ 'destination': '<(PRODUCT_DIR)/<(product_name).app/Contents/Frameworks', 'files': [ '<(PRODUCT_DIR)/<(product_name) Helper.app', - '<(PRODUCT_DIR)/<(product_name).framework', + '<(PRODUCT_DIR)/<(framework_name).framework', ], }, ], @@ -240,6 +253,8 @@ ], 'include_dirs': [ '.', + 'chromium_src', + 'vendor/brightray', ], 'direct_dependent_settings': { 'include_dirs': [ @@ -250,28 +265,17 @@ 'vendor/brightray/brightray.gyp:brightray', ], 'conditions': [ - ['OS!="linux"', { - 'sources/': [ - ['exclude', '/linux/'], - ['exclude', '_linux\.(cc|h)$'], - ], - }], - ['OS!="mac"', { - 'sources/': [ - ['exclude', '/mac/'], - ['exclude', '_mac\.(mm|h)$'], - ], - },{ - 'sources/': [ - ['exclude', '/views/'], - ['exclude', '_views\.(cc|h)$'], - ], - }], - ['OS!="win"', { - 'sources/': [ - ['exclude', '/win/'], - ['exclude', '_win\.(cc|h)$'], - ], + ['OS=="linux"', { + 'link_settings': { + 'ldflags': [ + # Make binary search for libraries under current directory, so we + # don't have to manually set $LD_LIBRARY_PATH: + # http://serverfault.com/questions/279068/cant-find-so-in-the-same-directory-as-the-executable + '-rpath \$$ORIGIN', + # Make native module dynamic loading work. + '-rdynamic', + ], + }, }], ], }, @@ -299,7 +303,7 @@ 'targets': [ { 'target_name': '<(project_name)_framework', - 'product_name': '<(product_name)', + 'product_name': '<(framework_name)', 'type': 'shared_library', 'dependencies': [ '<(project_name)_lib', @@ -307,22 +311,41 @@ 'sources': [ '<@(framework_sources)', ], + 'include_dirs': [ + '.', + 'vendor', + '<(libchromiumcontent_include_dir)', + ], + 'export_dependent_settings': [ + '<(project_name)_lib', + ], + 'link_settings': { + 'libraries': [ + '$(SDKROOT)/System/Library/Frameworks/Carbon.framework', + '$(SDKROOT)/System/Library/Frameworks/QuartzCore.framework', + ], + }, 'mac_bundle': 1, 'mac_bundle_resources': [ '<(libchromiumcontent_resources_dir)/content_shell.pak', '<(libchromiumcontent_resources_dir)/icudtl.dat', ], 'xcode_settings': { - 'LIBRARY_SEARCH_PATHS': '<(libchromiumcontent_library_dir)', - 'LD_DYLIB_INSTALL_NAME': '@rpath/<(product_name).framework/<(product_name)', - 'LD_RUNPATH_SEARCH_PATHS': '@loader_path/Libraries', + 'INFOPLIST_FILE': 'src/common/resources/mac/Info.plist', + 'LIBRARY_SEARCH_PATHS': [ + '<(libchromiumcontent_library_dir)', + ], + 'LD_DYLIB_INSTALL_NAME': '@rpath/<(framework_name).framework/<(framework_name)', + 'LD_RUNPATH_SEARCH_PATHS': [ + '@loader_path/Libraries', + ], 'OTHER_LDFLAGS': [ '-ObjC', ], }, 'copies': [ { - 'destination': '<(PRODUCT_DIR)/<(product_name).framework/Versions/A/Libraries', + 'destination': '<(PRODUCT_DIR)/<(framework_name).framework/Versions/A/Libraries', 'files': [ '<(libchromiumcontent_library_dir)/ffmpegsumo.so', '<(libchromiumcontent_library_dir)/libchromiumcontent.dylib', @@ -334,15 +357,12 @@ 'postbuild_name': 'Add symlinks for framework subdirectories', 'action': [ 'tools/mac/create-framework-subdir-symlinks.sh', - '<(product_name)', + '<(framework_name)', 'Libraries', 'Frameworks', ], }, ], - 'export_dependent_settings': [ - '<(project_name)_lib', - ], }, { 'target_name': '<(project_name)_helper', @@ -354,10 +374,15 @@ 'sources': [ '<@(app_sources)', ], + 'include_dirs': [ + '.', + ], 'mac_bundle': 1, 'xcode_settings': { 'INFOPLIST_FILE': 'src/renderer/resources/mac/Info.plist', - 'LD_RUNPATH_SEARCH_PATHS': '@executable_path/../../../../Frameworks', + 'LD_RUNPATH_SEARCH_PATHS': [ + '@executable_path/../../..', + ], }, }, ], diff --git a/filename_rules.gypi b/filename_rules.gypi new file mode 100644 index 0000000..9f69382 --- /dev/null +++ b/filename_rules.gypi @@ -0,0 +1,76 @@ +# Copyright (c) 2012 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# This gypi file defines the patterns used for determining whether a +# file is excluded from the build on a given platform. It is +# included by common.gypi for chromium_code. + +{ + 'target_conditions': [ + ['OS!="win"', { + 'sources/': [ ['exclude', '_win(_unittest)?\\.(h|cc)$'], + ['exclude', '(^|/)win/'], + ['exclude', '(^|/)win_[^/]*\\.(h|cc)$'] ], + }], + ['OS!="mac"', { + 'sources/': [ ['exclude', '_(cocoa|mac)(_unittest)?\\.(h|cc|mm?)$'], + ['exclude', '(^|/)(cocoa|mac)/'] ], + }], + ['OS!="ios"', { + 'sources/': [ ['exclude', '_ios(_unittest)?\\.(h|cc|mm?)$'], + ['exclude', '(^|/)ios/'] ], + }], + ['OS!="mac" and OS!="ios"', { + 'sources/': [ ['exclude', '\\.mm?$' ] ], + }], + # Do not exclude the linux files on *BSD since most of them can be + # shared at this point. + # In case a file is not needed, it is going to be excluded later on. + # TODO(evan): the above is not correct; we shouldn't build _linux + # files on non-linux. + ['OS!="linux" and OS!="openbsd" and OS!="freebsd"', { + 'sources/': [ + ['exclude', '_linux(_unittest)?\\.(h|cc)$'], + ['exclude', '(^|/)linux_[^/]*\\.(h|cc)$'], + ['exclude', '(^|/)linux/'], + ['exclude', '_x11(_unittest)?\\.(h|cc)$'], + ['exclude', '(^|/)x11_[^/]*\\.(h|cc)$'], + ['exclude', '(^|/)x11/'], + ], + }], + ['OS!="android"', { + 'sources/': [ + ['exclude', '_android(_unittest)?\\.cc$'], + ['exclude', '(^|/)android/'], + ], + }], + ['OS=="win"', { + 'sources/': [ + ['exclude', '_posix(_unittest)?\\.(h|cc)$'], + ['exclude', '(^|/)posix/'], + ], + }], + ['OS!="linux" and OS!="openbsd" and OS!="freebsd"', { + 'sources/': [ + ['exclude', '_xdg(_unittest)?\\.(h|cc)$'], + ], + }], + ['OS!="linux" and OS!="openbsd" and OS!="freebsd"', { + 'sources/': [ + ['exclude', '_gtk(_browsertest|_unittest)?\\.(h|cc)$'], + ['exclude', '(^|/)gtk/'], + ['exclude', '(^|/)gtk_[^/]*\\.(h|cc)$'], + ['exclude', '(^|/)libgtk2ui/'], + ['exclude', '(^|/)x/'], + ], + }], + ['OS=="mac"', { + 'sources/': [ ['exclude', '_aura(_browsertest|_unittest)?\\.(h|cc)$'], + ['exclude', '(^|/)aura/'], + ['exclude', '_views\\.(h|cc)$'], + ['exclude', '(^|/)views/'], + ], + }], + ] +} diff --git a/src/api/api_binding.h b/src/api/api_binding.h index 5cfa23c..59374ca 100644 --- a/src/api/api_binding.h +++ b/src/api/api_binding.h @@ -4,7 +4,10 @@ #ifndef EXO_SHELL_API_API_BINDING_H_ #define EXO_SHELL_API_API_BINDING_H_ +#include + #include "base/memory/scoped_ptr.h" +#include "base/values.h" #include "src/api/api_handler.h" diff --git a/src/api/api_handler.h b/src/api/api_handler.h index ffd6194..27f79ac 100644 --- a/src/api/api_handler.h +++ b/src/api/api_handler.h @@ -4,6 +4,8 @@ #ifndef EXO_SHELL_API_API_HANDLER_H_ #define EXO_SHELL_API_API_HANDLER_H_ +#include + #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" diff --git a/src/browser/browser_main_parts_mac.mm b/src/browser/browser_main_parts_mac.mm index 6141d9f..2213420 100644 --- a/src/browser/browser_main_parts_mac.mm +++ b/src/browser/browser_main_parts_mac.mm @@ -9,7 +9,7 @@ #include "base/mac/bundle_locations.h" #include "base/mac/scoped_nsobject.h" -#include "src/browser/mac/browser_application_mac.h" +#include "src/browser/mac/application_mac.h" namespace exo_shell { @@ -17,7 +17,7 @@ ExoShellMainParts::PreMainMessageLoopStart() { // Force the NSApplication subclass to be used. - NSApplication* application = [ExoShellApplication sharedApplication]; + [ExoShellApplication sharedApplication]; // Prevent Cocoa from turning command-line arguments into // |-application:openFiles:|, since we already handle them directly. diff --git a/src/browser/dialog/javascript_dialog_manager.cc b/src/browser/dialog/javascript_dialog_manager.cc index c2499e0..2fd62cd 100644 --- a/src/browser/dialog/javascript_dialog_manager.cc +++ b/src/browser/dialog/javascript_dialog_manager.cc @@ -81,11 +81,12 @@ ExoShellJavaScriptDialogManager::WebContentsDestroyed( { } +/* void ExoShellJavaScriptDialogManager::DialogClosed( JavaScriptDialog* dialog) { - /* TODO(spolu): Expose to API */ } +*/ } // namespace exo_shell diff --git a/src/browser/dialog/javascript_dialog_manager.h b/src/browser/dialog/javascript_dialog_manager.h index 3a582b6..c4ebd75 100644 --- a/src/browser/dialog/javascript_dialog_manager.h +++ b/src/browser/dialog/javascript_dialog_manager.h @@ -12,7 +12,7 @@ namespace exo_shell { -class JavaScriptDialog; +//class JavaScriptDialog; class ExoShellJavaScriptDialogManager : public content::JavaScriptDialogManager { @@ -44,7 +44,7 @@ class ExoShellJavaScriptDialogManager : content::WebContents* web_contents) OVERRIDE; // Called by the JavaScriptDialog when it closes. - void DialogClosed(JavaScriptDialog* dialog); + // void DialogClosed(JavaScriptDialog* dialog); // Used for content_browsertests. void set_dialog_request_callback(const base::Closure& callback) { @@ -54,7 +54,7 @@ class ExoShellJavaScriptDialogManager : private: #if defined(OS_MACOSX) || defined(OS_WIN) || defined(TOOLKIT_GTK) // The dialog being shown. No queueing. - scoped_ptr dialog_; + // scoped_ptr dialog_; #else /* TODO(spolu): implement JavaScriptDialog for other platforms, */ /* and then drop this #if */ diff --git a/src/browser/exo_frame_mac.mm b/src/browser/exo_frame_mac.mm deleted file mode 100644 index 81c083e..0000000 --- a/src/browser/exo_frame_mac.mm +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) 2013 Stanislas Polu. -// See the LICENSE file. - -#include "src/browser/exo_frame.h" - -#include "base/logging.h" -#import "base/mac/scoped_nsobject.h" -#include "base/strings/string_piece.h" -#include "base/strings/sys_string_conversions.h" -#include "url/gurl.h" -#import "ui/base/cocoa/underlay_opengl_hosting_window.h" -#include "content/public/browser/native_web_keyboard_event.h" -#include "content/public/browser/web_contents.h" -#include "content/public/browser/web_contents_view.h" - -using namespace content; - -namespace exo_shell { - -gfx::Size -ExoFrame::PlatformSize() -{ - WebContentsView* content_view = web_contents_->GetView(); - NSRect frame = [content_view->GetNativeView() frame]; - return gfx::Size(frame.size.width, frame.size.height); -} - -} // namespace exo_shell - diff --git a/src/browser/exo_shell.cc b/src/browser/exo_shell.cc index 472d79b..3e90c47 100644 --- a/src/browser/exo_shell.cc +++ b/src/browser/exo_shell.cc @@ -10,6 +10,7 @@ #include "base/strings/string_util.h" #include "base/strings/stringprintf.h" #include "base/strings/utf_string_conversions.h" +#include "base/threading/thread_restrictions.h" #include "ui/gfx/codec/png_codec.h" #include "content/public/browser/render_view_host.h" #include "content/public/browser/web_contents.h" diff --git a/src/browser/exo_shell.h b/src/browser/exo_shell.h index 321f7e5..d728250 100644 --- a/src/browser/exo_shell.h +++ b/src/browser/exo_shell.h @@ -14,7 +14,6 @@ #include "ui/gfx/size.h" #include "ui/gfx/point.h" #include "ui/gfx/image/image.h" -#include "ui/views/widget/widget.h" #include "content/public/browser/web_contents_delegate.h" #include "content/public/browser/notification_observer.h" #include "content/public/browser/web_contents_observer.h" @@ -24,6 +23,7 @@ #include "vendor/brightray/browser/inspectable_web_contents_impl.h" #if defined(USE_AURA) +#include "ui/views/widget/widget.h" #include "ui/views/widget/widget_delegate.h" #include "ui/views/widget/widget_observer.h" #endif diff --git a/src/browser/exo_shell_mac.mm b/src/browser/exo_shell_mac.mm index 354b16c..f7a8e65 100644 --- a/src/browser/exo_shell_mac.mm +++ b/src/browser/exo_shell_mac.mm @@ -14,9 +14,7 @@ #include "content/public/browser/native_web_keyboard_event.h" #include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents_view.h" - -#include "src/app/resource.h" -#include "src/browser/exo_frame.h" +#include "vendor/brightray/browser/inspectable_web_contents_view.h" using namespace content; @@ -26,17 +24,17 @@ // Listens for event that the window should close. @interface ExoShellWindowDelegate : NSObject { @private - exo_shell::ExoShell* browser_; + exo_shell::ExoShell* shell_; } -- (id)initWithExoShell:(exo_shell::ExoShell*)browser; +- (id)initWithShell:(exo_shell::ExoShell*) shell; @end @implementation ExoShellWindowDelegate -- (id)initWithExoShell:(exo_shell::ExoShell*)browser { +- (id)initWithShell:(exo_shell::ExoShell*) shell { if ((self = [super init])) { - browser_ = browser; + shell_ = shell; } return self; } @@ -48,8 +46,8 @@ - (id)initWithExoShell:(exo_shell::ExoShell*)browser { - (BOOL)windowShouldClose:(id)window { /* TODO(spolu): Check there is absolutely no leak here. Esp. in the case */ /* the windowShouldClose handler is due to a programmatic Kill(). */ - if(!browser_->is_killed()) { - browser_->Kill(); + if(!shell_->is_closed()) { + shell_->Close(); [self release]; } return YES; @@ -59,15 +57,15 @@ - (BOOL)windowShouldClose:(id)window { @interface ExoShellCrWindow : UnderlayOpenGLHostingWindow { @private - exo_shell::ExoShell* browser_; + exo_shell::ExoShell* shell_; } -- (void) setExoShell:(exo_shell::ExoShell*) browser; +- (void) setShell:(exo_shell::ExoShell*) shell; @end @implementation ExoShellCrWindow -- (void) setExoShell:(exo_shell::ExoShell*) browser { - browser_ = browser; +- (void) setShell:(exo_shell::ExoShell*) shell { + shell_ = shell; } @end @@ -81,12 +79,6 @@ - (void) setExoShell:(exo_shell::ExoShell*) browser { namespace exo_shell { -void -ExoShell::PlatformInitialize( - const gfx::Size& default_window_size) -{ -} - void ExoShell::PlatformCleanUp() { @@ -94,13 +86,13 @@ - (void) setExoShell:(exo_shell::ExoShell*) browser { void ExoShell::PlatformCreateWindow( - int width, - int height, - const std::string& icon_path) + const gfx::Size& size) { + LOG(INFO) << "Create Window: " << size.width() << "x" << size.height(); + /* icon_path is ignore on OSX */ NSRect initial_window_bounds = - NSMakeRect(0, 0, width, height); + NSMakeRect(0, 0, size.width(), size.height()); NSRect content_rect = initial_window_bounds; NSUInteger style_mask = NSTitledWindowMask | NSClosableWindowMask | @@ -112,9 +104,8 @@ - (void) setExoShell:(exo_shell::ExoShell*) browser { backing:NSBackingStoreBuffered defer:NO]; window_ = window; - [window setExoShell:this]; + [window setShell:this]; [window_ setTitle:kWindowTitle]; - NSView* content = [window_ contentView]; /* Set the Browser window to participate in Lion Fullscreen mode. Set */ /* Setting this flag has no effect on Snow Leopard or earlier. */ @@ -131,378 +122,91 @@ - (void) setExoShell:(exo_shell::ExoShell*) browser { /* Create a window delegate to watch for when it's asked to go away. It */ /* will clean itself up so we don't need to hold a reference. */ ExoShellWindowDelegate* delegate = - [[ExoShellWindowDelegate alloc] initWithExoShell:this]; + [[ExoShellWindowDelegate alloc] initWithShell:this]; [window_ setDelegate:delegate]; - control_left_box_ = [[[NSView alloc] init] autorelease]; - control_right_box_ = [[[NSView alloc] init] autorelease]; - control_top_box_ = [[[NSView alloc] init] autorelease]; - control_bottom_box_ = [[[NSView alloc] init] autorelease]; - horizontal_box_ = [[[NSView alloc] init] autorelease]; - pages_box_ = [[[NSView alloc] init] autorelease]; - floating_box_ = NULL; - - visible_page_ = NULL; - floating_frame_ = NULL; - floating_box_ = NULL; - - /* Vertical Layout */ - [control_top_box_ setTranslatesAutoresizingMaskIntoConstraints:NO]; - [content addSubview: control_top_box_]; - [horizontal_box_ setTranslatesAutoresizingMaskIntoConstraints:NO]; - [content addSubview: horizontal_box_]; - [control_bottom_box_ setTranslatesAutoresizingMaskIntoConstraints:NO]; - [content addSubview: control_bottom_box_]; - - NSDictionary *content_dict = - NSDictionaryOfVariableBindings(control_top_box_, - control_bottom_box_, - horizontal_box_); - [content addConstraints: - [NSLayoutConstraint - constraintsWithVisualFormat:@"V:|[control_top_box_][horizontal_box_][control_bottom_box_]|" - options:0 - metrics:nil - views:content_dict]]; - - NSArray * control_top_box_constraints = - [NSLayoutConstraint - constraintsWithVisualFormat:@"V:[control_top_box_(0)]" - options:0 - metrics:nil - views:content_dict]; - [content addConstraints: control_top_box_constraints]; - control_top_constraint_ = [control_top_box_constraints objectAtIndex: 0]; - - NSArray * control_bottom_box_constraints = - [NSLayoutConstraint - constraintsWithVisualFormat:@"V:[control_bottom_box_(0)]" - options:0 - metrics:nil - views:content_dict]; - [content addConstraints: control_bottom_box_constraints]; - control_bottom_constraint_ = [control_bottom_box_constraints objectAtIndex: 0]; - - [content addConstraints: - [NSLayoutConstraint - constraintsWithVisualFormat:@"V:[horizontal_box_(>=100)]" - options:0 - metrics:nil - views:content_dict]]; - [content addConstraints: - [NSLayoutConstraint - constraintsWithVisualFormat:@"|-0-[horizontal_box_(>=100)]-0-|" - options:0 - metrics:nil - views:content_dict]]; - [content addConstraints: - [NSLayoutConstraint - constraintsWithVisualFormat:@"|-0-[control_top_box_]-0-|" - options:0 - metrics:nil - views:content_dict]]; - [content addConstraints: - [NSLayoutConstraint - constraintsWithVisualFormat:@"|-0-[control_bottom_box_]-0-|" - options:0 - metrics:nil - views:content_dict]]; - - - /* Horizontal Layout */ - [control_left_box_ setTranslatesAutoresizingMaskIntoConstraints:NO]; - [horizontal_box_ addSubview: control_left_box_]; - [pages_box_ setTranslatesAutoresizingMaskIntoConstraints:NO]; - [horizontal_box_ addSubview: pages_box_]; - [control_right_box_ setTranslatesAutoresizingMaskIntoConstraints:NO]; - [horizontal_box_ addSubview: control_right_box_]; - - NSDictionary *horizontal_dict = - NSDictionaryOfVariableBindings(control_left_box_, - control_right_box_, - pages_box_); - - [horizontal_box_ addConstraints: - [NSLayoutConstraint - constraintsWithVisualFormat:@"|[control_left_box_][pages_box_][control_right_box_]|" - options:0 - metrics:nil - views:horizontal_dict]]; - - NSArray * control_left_box_constraints = - [NSLayoutConstraint - constraintsWithVisualFormat:@"[control_left_box_(0)]" - options:0 - metrics:nil - views:horizontal_dict]; - [horizontal_box_ addConstraints: control_left_box_constraints]; - control_left_constraint_ = [control_left_box_constraints objectAtIndex: 0]; - - NSArray * control_right_box_constraints = - [NSLayoutConstraint - constraintsWithVisualFormat:@"[control_right_box_(0)]" - options:0 - metrics:nil - views:horizontal_dict]; - [horizontal_box_ addConstraints: control_right_box_constraints]; - control_right_constraint_ = [control_right_box_constraints objectAtIndex: 0]; - - [horizontal_box_ addConstraints: - [NSLayoutConstraint - constraintsWithVisualFormat:@"[pages_box_(>=100)]" - options:0 - metrics:nil - views:horizontal_dict]]; - - [horizontal_box_ addConstraints: - [NSLayoutConstraint - constraintsWithVisualFormat:@"V:|-0-[pages_box_(>=100)]-0-|" - options:0 - metrics:nil - views:horizontal_dict]]; - [horizontal_box_ addConstraints: - [NSLayoutConstraint - constraintsWithVisualFormat:@"V:|-0-[control_left_box_]-0-|" - options:0 - metrics:nil - views:horizontal_dict]]; - [horizontal_box_ addConstraints: - [NSLayoutConstraint - constraintsWithVisualFormat:@"V:|-0-[control_right_box_]-0-|" - options:0 - metrics:nil - views:horizontal_dict]]; - - // show the window - [window_ makeKeyAndOrderFront:nil]; -} - - -void -ExoShell::PlatformSetTitle( - const std::string& title) -{ - NSString* title_string = base::SysUTF8ToNSString(title); - [window_ setTitle:title_string]; -} - + NSView* view = inspectable_web_contents()->GetView()->GetNativeView(); + [view setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable]; -void -ExoShell::PlatformKill() -{ - [window_ performClose:nil]; -} - - -void -ExoShell::PlatformAddPage( - ExoFrame *frame) -{ - /* Nothing to Do */ + [view setFrame:[[window_ contentView] bounds]]; + [[window_ contentView] addSubview:view]; } void -ExoShell::PlatformRemovePage( - ExoFrame *frame) +ExoShell::PlatformShow() { - WebContentsView* content_view = frame->web_contents_->GetView(); - if(visible_page_ == content_view->GetNativeView()) { - [visible_page_ removeFromSuperview]; - visible_page_ = NULL; - } + [window_ makeKeyAndOrderFront:nil]; } void -ExoShell::PlatformShowPage( - ExoFrame *frame) +ExoShell::PlatformClose() { - WebContentsView* content_view = frame->web_contents_->GetView(); - if(visible_page_ != content_view->GetNativeView()) { - if(visible_page_ != NULL) { - [visible_page_ removeFromSuperview]; - } - visible_page_ = content_view->GetNativeView(); - - NSRect rect = [pages_box_ bounds]; - [visible_page_ setFrame:rect]; - [visible_page_ setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)]; - [pages_box_ addSubview: visible_page_]; - - [visible_page_ setNeedsDisplay:YES]; - } + [window_ performClose:nil]; } void -ExoShell::PlatformSetControl( - CONTROL_TYPE type, - ExoFrame *frame) +ExoShell::PlatformSetTitle( + const std::string& title) { - NSView* web_view = frame->web_contents_->GetView()->GetNativeView(); - [web_view setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)]; - LOG(INFO) << "PlatformSetControl: " << type << " " << frame->name(); - - NSView* container = nil; - switch(type) { - case LEFT_CONTROL: - container = control_left_box_; - break; - case RIGHT_CONTROL: - container = control_right_box_; - break; - case TOP_CONTROL: - container = control_top_box_; - break; - case BOTTOM_CONTROL: - container = control_bottom_box_; - break; - default: - /* Nothing to do */ - ; - } - if(container) { - NSRect rect = [container bounds]; - [web_view setFrame:rect]; - [container addSubview: web_view]; - [web_view setNeedsDisplay:YES]; - } + NSString* title_string = base::SysUTF8ToNSString(title); + [window_ setTitle:title_string]; } -void -ExoShell::PlatformSetControlDimension( - CONTROL_TYPE type, - int size) -{ - LOG(INFO) << "PlatformSetControlDimension: " - << type << " " << size; - - NSView* container = nil; - NSLayoutConstraint* constraint = nil; - switch(type) { - case LEFT_CONTROL: - constraint = control_left_constraint_; - container = control_left_box_; - break; - case RIGHT_CONTROL: - constraint = control_right_constraint_; - container = control_right_box_; - break; - case TOP_CONTROL: - constraint = control_top_constraint_; - container = control_top_box_; - break; - case BOTTOM_CONTROL: - constraint = control_bottom_constraint_; - container = control_bottom_box_; - break; - default: - /* Nothing to do */ - ; - } - if(constraint) { - [constraint setConstant: size]; - } -} - -void -ExoShell::PlatformUnsetControl( - CONTROL_TYPE type, - ExoFrame *frame) +void +ExoShell::PlatformFocus(bool focus) { - LOG(INFO) << "PlatformUnsetControl: " << type << " " << frame->name(); - - NSView* container = nil; - NSLayoutConstraint* constraint = nil; - switch(type) { - case LEFT_CONTROL: - container = control_left_box_; - constraint = control_left_constraint_; - break; - case RIGHT_CONTROL: - container = control_right_box_; - constraint = control_right_constraint_; - break; - case TOP_CONTROL: - container = control_top_box_; - constraint = control_top_constraint_; - break; - case BOTTOM_CONTROL: - container = control_bottom_box_; - constraint = control_bottom_constraint_; - break; - default: - /* Nothing to do */ - ; + if(focus) { + [[NSApplication sharedApplication] activateIgnoringOtherApps:YES]; + [window_ makeKeyAndOrderFront:nil]; } - if(container) { - [container setSubviews:[NSArray array]]; - [constraint setConstant: 0]; + else { + [window_ orderBack:nil]; } } void -ExoShell::PlatformShowFloating( - ExoFrame* frame, - int x, - int y, - int width, - int height) +ExoShell::PlatformMaximize() { - DCHECK(floating_frame_ == NULL); - WebContentsView* content_view = frame->web_contents_->GetView(); - floating_frame_ = content_view->GetNativeView(); - - floating_box_ = [[[NSWindow alloc] initWithContentRect:NSMakeRect(x, y, width, height) - styleMask:NSBorderlessWindowMask - backing:NSBackingStoreBuffered - defer:NO] autorelease]; - [window_ addChildWindow:floating_box_ ordered:NSWindowAbove]; - - [[floating_box_ contentView] addSubview: floating_frame_]; - [floating_frame_ setFrame: [[floating_box_ contentView] bounds]]; - [floating_frame_ setNeedsDisplay:YES]; + [window_ zoom:nil]; } void -ExoShell::PlatformHideFloating() +ExoShell::PlatformUnMaximize() { - DCHECK(floating_frame_ != NULL && floating_box_ != NULL); - [window_ removeChildWindow: floating_box_]; - floating_box_ = NULL; - [floating_frame_ removeFromSuperview]; - floating_frame_ = NULL; + [window_ zoom:nil]; } void -ExoShell::PlatformFocus() +ExoShell::PlatformMinimize() { - [window_ makeKeyAndOrderFront:nil]; + [window_ miniaturize:nil]; } void -ExoShell::PlatformMaximize() +ExoShell::PlatformRestore() { - [window_ zoom:nil]; + [window_ deminiaturize:nil]; } - gfx::Size ExoShell::PlatformSize() { - int w = 0, h = 0; - /* TODO(spolu) read size */ - return gfx::Size(w, h); + NSRect frame = [window_ frame]; + return gfx::Size(frame.size.width, frame.size.height); } gfx::Point ExoShell::PlatformPosition() { - int x = 0, y = 0; - /* TODO(spolu) read position */ - return gfx::Point(x, y); + NSRect frame = [window_ frame]; + NSScreen* screen = [[NSScreen screens] objectAtIndex:0]; + + return gfx::Point(frame.origin.x, + NSHeight([screen frame]) - frame.origin.y - frame.size.height); } diff --git a/src/browser/exo_shell_views.cc b/src/browser/exo_shell_views.cc index 08cf26c..32c5191 100644 --- a/src/browser/exo_shell_views.cc +++ b/src/browser/exo_shell_views.cc @@ -59,8 +59,8 @@ class ExoShellClientView : public views::ClientView { public: ExoShellClientView( views::Widget* widget, - ExoShell* contents_view) - : views::ClientView(widget, contents_view) + ExoShell* shell) + : views::ClientView(widget, shell) { } virtual ~ExoShellClientView() {} @@ -135,10 +135,12 @@ ExoShell::PlatformSetTitle( void ExoShell::PlatformFocus(bool focus) { - if (focus) + if(focus) { window_->Activate(); - else + } + else { window_->Deactivate(); + } } void diff --git a/src/browser/mac/application_mac.h b/src/browser/mac/application_mac.h index e1b6ce0..5e74824 100644 --- a/src/browser/mac/application_mac.h +++ b/src/browser/mac/application_mac.h @@ -9,7 +9,7 @@ #include "base/message_loop/message_pump_mac.h" @interface ExoShellApplication : NSApplication { + CrAppControlProtocol> { @private BOOL handlingSendEvent_; } @@ -24,4 +24,4 @@ @end -#define // EXO_SHELL_BROWSER_MAC_EXO_SHELL_APPLICATION_MAC_H_ +#endif // EXO_SHELL_BROWSER_MAC_EXO_SHELL_APPLICATION_MAC_H_ diff --git a/src/browser/mac/application_mac.mm b/src/browser/mac/application_mac.mm index 9358e30..c9c1d93 100644 --- a/src/browser/mac/application_mac.mm +++ b/src/browser/mac/application_mac.mm @@ -2,7 +2,7 @@ // Copyright (c) 2012 The Chromium Authors. // See the LICENSE file. -#include "src/browser/browser_application_mac.h" +#include "src/browser/mac/application_mac.h" #include "base/auto_reset.h" #include "url/gurl.h" diff --git a/src/common/library_main.cc b/src/common/library_main.cc index f13f42c..307f5ae 100644 --- a/src/common/library_main.cc +++ b/src/common/library_main.cc @@ -1,7 +1,7 @@ -#include "common/library_main.h" +#include "src/common/library_main.h" -#include "common/main_delegate.h" #include "content/public/app/content_main.h" +#include "src/common/main_delegate.h" int ExoShellMain(int argc, const char* argv[]) { exo_shell::MainDelegate delegate; diff --git a/src/common/resources/mac/Info.plist b/src/common/resources/mac/Info.plist new file mode 100644 index 0000000..df4ce0a --- /dev/null +++ b/src/common/resources/mac/Info.plist @@ -0,0 +1,16 @@ + + + + + CFBundleExecutable + ExoShell Framework + CFBundleIdentifier + org.breach.ExoShellFramework + CFBundleName + ExoShell Framework + CFBundlePackageType + FMWK + NSSupportsAutomaticGraphicsSwitching + + + diff --git a/tools/mac/create-framework-subdir-symlinks.sh b/tools/mac/create-framework-subdir-symlinks.sh new file mode 100755 index 0000000..bfea1b3 --- /dev/null +++ b/tools/mac/create-framework-subdir-symlinks.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +set -e + +cd "${BUILT_PRODUCTS_DIR}/${1}.framework" +shift + +while [ ! -z "${1}" ]; do + ln -sf Versions/Current/"${1}" "${1}" + shift +done