Chromium Code Reviews| Index: remoting/host/me2me_preference_pane.mm |
| diff --git a/remoting/host/me2me_preference_pane.mm b/remoting/host/me2me_preference_pane.mm |
| index 5dd127e32aac080d7ef7ec6a13625112f524b2e0..c2c8f39a8663bda1f731305ce9a88bf5db6cd6a1 100644 |
| --- a/remoting/host/me2me_preference_pane.mm |
| +++ b/remoting/host/me2me_preference_pane.mm |
| @@ -24,6 +24,8 @@ |
| #include "base/stringprintf.h" |
| #include "base/sys_string_conversions.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/writer.h" |
| #include "third_party/modp_b64/modp_b64.h" |
| @@ -152,6 +154,10 @@ std::string JsonHostConfig::GetSerializedData() const { |
| [authorization_view_ setDelegate:self]; |
| [authorization_view_ setString:kAuthorizationRightExecute]; |
| [authorization_view_ setAutoupdate:YES]; |
| + confirm_pin_view_ = [[Me2MePreferencePaneConfirmPin alloc] init]; |
|
dcaiafa
2012/05/21 15:45:31
Leak in non-GC environment. I'd move the alloc/ini
|
| + [confirm_pin_view_ setDelegate:self]; |
| + disable_view_ = [[Me2MePreferencePaneDisable alloc] init]; |
| + [disable_view_ setDelegate:self]; |
| } |
| - (void)willSelect { |
| @@ -189,7 +195,8 @@ std::string JsonHostConfig::GetSerializedData() const { |
| } |
| } |
| -- (void)onApply:(id)sender { |
| +- (void)applyConfiguration:(id)sender |
| + pin:(NSString*)pin { |
| if (!have_new_config_) { |
| // 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. |
| @@ -200,13 +207,13 @@ std::string JsonHostConfig::GetSerializedData() const { |
| [self updateAuthorizationStatus]; |
| [self updateUI]; |
| - std::string pin = base::SysNSStringToUTF8([pin_ stringValue]); |
| + std::string pin_utf8 = base::SysNSStringToUTF8(pin); |
| std::string host_id, host_secret_hash; |
| bool result = (config_->GetString(remoting::kHostIdConfigPath, &host_id) && |
| config_->GetString(remoting::kHostSecretHashConfigPath, |
| &host_secret_hash)); |
| DCHECK(result); |
| - if (!IsPinValid(pin, host_id, host_secret_hash)) { |
| + if (!IsPinValid(pin_utf8, host_id, host_secret_hash)) { |
| [self showIncorrectPinMessage]; |
| return; |
| } |
| @@ -293,20 +300,32 @@ std::string JsonHostConfig::GetSerializedData() const { |
| config_.swap(new_config_); |
| have_new_config_ = YES; |
| + |
| + [confirm_pin_view_ resetPin]; |
| } |
| - (void)updateUI { |
| - // TODO(lambroslambrou): These strings should be localized. |
| -#ifdef OFFICIAL_BUILD |
| - NSString* name = @"Chrome Remote Desktop"; |
| -#else |
| - NSString* name = @"Chromoting"; |
| -#endif |
| + if (have_new_config_) { |
| + [box_ setContentView:[confirm_pin_view_ view]]; |
| + } else { |
| + [box_ setContentView:[disable_view_ view]]; |
| + } |
| + |
| + // TODO(lambroslambrou): Show "enabled" and "disabled" in bold font. |
| NSString* message; |
| 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 { |
| - 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]; |
| @@ -317,13 +336,12 @@ std::string JsonHostConfig::GetSerializedData() const { |
| // The config has already been checked by |IsConfigValid|. |
| DCHECK(result); |
| } |
| - [email_ setStringValue:base::SysUTF8ToNSString(email)]; |
| - [disable_button_ setEnabled:(is_pane_unlocked_ && is_service_running_)]; |
| - [pin_instruction_message_ setEnabled:have_new_config_]; |
| - [email_ setEnabled:have_new_config_]; |
| - [pin_ setEnabled:have_new_config_]; |
| - [apply_button_ setEnabled:(is_pane_unlocked_ && have_new_config_)]; |
| + [disable_view_ setEnabled:(is_pane_unlocked_ && is_service_running_)]; |
| + [confirm_pin_view_ setEnabled:is_pane_unlocked_]; |
| + [confirm_pin_view_ setEmail:base::SysUTF8ToNSString(email)]; |
| + NSString* applyButtonText = is_service_running_ ? @"Confirm" : @"Enable"; |
| + [confirm_pin_view_ setButtonText:applyButtonText]; |
| } |
| - (void)showError { |