diff options
Diffstat (limited to 'chrome/browser')
6 files changed, 134 insertions, 2 deletions
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); |