OLD | NEW |
| (Empty) |
1 // Copyright 2016 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 "blimp/client/core/settings/settings_feature.h" | |
6 | |
7 #include "blimp/client/core/settings/settings.h" | |
8 #include "blimp/client/core/settings/user_agent.h" | |
9 #include "blimp/common/create_blimp_message.h" | |
10 #include "blimp/common/proto/blimp_message.pb.h" | |
11 #include "blimp/common/proto/settings.pb.h" | |
12 #include "net/base/net_errors.h" | |
13 | |
14 namespace blimp { | |
15 namespace client { | |
16 | |
17 SettingsFeature::SettingsFeature(Settings* settings) : settings_(settings) { | |
18 DCHECK(settings_); | |
19 } | |
20 | |
21 SettingsFeature::~SettingsFeature() = default; | |
22 | |
23 void SettingsFeature::set_outgoing_message_processor( | |
24 std::unique_ptr<BlimpMessageProcessor> processor) { | |
25 outgoing_message_processor_ = std::move(processor); | |
26 } | |
27 | |
28 void SettingsFeature::ProcessMessage(std::unique_ptr<BlimpMessage> message, | |
29 const net::CompletionCallback& callback) { | |
30 // We don't receive any messages from the engine yet. | |
31 NOTREACHED() << "Invalid settings message received from the engine."; | |
32 callback.Run(net::OK); | |
33 } | |
34 | |
35 void SettingsFeature::OnRecordWholeDocumentChanged(bool enable) { | |
36 EngineSettingsMessage* engine_settings; | |
37 std::unique_ptr<BlimpMessage> message = CreateBlimpMessage(&engine_settings); | |
38 engine_settings->set_record_whole_document(enable); | |
39 outgoing_message_processor_->ProcessMessage(std::move(message), | |
40 net::CompletionCallback()); | |
41 } | |
42 | |
43 void SettingsFeature::PushSettings() { | |
44 EngineSettingsMessage* engine_settings; | |
45 std::unique_ptr<BlimpMessage> message = CreateBlimpMessage(&engine_settings); | |
46 engine_settings->set_record_whole_document( | |
47 settings_->IsRecordWholeDocument()); | |
48 engine_settings->set_client_os_info(GetOSVersionInfoForUserAgent()); | |
49 outgoing_message_processor_->ProcessMessage(std::move(message), | |
50 net::CompletionCallback()); | |
51 } | |
52 | |
53 } // namespace client | |
54 } // namespace blimp | |
OLD | NEW |