blob: 39bfc927b09cf54fd39322eb78d413f125371d16 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
// 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 "base/utf_string_conversions.h"
#include "base/values.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/service/service_process_control_manager.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/remoting/chromoting_host_info.h"
#include "content/browser/webui/web_ui.h"
#include "grit/generated_resources.h"
#include "ui/base/l10n/l10n_util.h"
namespace remoting {
RemotingOptionsHandler::RemotingOptionsHandler()
: web_ui_(NULL),
process_control_(NULL) {
}
RemotingOptionsHandler::~RemotingOptionsHandler() {
if (process_control_)
process_control_->RemoveMessageHandler(this);
}
void RemotingOptionsHandler::Init(WebUI* web_ui) {
web_ui_ = web_ui;
process_control_ =
ServiceProcessControlManager::GetInstance()->GetProcessControl(
web_ui_->GetProfile());
process_control_->AddMessageHandler(this);
if (!process_control_->RequestRemotingHostStatus()) {
// Assume that host is not started if we can't request status.
SetStatus(false, "");
}
web_ui_->GetProfile()->GetPrefs()->SetBoolean(
prefs::kRemotingHasSetupCompleted, 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);
web_ui_->CallJavascriptFunction("options.AdvancedOptions.SetRemotingStatus",
enabled_value, status_value);
}
} // namespace remoting
|