diff options
-rw-r--r-- | chrome/app/generated_resources.grd | 11 | ||||
-rw-r--r-- | chrome/browser/dom_ui/options/advanced_options_handler.cc | 4 | ||||
-rw-r--r-- | chrome/browser/dom_ui/options/advanced_options_handler.h | 5 | ||||
-rw-r--r-- | chrome/browser/remoting/remoting_options_handler.cc | 63 | ||||
-rw-r--r-- | chrome/browser/remoting/remoting_options_handler.h | 42 | ||||
-rw-r--r-- | chrome/browser/resources/options/advanced_options.html | 11 | ||||
-rw-r--r-- | chrome/browser/resources/options/advanced_options.js | 11 | ||||
-rw-r--r-- | chrome/chrome_browser.gypi | 2 | ||||
-rw-r--r-- | chrome/service/service_ipc_server.cc | 10 | ||||
-rw-r--r-- | chrome/service/service_ipc_server.h | 5 |
10 files changed, 159 insertions, 5 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index d67bebf..b0ba0bb 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd @@ -8494,7 +8494,10 @@ Keep your key file in a safe place. You will need it to create new versions of y Remoting </message> <message name="IDS_OPTIONS_REMOTING_SETUP_BUTTON" desc="Title for the remoting setup button."> - Allow remote connections to this computer... + Set up remote access... + </message> + <message name="IDS_OPTIONS_REMOTING_STOP_BUTTON" desc="Title for the remoting stop button."> + Disable remote access </message> <message name="IDS_REMOTING_SETUP_DIALOG_TITLE" desc="Title of the remoting setup dialog."> Set up remoting @@ -8520,6 +8523,12 @@ Keep your key file in a safe place. You will need it to create new versions of y <message name="IDS_REMOTING_RETRY_BUTTON_TEXT" desc="Text for retry button"> Retry </message> + <message name="IDS_REMOTING_STATUS_DISABLED_TEXT" desc="Status string shown when remoting is disabled."> + Remote access to this computer is disabled. + </message> + <message name="IDS_REMOTING_STATUS_ENABLED_TEXT" desc="Status string shown when remoting is enabled."> + Remote access to this computer is enabled for <ph name="USER_EMAIL_ADDRESS">$1<ex>foo@gmail.com</ex></ph>. + </message> <!-- Sync strings --> diff --git a/chrome/browser/dom_ui/options/advanced_options_handler.cc b/chrome/browser/dom_ui/options/advanced_options_handler.cc index 44033b7c..c156220 100644 --- a/chrome/browser/dom_ui/options/advanced_options_handler.cc +++ b/chrome/browser/dom_ui/options/advanced_options_handler.cc @@ -187,6 +187,8 @@ void AdvancedOptionsHandler::GetLocalizedValues( l10n_util::GetStringUTF16(IDS_OPTIONS_ADVANCED_SECTION_TITLE_REMOTING)); localized_strings->SetString("remotingSetupButton", l10n_util::GetStringUTF16(IDS_OPTIONS_REMOTING_SETUP_BUTTON)); + localized_strings->SetString("remotingStopButton", + l10n_util::GetStringUTF16(IDS_OPTIONS_REMOTING_STOP_BUTTON)); #endif localized_strings->SetString("enableLogging", l10n_util::GetStringUTF16(IDS_OPTIONS_ENABLE_LOGGING)); @@ -218,6 +220,8 @@ void AdvancedOptionsHandler::Initialize() { #if defined(ENABLE_REMOTING) && !defined(OS_CHROMEOS) if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableRemoting)) { RemoveRemotingSection(); + } else { + remoting_options_handler_.Init(dom_ui_); } #endif diff --git a/chrome/browser/dom_ui/options/advanced_options_handler.h b/chrome/browser/dom_ui/options/advanced_options_handler.h index 033cb85..a400ea8 100644 --- a/chrome/browser/dom_ui/options/advanced_options_handler.h +++ b/chrome/browser/dom_ui/options/advanced_options_handler.h @@ -10,6 +10,7 @@ #include "chrome/browser/prefs/pref_member.h" #include "chrome/browser/prefs/pref_set_observer.h" #include "chrome/browser/printing/cloud_print/cloud_print_setup_flow.h" +#include "chrome/browser/remoting/remoting_options_handler.h" #include "chrome/browser/shell_dialogs.h" class OptionsManagedBannerHandler; @@ -153,6 +154,10 @@ class AdvancedOptionsHandler bool cloud_print_proxy_ui_enabled_; #endif +#if defined(ENABLE_REMOTING) && !defined(OS_CHROMEOS) + remoting::RemotingOptionsHandler remoting_options_handler_; +#endif + FilePathPrefMember default_download_location_; StringPrefMember auto_open_files_; IntegerPrefMember default_font_size_; diff --git a/chrome/browser/remoting/remoting_options_handler.cc b/chrome/browser/remoting/remoting_options_handler.cc new file mode 100644 index 0000000..8e1d549 --- /dev/null +++ b/chrome/browser/remoting/remoting_options_handler.cc @@ -0,0 +1,63 @@ +// 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 "chrome/browser/remoting/remoting_options_handler.h" + +#include "app/l10n_util.h" +#include "base/utf_string_conversions.h" +#include "base/values.h" +#include "chrome/common/remoting/chromoting_host_info.h" +#include "chrome/browser/dom_ui/dom_ui.h" +#include "chrome/browser/service/service_process_control_manager.h" +#include "grit/generated_resources.h" + +namespace remoting { + +RemotingOptionsHandler::RemotingOptionsHandler() + : dom_ui_(NULL), + process_control_(NULL) { +} + +RemotingOptionsHandler::~RemotingOptionsHandler() { + if (process_control_) + process_control_->RemoveMessageHandler(this); +} + +void RemotingOptionsHandler::Init(DOMUI* dom_ui) { + dom_ui_ = dom_ui; + + process_control_ = + ServiceProcessControlManager::GetInstance()->GetProcessControl( + dom_ui_->GetProfile()); + process_control_->AddMessageHandler(this); + + if (!process_control_->RequestRemotingHostStatus()) { + // Assume that host is not started if we can't request status. + SetStatus(false, ""); + } +} + +// ServiceProcessControl::MessageHandler interface +void RemotingOptionsHandler::OnRemotingHostInfo( + const remoting::ChromotingHostInfo& host_info) { + SetStatus(host_info.enabled, host_info.login); +} + +void RemotingOptionsHandler::SetStatus( + bool enabled, const std::string& login) { + string16 status; + if (enabled) { + status = l10n_util::GetStringFUTF16(IDS_REMOTING_STATUS_ENABLED_TEXT, + UTF8ToUTF16(login)); + } else { + status = l10n_util::GetStringUTF16(IDS_REMOTING_STATUS_DISABLED_TEXT); + } + + FundamentalValue enabled_value(enabled); + StringValue status_value(status); + dom_ui_->CallJavascriptFunction(L"options.AdvancedOptions.SetRemotingStatus", + enabled_value, status_value); +} + +} // namespace remoting diff --git a/chrome/browser/remoting/remoting_options_handler.h b/chrome/browser/remoting/remoting_options_handler.h new file mode 100644 index 0000000..8a15cd3 --- /dev/null +++ b/chrome/browser/remoting/remoting_options_handler.h @@ -0,0 +1,42 @@ +// 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. + +#ifndef CHROME_BROWSER_REMOTING_REMOTING_OPTIONS_HANDLER_H_ +#define CHROME_BROWSER_REMOTING_REMOTING_OPTIONS_HANDLER_H_ + +#include "chrome/browser/service/service_process_control.h" + +class DOMUI; + +namespace remoting { + +// Remoting options handler is responsinble for showing correct status +// of the chromoting host in the preferences. It listens to the +// messages from the service process (by registering MessageHandler +// callback in the ServiceProcessControl) and updates current status +// as neccessary. +class RemotingOptionsHandler + : public ServiceProcessControl::MessageHandler { + public: + RemotingOptionsHandler(); + virtual ~RemotingOptionsHandler(); + + void Init(DOMUI* dom_ui); + + // ServiceProcessControl::MessageHandler interface. + virtual void OnRemotingHostInfo( + const remoting::ChromotingHostInfo& host_info); + + private: + void SetStatus(bool enabled, const std::string& login); + + DOMUI* dom_ui_; + ServiceProcessControl* process_control_; + + DISALLOW_COPY_AND_ASSIGN(RemotingOptionsHandler); +}; + +} // namespace remoting + +#endif // CHROME_BROWSER_REMOTING_REMOTING_OPTIONS_HANDLER_H_ diff --git a/chrome/browser/resources/options/advanced_options.html b/chrome/browser/resources/options/advanced_options.html index 256ac39..f4179c6 100644 --- a/chrome/browser/resources/options/advanced_options.html +++ b/chrome/browser/resources/options/advanced_options.html @@ -206,8 +206,15 @@ <section id="remoting-section"> <h3 i18n-content="advancedSectionTitleRemoting"></h3> <div> - <button id="remotingSetupButton" - i18n-content="remotingSetupButton"></button> + <div id="remotingStatus" class="section-text"></div> + <div> + <button id="remotingSetupButton" + i18n-content="remotingSetupButton" + style="display:none;"></button> + <button id="remotingStopButton" + i18n-content="remotingStopButton" + style="display:none;"></button> + </div> </div> </section> </if> diff --git a/chrome/browser/resources/options/advanced_options.js b/chrome/browser/resources/options/advanced_options.js index 5ff1ffba..b061f89 100644 --- a/chrome/browser/resources/options/advanced_options.js +++ b/chrome/browser/resources/options/advanced_options.js @@ -248,6 +248,17 @@ var OptionsPage = options.OptionsPage; } }; + AdvancedOptions.SetRemotingStatus = function(enabled, status) { + if (enabled) { + $('remotingSetupButton').style.display = 'none'; + $('remotingStopButton').style.display = 'inline'; + } else { + $('remotingSetupButton').style.display = 'inline'; + $('remotingStopButton').style.display = 'none'; + } + $('remotingStatus').textContent = status; + }; + AdvancedOptions.RemoveRemotingSection = function() { var proxySectionElm = $('remoting-section'); proxySectionElm.parentNode.removeChild(proxySectionElm); diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index f3352e9..9783797 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -2112,6 +2112,8 @@ 'browser/profiles/profile_manager.h', 'browser/remoting/directory_add_request.cc', 'browser/remoting/directory_add_request.h', + 'browser/remoting/remoting_options_handler.cc', + 'browser/remoting/remoting_options_handler.h', 'browser/remoting/remoting_resources_source.cc', 'browser/remoting/remoting_resources_source.h', 'browser/remoting/setup_flow.cc', diff --git a/chrome/service/service_ipc_server.cc b/chrome/service/service_ipc_server.cc index 978d348..24f7600 100644 --- a/chrome/service/service_ipc_server.cc +++ b/chrome/service/service_ipc_server.cc @@ -132,13 +132,19 @@ void ServiceIPCServer::OnSetRemotingHostCredentials( void ServiceIPCServer::OnEnableRemotingHost() { g_service_process->remoting_host_manager()->Enable(); + SendRemotingHostInfo(); } -void ServiceIPCServer:: OnDisableRemotingHost() { +void ServiceIPCServer::OnDisableRemotingHost() { g_service_process->remoting_host_manager()->Disable(); + SendRemotingHostInfo(); } -void ServiceIPCServer:: OnGetRemotingHostInfo() { +void ServiceIPCServer::OnGetRemotingHostInfo() { + SendRemotingHostInfo(); +} + +void ServiceIPCServer::SendRemotingHostInfo() { remoting::ChromotingHostInfo host_info; g_service_process->remoting_host_manager()->GetHostInfo(&host_info); channel_->Send(new ServiceHostMsg_RemotingHost_HostInfo(host_info)); diff --git a/chrome/service/service_ipc_server.h b/chrome/service/service_ipc_server.h index 29c8dc26..675135e 100644 --- a/chrome/service/service_ipc_server.h +++ b/chrome/service/service_ipc_server.h @@ -52,6 +52,11 @@ class ServiceIPCServer : public IPC::Channel::Listener, void OnEnableRemotingHost(); void OnDisableRemotingHost(); void OnGetRemotingHostInfo(); + + // Sends HostInfo message to the browser. It must is called when we + // receive GetRemotingHostInfo message or when status of the host + // is changed. + void SendRemotingHostInfo(); #endif // defined(ENABLE_REMOTING) void OnShutdown(); |