use AtomEventProcessingWindow as native window.

This commit is contained in:
Cheng Zhao 2013-04-12 15:53:29 +08:00
parent 3391370857
commit af94c434ac
4 changed files with 43 additions and 6 deletions

View file

@ -78,6 +78,14 @@ void NativeWindow::InitFromOptions(base::DictionaryValue* options) {
Show();
}
void NativeWindow::ShowDevTools() {
inspectable_web_contents()->ShowDevTools();
}
void NativeWindow::CloseDevTools() {
// inspectable_web_contents()->CloseDevTools();
}
content::WebContents* NativeWindow::GetWebContents() const {
return inspectable_web_contents_->GetWebContents();
}

View file

@ -65,6 +65,8 @@ class NativeWindow {
virtual void FlashFrame(bool flash) = 0;
virtual void SetKiosk(bool kiosk) = 0;
virtual bool IsKiosk() = 0;
virtual void ShowDevTools();
virtual void CloseDevTools();
content::WebContents* GetWebContents() const;
@ -72,6 +74,10 @@ class NativeWindow {
explicit NativeWindow(content::BrowserContext* browser_context,
base::DictionaryValue* options);
brightray::InspectableWebContents* inspectable_web_contents() const {
return inspectable_web_contents_.get();
}
private:
scoped_ptr<brightray::InspectableWebContents> inspectable_web_contents_;

View file

@ -44,8 +44,6 @@ class NativeWindowMac : public NativeWindow {
virtual void SetKiosk(bool kiosk) OVERRIDE;
virtual bool IsKiosk() OVERRIDE;
void set_is_fullscreen(bool fullscreen) { is_fullscreen_ = fullscreen; }
NSWindow* window() const { return window_; }
protected:

View file

@ -11,10 +11,31 @@
#include "base/mac/mac_util.h"
#include "base/sys_string_conversions.h"
#include "base/values.h"
#include "browser/atom_event_processing_window.h"
#include "common/options_switches.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_view.h"
@interface AtomNSWindow : AtomEventProcessingWindow {
@private
atom::NativeWindowMac* shell_;
}
- (void)setShell:(atom::NativeWindowMac*)shell;
- (IBAction)showDevTools:(id)sender;
@end
@implementation AtomNSWindow
- (void)setShell:(atom::NativeWindowMac*)shell {
shell_ = shell;
}
- (IBAction)showDevTools:(id)sender {
shell_->ShowDevTools();
}
@end
namespace atom {
NativeWindowMac::NativeWindowMac(content::BrowserContext* browser_context,
@ -36,10 +57,14 @@ NativeWindowMac::NativeWindowMac(content::BrowserContext* browser_context,
NSUInteger style_mask = NSTitledWindowMask | NSClosableWindowMask |
NSMiniaturizableWindowMask | NSResizableWindowMask |
NSTexturedBackgroundWindowMask;
window_ = [[NSWindow alloc] initWithContentRect:cocoa_bounds
styleMask:style_mask
backing:NSBackingStoreBuffered
defer:YES];
AtomNSWindow* atom_window = [[AtomNSWindow alloc]
initWithContentRect:cocoa_bounds
styleMask:style_mask
backing:NSBackingStoreBuffered
defer:YES];
[atom_window setShell:this];
window_ = atom_window;
// Disable fullscreen button when 'fullscreen' is specified to false.
bool fullscreen;