Implement Mac pref-pane UI mockups

This updates the screens to match the mockups.  There are two
new nib files.  One is a view with just a disable button.  The
other is a view with the PIN-confirmation controls.  The main
nib has been updated to remove all controls except for the
Status text and the padlock.  A new placeholder box has been
added in the middle of the window, which can show either of
the new nibs, depending on whether a new config has been
received by the pref-pane.

This also fixes some small issues:

PIN is reset whenever a new config is sent to the pref-pane -
this prevents the previous PIN dots being shown if the user
changes PIN a second time without closing the System Preferences
applet.

The PIN entry box is disabled until the pane is unlocked, for a
slightly improved UX.

BUG=128813,129032
TEST=manual

Review URL: https://chromiumcodereview.appspot.com/10411032

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@138322 0039d316-1c4b-4281-b951-d872f2087c98
parent 7c5e3fd5
...@@ -37,13 +37,15 @@ class JsonHostConfig { ...@@ -37,13 +37,15 @@ class JsonHostConfig {
} }
@class Me2MePreferencePaneConfirmPin;
@class Me2MePreferencePaneDisable;
@interface Me2MePreferencePane : NSPreferencePane { @interface Me2MePreferencePane : NSPreferencePane {
Me2MePreferencePaneConfirmPin* confirm_pin_view_;
Me2MePreferencePaneDisable* disable_view_;
IBOutlet NSTextField* status_message_; IBOutlet NSTextField* status_message_;
IBOutlet NSButton* disable_button_; IBOutlet NSBox* box_;
IBOutlet NSTextField* pin_instruction_message_;
IBOutlet NSTextField* email_;
IBOutlet NSTextField* pin_;
IBOutlet NSButton* apply_button_;
IBOutlet SFAuthorizationView* authorization_view_; IBOutlet SFAuthorizationView* authorization_view_;
// Holds the new proposed configuration if a temporary config file is // Holds the new proposed configuration if a temporary config file is
...@@ -64,8 +66,9 @@ class JsonHostConfig { ...@@ -64,8 +66,9 @@ class JsonHostConfig {
- (void)mainViewDidLoad; - (void)mainViewDidLoad;
- (void)willSelect; - (void)willSelect;
- (void)willUnselect; - (void)willUnselect;
- (IBAction)onDisable:(id)sender; - (void)onDisable:(id)sender;
- (IBAction)onApply:(id)sender; - (void)applyConfiguration:(id)sender
pin:(NSString*)pin;
- (void)onNewConfigFile:(NSNotification*)notification; - (void)onNewConfigFile:(NSNotification*)notification;
- (void)refreshServiceStatus:(NSTimer*)timer; - (void)refreshServiceStatus:(NSTimer*)timer;
- (void)authorizationViewDidAuthorize:(SFAuthorizationView*)view; - (void)authorizationViewDidAuthorize:(SFAuthorizationView*)view;
......
...@@ -24,6 +24,8 @@ ...@@ -24,6 +24,8 @@
#include "base/stringprintf.h" #include "base/stringprintf.h"
#include "base/sys_string_conversions.h" #include "base/sys_string_conversions.h"
#include "remoting/host/host_config.h" #include "remoting/host/host_config.h"
#import "remoting/host/me2me_preference_pane_confirm_pin.h"
#import "remoting/host/me2me_preference_pane_disable.h"
#include "third_party/jsoncpp/source/include/json/reader.h" #include "third_party/jsoncpp/source/include/json/reader.h"
#include "third_party/jsoncpp/source/include/json/writer.h" #include "third_party/jsoncpp/source/include/json/writer.h"
#include "third_party/modp_b64/modp_b64.h" #include "third_party/modp_b64/modp_b64.h"
...@@ -152,6 +154,10 @@ std::string JsonHostConfig::GetSerializedData() const { ...@@ -152,6 +154,10 @@ std::string JsonHostConfig::GetSerializedData() const {
[authorization_view_ setDelegate:self]; [authorization_view_ setDelegate:self];
[authorization_view_ setString:kAuthorizationRightExecute]; [authorization_view_ setString:kAuthorizationRightExecute];
[authorization_view_ setAutoupdate:YES]; [authorization_view_ setAutoupdate:YES];
confirm_pin_view_ = [[Me2MePreferencePaneConfirmPin alloc] init];
[confirm_pin_view_ setDelegate:self];
disable_view_ = [[Me2MePreferencePaneDisable alloc] init];
[disable_view_ setDelegate:self];
} }
- (void)willSelect { - (void)willSelect {
...@@ -189,7 +195,8 @@ std::string JsonHostConfig::GetSerializedData() const { ...@@ -189,7 +195,8 @@ std::string JsonHostConfig::GetSerializedData() const {
} }
} }
- (void)onApply:(id)sender { - (void)applyConfiguration:(id)sender
pin:(NSString*)pin {
if (!have_new_config_) { if (!have_new_config_) {
// It shouldn't be possible to hit the button if there is no config to // It shouldn't be possible to hit the button if there is no config to
// apply, but check anyway just in case it happens somehow. // apply, but check anyway just in case it happens somehow.
...@@ -200,13 +207,13 @@ std::string JsonHostConfig::GetSerializedData() const { ...@@ -200,13 +207,13 @@ std::string JsonHostConfig::GetSerializedData() const {
[self updateAuthorizationStatus]; [self updateAuthorizationStatus];
[self updateUI]; [self updateUI];
std::string pin = base::SysNSStringToUTF8([pin_ stringValue]); std::string pin_utf8 = base::SysNSStringToUTF8(pin);
std::string host_id, host_secret_hash; std::string host_id, host_secret_hash;
bool result = (config_->GetString(remoting::kHostIdConfigPath, &host_id) && bool result = (config_->GetString(remoting::kHostIdConfigPath, &host_id) &&
config_->GetString(remoting::kHostSecretHashConfigPath, config_->GetString(remoting::kHostSecretHashConfigPath,
&host_secret_hash)); &host_secret_hash));
DCHECK(result); DCHECK(result);
if (!IsPinValid(pin, host_id, host_secret_hash)) { if (!IsPinValid(pin_utf8, host_id, host_secret_hash)) {
[self showIncorrectPinMessage]; [self showIncorrectPinMessage];
return; return;
} }
...@@ -296,20 +303,32 @@ std::string JsonHostConfig::GetSerializedData() const { ...@@ -296,20 +303,32 @@ std::string JsonHostConfig::GetSerializedData() const {
config_.swap(new_config_); config_.swap(new_config_);
have_new_config_ = YES; have_new_config_ = YES;
[confirm_pin_view_ resetPin];
} }
- (void)updateUI { - (void)updateUI {
// TODO(lambroslambrou): These strings should be localized. if (have_new_config_) {
#ifdef OFFICIAL_BUILD [box_ setContentView:[confirm_pin_view_ view]];
NSString* name = @"Chrome Remote Desktop"; } else {
#else [box_ setContentView:[disable_view_ view]];
NSString* name = @"Chromoting"; }
#endif
// TODO(lambroslambrou): Show "enabled" and "disabled" in bold font.
NSString* message; NSString* message;
if (is_service_running_) { if (is_service_running_) {
message = [NSString stringWithFormat:@"%@ is enabled", name]; if (have_new_config_) {
message = @"Please confirm your new PIN.";
} else {
message = @"Remote connections to this computer are enabled.";
}
} else { } else {
message = [NSString stringWithFormat:@"%@ is disabled", name]; if (have_new_config_) {
message = @"Remote connections to this computer are disabled. To enable "
"remote connections you must confirm your PIN.";
} else {
message = @"Remote connections to this computer are disabled.";
}
} }
[status_message_ setStringValue:message]; [status_message_ setStringValue:message];
...@@ -320,13 +339,12 @@ std::string JsonHostConfig::GetSerializedData() const { ...@@ -320,13 +339,12 @@ std::string JsonHostConfig::GetSerializedData() const {
// The config has already been checked by |IsConfigValid|. // The config has already been checked by |IsConfigValid|.
DCHECK(result); DCHECK(result);
} }
[email_ setStringValue:base::SysUTF8ToNSString(email)];
[disable_button_ setEnabled:(is_pane_unlocked_ && is_service_running_)]; [disable_view_ setEnabled:(is_pane_unlocked_ && is_service_running_)];
[pin_instruction_message_ setEnabled:have_new_config_]; [confirm_pin_view_ setEnabled:is_pane_unlocked_];
[email_ setEnabled:have_new_config_]; [confirm_pin_view_ setEmail:base::SysUTF8ToNSString(email)];
[pin_ setEnabled:have_new_config_]; NSString* applyButtonText = is_service_running_ ? @"Confirm" : @"Enable";
[apply_button_ setEnabled:(is_pane_unlocked_ && have_new_config_)]; [confirm_pin_view_ setButtonText:applyButtonText];
} }
- (void)showError { - (void)showError {
......
This diff is collapsed.
// 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.
#import <Cocoa/Cocoa.h>
@protocol Me2MePreferencePaneConfirmPinHandler <NSObject>
- (void)applyConfiguration:(id)sender pin:(NSString*)pin;
@end
@interface Me2MePreferencePaneConfirmPin : NSViewController {
IBOutlet NSTextField* email_;
IBOutlet NSTextField* pin_;
IBOutlet NSButton* apply_button_;
id delegate_;
}
@property (retain) id delegate;
- (void)setEmail:(NSString*)email;
- (void)setButtonText:(NSString*)text;
- (void)setEnabled:(BOOL)enabled;
- (void)resetPin;
- (IBAction)onApply:(id)sender;
@end
// 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.
#import "me2me_preference_pane_confirm_pin.h"
@implementation Me2MePreferencePaneConfirmPin
@synthesize delegate = delegate_;
- (id)init {
self = [super initWithNibName:@"me2me_preference_pane_confirm_pin"
bundle:[NSBundle bundleForClass:[self class]]];
return self;
}
- (void)dealloc {
[delegate_ release];
[super dealloc];
}
- (void)setEmail:(NSString*)email {
[email_ setStringValue:email];
}
- (void)setButtonText:(NSString*)text {
[apply_button_ setTitle:text];
}
- (void)setEnabled:(BOOL)enabled {
[apply_button_ setEnabled:enabled];
[pin_ setEnabled:enabled];
}
- (void)resetPin {
[pin_ setStringValue:@""];
}
- (void)onApply:(id)sender {
[delegate_ applyConfiguration:self
pin:[pin_ stringValue]];
}
@end
This diff is collapsed.
// 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.
#import <Cocoa/Cocoa.h>
// This view-controller holds just a "Disable" button. It is shown when the
// pref-pane is launched manually, or when the user has just confirmed their
// PIN and applied a new configuration.
@interface Me2MePreferencePaneDisable : NSViewController {
IBOutlet NSButton* disable_button_;
id delegate_;
}
@property (retain) id delegate;
- (void)setEnabled:(BOOL)enabled;
- (IBAction)onDisable:(id)sender;
@end
// 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.
#import "me2me_preference_pane_disable.h"
@implementation Me2MePreferencePaneDisable
@synthesize delegate = delegate_;
- (id)init {
self = [super initWithNibName:@"me2me_preference_pane_disable"
bundle:[NSBundle bundleForClass:[self class]]];
return self;
}
- (void)dealloc {
[delegate_ release];
[super dealloc];
}
- (void)setEnabled:(BOOL)enabled {
[disable_button_ setEnabled:enabled];
}
- (void)onDisable:(id)sender {
[delegate_ onDisable:self];
}
@end
This diff is collapsed.
...@@ -399,6 +399,10 @@ ...@@ -399,6 +399,10 @@
'../third_party/modp_b64/modp_b64.cc', '../third_party/modp_b64/modp_b64.cc',
'host/me2me_preference_pane.h', 'host/me2me_preference_pane.h',
'host/me2me_preference_pane.mm', 'host/me2me_preference_pane.mm',
'host/me2me_preference_pane_confirm_pin.h',
'host/me2me_preference_pane_confirm_pin.mm',
'host/me2me_preference_pane_disable.h',
'host/me2me_preference_pane_disable.mm',
], ],
'link_settings': { 'link_settings': {
'libraries': [ 'libraries': [
...@@ -412,6 +416,8 @@ ...@@ -412,6 +416,8 @@
}, },
'mac_bundle_resources': [ 'mac_bundle_resources': [
'host/me2me_preference_pane.xib', 'host/me2me_preference_pane.xib',
'host/me2me_preference_pane_confirm_pin.xib',
'host/me2me_preference_pane_disable.xib',
'host/me2me_preference_pane-Info.plist', 'host/me2me_preference_pane-Info.plist',
'resources/chromoting128.png', 'resources/chromoting128.png',
], ],
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment