Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2822)

Unified Diff: blimp/engine/feature/engine_settings_feature.cc

Issue 1810213009: blimp: Add settings to allow the client to download the whole page. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@record_full_document
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: blimp/engine/feature/engine_settings_feature.cc
diff --git a/blimp/engine/feature/engine_settings_feature.cc b/blimp/engine/feature/engine_settings_feature.cc
new file mode 100644
index 0000000000000000000000000000000000000000..697a4109cb1f57a2540f46ae5991969afd655002
--- /dev/null
+++ b/blimp/engine/feature/engine_settings_feature.cc
@@ -0,0 +1,77 @@
+// Copyright 2015 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 "blimp/engine/feature/engine_settings_feature.h"
+
+#include "blimp/common/proto/blimp_message.pb.h"
+#include "blimp/common/proto/settings.pb.h"
+#include "content/public/browser/render_view_host.h"
+#include "content/public/common/web_preferences.h"
+#include "net/base/net_errors.h"
+
+namespace blimp {
+
+EngineSettingsFeature::EngineSettingsFeature()
+ : record_whole_document_(false) {}
+
+EngineSettingsFeature::~EngineSettingsFeature() {}
+
+void EngineSettingsFeature::set_outgoing_message_processor(
+ scoped_ptr<BlimpMessageProcessor> processor) {
+ outgoing_message_processor_ = std::move(processor);
+}
+
+void EngineSettingsFeature::AddObserver(Observer* observer) {
+ observer_list_.AddObserver(observer);
+}
+
+void EngineSettingsFeature::RemoveObserver(Observer* observer) {
+ observer_list_.AddObserver(observer);
+}
+
+void EngineSettingsFeature::UpdateWebkitPreferences(
+ content::RenderViewHost* render_view_host) {
+ DCHECK(render_view_host);
+
+ bool updated = false;
+ content::WebPreferences prefs = render_view_host->GetWebkitPreferences();
+
+ if (prefs.record_whole_document != record_whole_document_) {
+ prefs.record_whole_document = record_whole_document_;
+ updated = true;
+ }
+
+ if (updated)
+ render_view_host->UpdateWebkitPreferences(prefs);
+}
+
+void EngineSettingsFeature::ProcessMessage(scoped_ptr<BlimpMessage> message,
+ const net::CompletionCallback& callback) {
+ DCHECK_EQ(message->type(), BlimpMessage::SETTINGS);
+ DCHECK(message->has_settings());
+
+ const SettingsMessage& settings = message->settings();
+ DCHECK(settings.has_engine_settings());
+
+ const EngineSettingsMessage& engine_settings = settings.engine_settings();
+ ProcessWebPreferences(engine_settings);
+
+ callback.Run(net::OK);
+}
+
+void EngineSettingsFeature::ProcessWebPreferences(
+ const EngineSettingsMessage& engine_settings) {
+ bool updated = false;
+
+ if (engine_settings.has_record_whole_document()
+ && engine_settings.record_whole_document() != record_whole_document_) {
+ record_whole_document_ = engine_settings.record_whole_document();
+ updated = true;
+ }
+
+ if (updated)
+ FOR_EACH_OBSERVER(Observer, observer_list_, OnWebPreferencesChanged());
+}
+
+} // namespace blimp

Powered by Google App Engine
This is Rietveld 408576698