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/engine/feature/engine_settings_feature.h" | |
6 | |
7 #include "blimp/common/proto/blimp_message.pb.h" | |
8 #include "blimp/common/proto/settings.pb.h" | |
9 #include "blimp/engine/app/settings_manager.h" | |
10 #include "blimp/engine/common/blimp_content_client.h" | |
11 #include "content/public/browser/render_view_host.h" | |
12 #include "content/public/common/web_preferences.h" | |
13 #include "net/base/net_errors.h" | |
14 | |
15 namespace blimp { | |
16 namespace engine { | |
17 | |
18 EngineSettingsFeature::EngineSettingsFeature(SettingsManager* settings_manager) | |
19 : settings_manager_(settings_manager) { | |
20 DCHECK(settings_manager_); | |
21 } | |
22 | |
23 EngineSettingsFeature::~EngineSettingsFeature() {} | |
24 | |
25 void EngineSettingsFeature::ProcessMessage( | |
26 std::unique_ptr<BlimpMessage> message, | |
27 const net::CompletionCallback& callback) { | |
28 DCHECK_EQ(BlimpMessage::kSettings, message->feature_case()); | |
29 | |
30 const SettingsMessage& settings = message->settings(); | |
31 DCHECK(settings.has_engine_settings()); | |
32 | |
33 const EngineSettingsMessage& engine_settings = settings.engine_settings(); | |
34 ProcessSettings(engine_settings); | |
35 | |
36 callback.Run(net::OK); | |
37 } | |
38 | |
39 void EngineSettingsFeature::ProcessSettings( | |
40 const EngineSettingsMessage& engine_settings) { | |
41 if (engine_settings.has_record_whole_document()) { | |
42 EngineSettings settings = settings_manager_->GetEngineSettings(); | |
43 settings.record_whole_document = engine_settings.record_whole_document(); | |
44 settings_manager_->UpdateEngineSettings(settings); | |
45 } | |
46 | |
47 // Set the client OS information for building user agent. | |
48 if (engine_settings.has_client_os_info()) { | |
49 std::string client_os_info = engine_settings.client_os_info(); | |
50 SetClientOSInfo(client_os_info); | |
51 } | |
52 } | |
53 | |
54 } // namespace engine | |
55 } // namespace blimp | |
OLD | NEW |