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/common/create_blimp_message.h" | 8 #include "blimp/common/create_blimp_message.h" |
| 8 #include "blimp/common/proto/blimp_message.pb.h" | 9 #include "blimp/common/proto/blimp_message.pb.h" |
| 9 #include "blimp/common/proto/settings.pb.h" | 10 #include "blimp/common/proto/settings.pb.h" |
| 10 #include "net/base/net_errors.h" | 11 #include "net/base/net_errors.h" |
| 11 | 12 |
| 12 namespace blimp { | 13 namespace blimp { |
| 13 namespace client { | 14 namespace client { |
| 14 | 15 |
| 15 SettingsFeature::SettingsFeature() : record_whole_document_(false) {} | 16 SettingsFeature::SettingsFeature(Settings* settings) |
| 17 : settings_(settings) { | |
| 18 if (settings_) { | |
|
David Trainor- moved to gerrit
2016/10/05 23:46:21
Remove {} if single line after if. Same below.
Menglin
2016/10/06 22:36:38
don't need the observer setup since SettingsFeatur
| |
| 19 settings_->AddObserver(this); | |
| 20 } | |
| 21 } | |
| 16 | 22 |
| 17 SettingsFeature::~SettingsFeature() {} | 23 SettingsFeature::~SettingsFeature() { |
| 24 if (settings_) { | |
| 25 settings_->RemoveObserver(this); | |
| 26 } | |
| 27 } | |
| 18 | 28 |
| 19 void SettingsFeature::set_outgoing_message_processor( | 29 void SettingsFeature::set_outgoing_message_processor( |
| 20 std::unique_ptr<BlimpMessageProcessor> processor) { | 30 std::unique_ptr<BlimpMessageProcessor> processor) { |
| 21 outgoing_message_processor_ = std::move(processor); | 31 outgoing_message_processor_ = std::move(processor); |
| 22 } | 32 } |
| 23 | 33 |
| 24 void SettingsFeature::SetRecordWholeDocument(bool record_whole_document) { | 34 void SettingsFeature::OnRecordWholeDocumentChanged(bool enable) { |
|
David Trainor- moved to gerrit
2016/10/05 23:46:21
We shouldn't need this. IIUC we only expect this
Menglin
2016/10/06 22:36:38
OK. I'm removing this method, in the mean time, Se
| |
| 25 if (record_whole_document_ == record_whole_document) | |
| 26 return; | |
| 27 | |
| 28 record_whole_document_ = record_whole_document; | |
| 29 | |
| 30 EngineSettingsMessage* engine_settings; | 35 EngineSettingsMessage* engine_settings; |
| 31 std::unique_ptr<BlimpMessage> message = CreateBlimpMessage(&engine_settings); | 36 std::unique_ptr<BlimpMessage> message = CreateBlimpMessage(&engine_settings); |
| 32 engine_settings->set_record_whole_document(record_whole_document_); | 37 engine_settings->set_record_whole_document(enable); |
| 33 outgoing_message_processor_->ProcessMessage(std::move(message), | 38 outgoing_message_processor_->ProcessMessage(std::move(message), |
| 34 net::CompletionCallback()); | 39 net::CompletionCallback()); |
| 35 } | 40 } |
| 36 | 41 |
| 37 void SettingsFeature::SendUserAgentOSVersionInfo(const std::string& osVersion) { | 42 void SettingsFeature::SendUserAgentOSVersionInfo(const std::string& osVersion) { |
|
David Trainor- moved to gerrit
2016/10/05 23:46:21
Add a line saying remove this method and tie it to
Menglin
2016/10/06 22:36:38
Done.
| |
| 38 EngineSettingsMessage* engine_settings; | 43 EngineSettingsMessage* engine_settings; |
| 39 std::unique_ptr<BlimpMessage> message = CreateBlimpMessage(&engine_settings); | 44 std::unique_ptr<BlimpMessage> message = CreateBlimpMessage(&engine_settings); |
| 40 engine_settings->set_client_os_info(osVersion); | 45 engine_settings->set_client_os_info(osVersion); |
| 41 outgoing_message_processor_->ProcessMessage(std::move(message), | 46 outgoing_message_processor_->ProcessMessage(std::move(message), |
| 42 net::CompletionCallback()); | 47 net::CompletionCallback()); |
| 43 } | 48 } |
| 44 | 49 |
| 45 void SettingsFeature::ProcessMessage(std::unique_ptr<BlimpMessage> message, | 50 void SettingsFeature::ProcessMessage(std::unique_ptr<BlimpMessage> message, |
| 46 const net::CompletionCallback& callback) { | 51 const net::CompletionCallback& callback) { |
| 47 // We don't receive any messages from the engine yet. | 52 // We don't receive any messages from the engine yet. |
| 48 NOTREACHED() << "Invalid settings message received from the engine."; | 53 NOTREACHED() << "Invalid settings message received from the engine."; |
| 49 callback.Run(net::OK); | 54 callback.Run(net::OK); |
| 50 } | 55 } |
| 51 | 56 |
| 57 void SettingsFeature::PushSettings() { | |
| 58 // TODO(mlliu): set the user agent on the proto as well after moving | |
| 59 // blimp/client/app/user_agent.* to this directory (http://crbug.com/652032). | |
| 60 EngineSettingsMessage* engine_settings; | |
| 61 std::unique_ptr<BlimpMessage> message = CreateBlimpMessage(&engine_settings); | |
| 62 engine_settings->set_record_whole_document( | |
| 63 settings_->record_whole_document()); | |
| 64 outgoing_message_processor_->ProcessMessage(std::move(message), | |
| 65 net::CompletionCallback()); | |
| 66 } | |
| 67 | |
| 52 } // namespace client | 68 } // namespace client |
| 53 } // namespace blimp | 69 } // namespace blimp |
| OLD | NEW |