summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--remoting/host/continue_window.cc16
-rw-r--r--remoting/host/continue_window.h6
-rw-r--r--remoting/host/continue_window_linux.cc13
-rw-r--r--remoting/host/continue_window_mac.mm99
-rw-r--r--remoting/remoting.gyp5
-rw-r--r--remoting/resources/chromoting128.pngbin6807 -> 7981 bytes
-rw-r--r--remoting/webapp/me2mom/chromoting128.pngbin6807 -> 0 bytes
7 files changed, 125 insertions, 14 deletions
diff --git a/remoting/host/continue_window.cc b/remoting/host/continue_window.cc
new file mode 100644
index 0000000..c006b4f
--- /dev/null
+++ b/remoting/host/continue_window.cc
@@ -0,0 +1,16 @@
+// Copyright (c) 2011 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.
+
+#include "remoting/host/continue_window.h"
+
+namespace remoting {
+
+const char ContinueWindow::kTitle[] = "Remoting";
+const char ContinueWindow::kMessage[] =
+ "You are currently sharing this machine with another user. "
+ "Please confirm that you want to continue sharing.";
+const char ContinueWindow::kDefaultButtonText[] = "Continue";
+const char ContinueWindow::kCancelButtonText[] = "Stop";
+
+}
diff --git a/remoting/host/continue_window.h b/remoting/host/continue_window.h
index 0c52416..d2eb30f 100644
--- a/remoting/host/continue_window.h
+++ b/remoting/host/continue_window.h
@@ -21,6 +21,12 @@ class ContinueWindow {
virtual void Hide() = 0;
static ContinueWindow* Create();
+
+ protected:
+ static const char kTitle[];
+ static const char kMessage[];
+ static const char kDefaultButtonText[];
+ static const char kCancelButtonText[];
};
}
diff --git a/remoting/host/continue_window_linux.cc b/remoting/host/continue_window_linux.cc
index d0a1ff3..cc15f6c 100644
--- a/remoting/host/continue_window_linux.cc
+++ b/remoting/host/continue_window_linux.cc
@@ -13,12 +13,6 @@
namespace remoting {
-const char kContinueWindowTitle[] = "Remoting";
-const char kContinueWindowText[] =
- "You are currently sharing this machine with another user. "
- "Please confirm that you want to continue sharing.";
-const char kContinueWindowButtonText[] = "Yes, continue sharing";
-
class ContinueWindowLinux : public remoting::ContinueWindow {
public:
ContinueWindowLinux();
@@ -51,7 +45,7 @@ void ContinueWindowLinux::CreateWindow() {
continue_window_ = gtk_window_new(GTK_WINDOW_TOPLEVEL);
GtkWindow* window = GTK_WINDOW(continue_window_);
- gtk_window_set_title(window, kContinueWindowTitle);
+ gtk_window_set_title(window, kTitle);
gtk_window_set_resizable(window, FALSE);
g_signal_connect(window, "delete-event",
@@ -63,14 +57,15 @@ void ContinueWindowLinux::CreateWindow() {
GtkWidget* text_row = gtk_hbox_new(FALSE, 0);
gtk_container_add(GTK_CONTAINER(main_area), text_row);
- GtkWidget* text_label = gtk_label_new(kContinueWindowText);
+ GtkWidget* text_label = gtk_label_new(kMessage);
gtk_label_set_line_wrap(GTK_LABEL(text_label), TRUE);
gtk_container_add(GTK_CONTAINER(text_row), text_label);
GtkWidget* button_box = gtk_hbox_new(FALSE, 0);
gtk_container_add(GTK_CONTAINER(main_area), button_box);
- GtkWidget* ok_button = gtk_button_new_with_label(kContinueWindowButtonText);
+ GtkWidget* ok_button =
+ gtk_button_new_with_label(kDefaultButtonText);
gtk_box_pack_start(GTK_BOX(button_box), ok_button,
TRUE, FALSE, 0);
diff --git a/remoting/host/continue_window_mac.mm b/remoting/host/continue_window_mac.mm
index 2dab025..8793dd4 100644
--- a/remoting/host/continue_window_mac.mm
+++ b/remoting/host/continue_window_mac.mm
@@ -2,31 +2,122 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#import "remoting/host/continue_window.h"
+#include "remoting/host/continue_window.h"
+
+#import <Cocoa/Cocoa.h>
#include "base/compiler_specific.h"
#include "base/logging.h"
+#include "base/mac/scoped_nsautorelease_pool.h"
+#include "base/memory/scoped_nsobject.h"
+#include "remoting/host/chromoting_host.h"
+
+// As this is a plugin, there needs to be a way to find its bundle
+// so that resources are able to be found. This class exists solely so that
+// there is a way to get the bundle that this code file is in using
+// [NSBundle bundleForClass:[ContinueWindowMacClassToLocateMyBundle class]]
+// It is really only a name.
+@interface ContinueWindowMacClassToLocateMyBundle : NSObject
+@end
+
+@implementation ContinueWindowMacClassToLocateMyBundle
+@end
namespace remoting {
class ContinueWindowMac : public remoting::ContinueWindow {
public:
- ContinueWindowMac() {}
+ ContinueWindowMac() : modal_session_(NULL) {}
virtual ~ContinueWindowMac() {}
virtual void Show(remoting::ChromotingHost* host) OVERRIDE;
virtual void Hide() OVERRIDE;
private:
+ NSModalSession modal_session_;
+
DISALLOW_COPY_AND_ASSIGN(ContinueWindowMac);
};
void ContinueWindowMac::Show(remoting::ChromotingHost* host) {
- NOTIMPLEMENTED();
+ base::mac::ScopedNSAutoreleasePool pool;
+
+ // Generate window shade
+ NSArray* screens = [NSScreen screens];
+ NSMutableArray* windows = [NSMutableArray arrayWithCapacity:[screens count]];
+ for (NSScreen *screen in screens) {
+ NSWindow* window =
+ [[[NSWindow alloc] initWithContentRect:[screen frame]
+ styleMask:NSBorderlessWindowMask
+ backing:NSBackingStoreBuffered
+ defer:NO
+ screen:screen] autorelease];
+ [window setReleasedWhenClosed:NO];
+ [window setAlphaValue:0.8];
+ [window setOpaque:NO];
+ [window setBackgroundColor:[NSColor blackColor]];
+ // Raise the window shade above just about everything else.
+ // Leave the dock and menu bar exposed so the user has some basic level
+ // of control (like they can quit Chromium).
+ [window setLevel:NSModalPanelWindowLevel - 1];
+ [window orderFront:nil];
+ [windows addObject:window];
+ }
+
+ // Put up alert
+ NSString* message = [NSString stringWithUTF8String:kMessage];
+ NSString* continue_button =
+ [NSString stringWithUTF8String:kDefaultButtonText];
+ NSString* cancel_button =
+ [NSString stringWithUTF8String:kCancelButtonText];
+ scoped_nsobject<NSAlert> continue_alert([[NSAlert alloc] init]);
+ [continue_alert setMessageText:message];
+ [continue_alert addButtonWithTitle:continue_button];
+ [continue_alert addButtonWithTitle:cancel_button];
+
+ // See ContinueWindowMacClassToLocateMyBundle class above for details
+ // on this.
+ NSBundle *bundle =
+ [NSBundle bundleForClass:[ContinueWindowMacClassToLocateMyBundle class]];
+ NSString *imagePath = [bundle pathForResource:@"chromoting128" ofType:@"png"];
+ scoped_nsobject<NSImage> image(
+ [[NSImage alloc] initByReferencingFile:imagePath]);
+ [continue_alert setIcon:image];
+ [continue_alert layout];
+
+ NSWindow* continue_window = [continue_alert window];
+ [continue_window center];
+ [continue_window orderWindow:NSWindowAbove
+ relativeTo:[[windows lastObject] windowNumber]];
+ [continue_window makeKeyWindow];
+ NSApplication* application = [NSApplication sharedApplication];
+ modal_session_ = [application beginModalSessionForWindow:continue_window];
+ NSInteger answer = 0;
+ do {
+ answer = [application runModalSession:modal_session_];
+ } while (answer == NSRunContinuesResponse);
+ [application endModalSession:modal_session_];
+ modal_session_ = NULL;
+
+ [continue_window close];
+
+ // Remove window shade.
+ for (NSWindow* window in windows) {
+ [window close];
+ }
+
+ if (answer == NSAlertFirstButtonReturn) {
+ host->PauseSession(false);
+ } else {
+ host->Shutdown(NULL);
+ }
}
void ContinueWindowMac::Hide() {
- NOTIMPLEMENTED();
+ if (modal_session_) {
+ NSApplication* application = [NSApplication sharedApplication];
+ [application stopModalWithCode:NSAlertFirstButtonReturn];
+ }
}
ContinueWindow* ContinueWindow::Create() {
diff --git a/remoting/remoting.gyp b/remoting/remoting.gyp
index 640cd2e..e75980b 100644
--- a/remoting/remoting.gyp
+++ b/remoting/remoting.gyp
@@ -33,11 +33,11 @@
}],
],
'remoting_it2me_files': [
+ 'resources/chromoting128.png',
'webapp/me2mom/background.html',
'webapp/me2mom/background.js',
'webapp/me2mom/choice.css',
'webapp/me2mom/choice.html',
- 'webapp/me2mom/chromoting128.png',
'webapp/me2mom/cs_oauth2_trampoline.js',
'webapp/me2mom/debug_log.css',
'webapp/me2mom/debug_log.js',
@@ -162,6 +162,7 @@
'mac_bundle_resources': [
'host/disconnect_window.xib',
'host/plugin/host_plugin-Info.plist',
+ 'resources/chromoting128.png',
],
'mac_bundle_resources!': [
'host/plugin/host_plugin-Info.plist',
@@ -328,6 +329,7 @@
'host/chromoting_host_context.h',
'host/client_session.cc',
'host/client_session.h',
+ 'host/continue_window.cc',
'host/continue_window.h',
'host/continue_window_mac.mm',
'host/continue_window_linux.cc',
@@ -451,6 +453,7 @@
'host/capturer_fake_ascii.cc',
'host/capturer_fake_ascii.h',
'host/continue_window.h',
+ 'host/continue_window.cc',
'host/continue_window_mac.mm',
'host/continue_window_linux.cc',
'host/continue_window_win.cc',
diff --git a/remoting/resources/chromoting128.png b/remoting/resources/chromoting128.png
index 85862b0..86eb735 100644
--- a/remoting/resources/chromoting128.png
+++ b/remoting/resources/chromoting128.png
Binary files differ
diff --git a/remoting/webapp/me2mom/chromoting128.png b/remoting/webapp/me2mom/chromoting128.png
deleted file mode 100644
index 85862b0..0000000
--- a/remoting/webapp/me2mom/chromoting128.png
+++ /dev/null
Binary files differ