diff options
Diffstat (limited to 'remoting/host/disconnect_window_mac.mm')
-rw-r--r-- | remoting/host/disconnect_window_mac.mm | 43 |
1 files changed, 26 insertions, 17 deletions
diff --git a/remoting/host/disconnect_window_mac.mm b/remoting/host/disconnect_window_mac.mm index 9cb170a..56e4946 100644 --- a/remoting/host/disconnect_window_mac.mm +++ b/remoting/host/disconnect_window_mac.mm @@ -8,27 +8,25 @@ #include "base/bind.h" #include "base/compiler_specific.h" -#include "base/i18n/rtl.h" #include "base/memory/weak_ptr.h" #include "base/strings/string_util.h" #include "base/strings/sys_string_conversions.h" -#include "remoting/base/string_resources.h" #include "remoting/host/client_session_control.h" #include "remoting/host/host_window.h" -#include "ui/base/l10n/l10n_util_mac.h" +#include "remoting/host/ui_strings.h" @interface DisconnectWindowController() - (BOOL)isRToL; - (void)Hide; @end -const int kMaximumConnectedNameWidthInPixels = 600; +const int kMaximumConnectedNameWidthInPixels = 400; namespace remoting { class DisconnectWindowMac : public HostWindow { public: - DisconnectWindowMac(); + explicit DisconnectWindowMac(const UiStrings& ui_strings); virtual ~DisconnectWindowMac(); // HostWindow overrides. @@ -37,13 +35,17 @@ class DisconnectWindowMac : public HostWindow { OVERRIDE; private: + // Localized UI strings. + UiStrings ui_strings_; + DisconnectWindowController* window_controller_; DISALLOW_COPY_AND_ASSIGN(DisconnectWindowMac); }; -DisconnectWindowMac::DisconnectWindowMac() - : window_controller_(nil) { +DisconnectWindowMac::DisconnectWindowMac(const UiStrings& ui_strings) + : ui_strings_(ui_strings), + window_controller_(nil) { } DisconnectWindowMac::~DisconnectWindowMac() { @@ -68,23 +70,27 @@ void DisconnectWindowMac::Start( std::string client_jid = client_session_control->client_jid(); std::string username = client_jid.substr(0, client_jid.find('/')); window_controller_ = - [[DisconnectWindowController alloc] initWithCallback:disconnect_callback - username:username]; + [[DisconnectWindowController alloc] initWithUiStrings:&ui_strings_ + callback:disconnect_callback + username:username]; [window_controller_ showWindow:nil]; } // static -scoped_ptr<HostWindow> HostWindow::CreateDisconnectWindow() { - return scoped_ptr<HostWindow>(new DisconnectWindowMac()); +scoped_ptr<HostWindow> HostWindow::CreateDisconnectWindow( + const UiStrings& ui_strings) { + return scoped_ptr<HostWindow>(new DisconnectWindowMac(ui_strings)); } } // namespace remoting @implementation DisconnectWindowController -- (id)initWithCallback:(const base::Closure&)disconnect_callback - username:(const std::string&)username { +- (id)initWithUiStrings:(const remoting::UiStrings*)ui_strings + callback:(const base::Closure&)disconnect_callback + username:(const std::string&)username { self = [super initWithWindowNibName:@"disconnect_window"]; if (self) { + ui_strings_ = ui_strings; disconnect_callback_ = disconnect_callback; username_ = UTF8ToUTF16(username); } @@ -102,7 +108,7 @@ scoped_ptr<HostWindow> HostWindow::CreateDisconnectWindow() { } - (BOOL)isRToL { - return base::i18n::IsRTL(); + return ui_strings_->direction == remoting::UiStrings::RTL; } - (void)Hide { @@ -111,9 +117,12 @@ scoped_ptr<HostWindow> HostWindow::CreateDisconnectWindow() { } - (void)windowDidLoad { - [connectedToField_ setStringValue:l10n_util::GetNSStringF(IDR_MESSAGE_SHARED, - username_)]; - [disconnectButton_ setTitle:l10n_util::GetNSString(IDR_STOP_SHARING_BUTTON)]; + string16 text = ReplaceStringPlaceholders(ui_strings_->disconnect_message, + username_, NULL); + [connectedToField_ setStringValue:base::SysUTF16ToNSString(text)]; + + [disconnectButton_ setTitle:base::SysUTF16ToNSString( + ui_strings_->disconnect_button_text)]; // Resize the window dynamically based on the content. CGFloat oldConnectedWidth = NSWidth([connectedToField_ bounds]); |