Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(202)

Side by Side Diff: chrome/browser/remoting/remoting_options_handler.cc

Issue 6955010: Remove the Remoting Host component from Chrome. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove an errant include. Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/remoting/remoting_options_handler.h"
6
7 #include "base/utf_string_conversions.h"
8 #include "base/values.h"
9 #include "chrome/browser/prefs/pref_service.h"
10 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/browser/service/service_process_control_manager.h"
12 #include "chrome/common/pref_names.h"
13 #include "chrome/common/remoting/chromoting_host_info.h"
14 #include "content/browser/webui/web_ui.h"
15 #include "grit/generated_resources.h"
16 #include "ui/base/l10n/l10n_util.h"
17
18 namespace remoting {
19
20 RemotingOptionsHandler::RemotingOptionsHandler()
21 : web_ui_(NULL),
22 process_control_(NULL) {
23 }
24
25 RemotingOptionsHandler::~RemotingOptionsHandler() {
26 if (process_control_)
27 process_control_->RemoveMessageHandler(this);
28 }
29
30 void RemotingOptionsHandler::Init(WebUI* web_ui) {
31 web_ui_ = web_ui;
32
33 process_control_ =
34 ServiceProcessControlManager::GetInstance()->GetProcessControl(
35 web_ui_->GetProfile());
36 process_control_->AddMessageHandler(this);
37
38 PrefService* prefs = web_ui_->GetProfile()->GetPrefs();
39
40 if (!process_control_->RequestRemotingHostStatus()) {
41 // Assume that host is not started if we can't request status.
42 bool enabled = prefs->GetBoolean(prefs::kChromotingEnabled);
43 bool host_enabled = prefs->GetBoolean(prefs::kChromotingHostEnabled);
44 SetStatus(enabled, host_enabled, false, "");
45 }
46 prefs->SetBoolean(prefs::kRemotingHasSetupCompleted, false);
47 }
48
49 // ServiceProcessControl::MessageHandler interface
50 void RemotingOptionsHandler::OnRemotingHostInfo(
51 const remoting::ChromotingHostInfo& host_info) {
52 PrefService* prefs = web_ui_->GetProfile()->GetPrefs();
53 bool enabled = prefs->GetBoolean(prefs::kChromotingEnabled);
54 bool host_enabled = prefs->GetBoolean(prefs::kChromotingHostEnabled);
55 DCHECK(enabled && host_enabled);
56
57 bool host_configured = host_info.enabled;
58 SetStatus(enabled, host_enabled, host_configured, host_info.login);
59 }
60
61 void RemotingOptionsHandler::SetStatus(
62 bool enabled, bool host_enabled, bool host_configured,
63 const std::string& login) {
64 string16 status;
65 if (enabled) {
66 if (host_enabled) {
67 if (host_configured) {
68 status = l10n_util::GetStringFUTF16(IDS_REMOTING_STATUS_CONFIGURED_TEXT,
69 UTF8ToUTF16(login));
70 } else {
71 status = l10n_util::GetStringUTF16(
72 IDS_REMOTING_STATUS_HOST_ENABLED_TEXT);
73 }
74 } else {
75 status = l10n_util::GetStringUTF16(IDS_REMOTING_STATUS_ENABLED_TEXT);
76 }
77 } else {
78 status = l10n_util::GetStringUTF16(IDS_REMOTING_STATUS_DISABLED_TEXT);
79 }
80
81 FundamentalValue enabled_value(enabled);
82 FundamentalValue configured_value(host_configured);
83 StringValue status_value(status);
84 web_ui_->CallJavascriptFunction(
85 "options.AdvancedOptions.SetRemotingStatus",
86 enabled_value, configured_value, status_value);
87 }
88
89 } // namespace remoting
OLDNEW
« no previous file with comments | « chrome/browser/remoting/remoting_options_handler.h ('k') | chrome/browser/remoting/remoting_resources_source.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698