Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "blimp/client/core/settings/settings_feature.h" | 5 #include "blimp/client/core/settings/settings_feature.h" |
| 6 | 6 |
| 7 #include "blimp/client/core/settings/settings.h" | 7 #include "blimp/client/core/settings/settings.h" |
| 8 #include "blimp/client/core/settings/user_agent.h" | |
| 8 #include "blimp/common/create_blimp_message.h" | 9 #include "blimp/common/create_blimp_message.h" |
| 9 #include "blimp/common/proto/blimp_message.pb.h" | 10 #include "blimp/common/proto/blimp_message.pb.h" |
| 10 #include "blimp/common/proto/settings.pb.h" | 11 #include "blimp/common/proto/settings.pb.h" |
| 11 #include "net/base/net_errors.h" | 12 #include "net/base/net_errors.h" |
| 12 | 13 |
| 13 namespace blimp { | 14 namespace blimp { |
| 14 namespace client { | 15 namespace client { |
| 15 | 16 |
| 16 SettingsFeature::SettingsFeature(Settings* settings) : settings_(settings) {} | 17 SettingsFeature::SettingsFeature(Settings* settings) : settings_(settings) {} |
| 17 | 18 |
| 18 SettingsFeature::~SettingsFeature() = default; | 19 SettingsFeature::~SettingsFeature() = default; |
| 19 | 20 |
| 20 void SettingsFeature::set_outgoing_message_processor( | 21 void SettingsFeature::set_outgoing_message_processor( |
| 21 std::unique_ptr<BlimpMessageProcessor> processor) { | 22 std::unique_ptr<BlimpMessageProcessor> processor) { |
| 22 outgoing_message_processor_ = std::move(processor); | 23 outgoing_message_processor_ = std::move(processor); |
| 23 } | 24 } |
| 24 | 25 |
| 25 // TODO(mlliu): remove this method once we set the user agent in PushSettings() | |
| 26 // http://crbug.com/652032. | |
| 27 void SettingsFeature::SendUserAgentOSVersionInfo(const std::string& osVersion) { | |
| 28 EngineSettingsMessage* engine_settings; | |
| 29 std::unique_ptr<BlimpMessage> message = CreateBlimpMessage(&engine_settings); | |
| 30 engine_settings->set_client_os_info(osVersion); | |
| 31 outgoing_message_processor_->ProcessMessage(std::move(message), | |
| 32 net::CompletionCallback()); | |
| 33 } | |
| 34 | |
| 35 void SettingsFeature::ProcessMessage(std::unique_ptr<BlimpMessage> message, | 26 void SettingsFeature::ProcessMessage(std::unique_ptr<BlimpMessage> message, |
| 36 const net::CompletionCallback& callback) { | 27 const net::CompletionCallback& callback) { |
| 37 // We don't receive any messages from the engine yet. | 28 // We don't receive any messages from the engine yet. |
| 38 NOTREACHED() << "Invalid settings message received from the engine."; | 29 NOTREACHED() << "Invalid settings message received from the engine."; |
| 39 callback.Run(net::OK); | 30 callback.Run(net::OK); |
| 40 } | 31 } |
| 41 | 32 |
| 42 void SettingsFeature::OnRecordWholeDocumentChanged(bool enable) { | 33 void SettingsFeature::OnRecordWholeDocumentChanged(bool enable) { |
| 43 EngineSettingsMessage* engine_settings; | 34 EngineSettingsMessage* engine_settings; |
| 44 std::unique_ptr<BlimpMessage> message = CreateBlimpMessage(&engine_settings); | 35 std::unique_ptr<BlimpMessage> message = CreateBlimpMessage(&engine_settings); |
| 45 engine_settings->set_record_whole_document(enable); | 36 engine_settings->set_record_whole_document(enable); |
| 46 outgoing_message_processor_->ProcessMessage(std::move(message), | 37 outgoing_message_processor_->ProcessMessage(std::move(message), |
| 47 net::CompletionCallback()); | 38 net::CompletionCallback()); |
| 48 } | 39 } |
| 49 | 40 |
| 50 void SettingsFeature::PushSettings() { | 41 void SettingsFeature::PushSettings() { |
| 51 // TODO(mlliu): set the user agent on the proto as well after moving | |
| 52 // blimp/client/app/user_agent.* to this directory (http://crbug.com/652032). | |
| 53 EngineSettingsMessage* engine_settings; | 42 EngineSettingsMessage* engine_settings; |
| 54 std::unique_ptr<BlimpMessage> message = CreateBlimpMessage(&engine_settings); | 43 std::unique_ptr<BlimpMessage> message = CreateBlimpMessage(&engine_settings); |
| 55 engine_settings->set_record_whole_document( | 44 if (settings_) { |
|
Khushal
2016/11/01 21:28:55
Why the if check? Isn't settings_ supposed to outl
Menglin
2016/11/01 21:37:52
it's for BlimpClientSession. because in BlimpClien
Khushal
2016/11/01 23:33:06
Hmmm, I just looked at that class and it seems lik
| |
| 56 settings_->IsRecordWholeDocument()); | 45 engine_settings->set_record_whole_document( |
| 46 settings_->IsRecordWholeDocument()); | |
| 47 } | |
| 48 engine_settings->set_client_os_info(GetOSVersionInfoForUserAgent()); | |
| 57 outgoing_message_processor_->ProcessMessage(std::move(message), | 49 outgoing_message_processor_->ProcessMessage(std::move(message), |
| 58 net::CompletionCallback()); | 50 net::CompletionCallback()); |
| 59 } | 51 } |
| 60 | 52 |
| 61 } // namespace client | 53 } // namespace client |
| 62 } // namespace blimp | 54 } // namespace blimp |
| OLD | NEW |