Chromium Code Reviews| 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.h" | |
| 6 | |
| 7 #include "base/command_line.h" | |
| 8 #include "blimp/client/core/blimp_client_switches.h" | |
| 9 #include "blimp/client/core/settings/settings_observer.h" | |
| 10 #include "blimp/client/core/settings/settings_prefs.h" | |
| 11 #include "components/prefs/pref_registry_simple.h" | |
| 12 #include "components/prefs/pref_service.h" | |
| 13 | |
| 14 namespace blimp { | |
| 15 namespace client { | |
| 16 | |
| 17 Settings::Settings(PrefService* local_state) | |
| 18 : local_state_(local_state), | |
| 19 record_whole_document_(false), | |
| 20 show_network_stats_(false) {} | |
| 21 | |
| 22 Settings::~Settings() {} | |
|
David Trainor- moved to gerrit
2016/09/27 04:10:06
= default
Menglin
2016/09/30 23:48:57
Done.
| |
| 23 | |
| 24 void Settings::AddObserver(std::unique_ptr<SettingsObserver> observer) { | |
| 25 observers_.push_back(std::move(observer)); | |
| 26 } | |
| 27 | |
| 28 void Settings::SetShowNetworkStats(bool enable) { | |
| 29 show_network_stats_ = enable; | |
| 30 for (const auto& observer : observers_) { | |
|
David Trainor- moved to gerrit
2016/09/27 04:10:06
Use the observer macro?
Menglin
2016/09/30 23:48:57
Done.
| |
| 31 observer->OnShowNetworkStatsChanged(show_network_stats_); | |
| 32 } | |
| 33 } | |
| 34 | |
| 35 void Settings::SetEnableBlimpMode(bool enable) { | |
| 36 blimp_enabled_ = enable; | |
| 37 local_state_->SetBoolean(prefs::kBlimpEnabled, enable); | |
|
David Trainor- moved to gerrit
2016/09/27 04:10:06
Notify the enable blimp mode state changed first?
Menglin
2016/09/30 23:48:56
Done.
| |
| 38 for (const auto& observer : observers_) { | |
| 39 observer->OnRestartRequired(); | |
| 40 } | |
| 41 } | |
| 42 | |
| 43 void Settings::SetRecordWholeDocument(bool enable) { | |
| 44 if (record_whole_document_ == enable) return; | |
|
David Trainor- moved to gerrit
2016/09/27 04:10:06
Put this on the others as well?
Menglin
2016/09/30 23:48:56
Done.
| |
| 45 | |
| 46 record_whole_document_ = enable; | |
| 47 local_state_->SetBoolean(prefs::kRecordWholeDocument, record_whole_document_); | |
| 48 for (const auto& observer : observers_) { | |
| 49 observer->OnRecordWholeDocumentChanged(record_whole_document_); | |
| 50 } | |
|
David Trainor- moved to gerrit
2016/09/27 04:10:06
Also requires restart
Menglin
2016/09/30 23:48:57
Done.
Menglin
2016/10/24 22:44:58
I'm removing OnRestartRequired() for this and usin
| |
| 51 } | |
| 52 | |
| 53 void Settings::InitializeFromCommandLineAndPref() { | |
|
David Trainor- moved to gerrit
2016/09/27 04:10:06
Let's be consistent with how we do this (call set
Menglin
2016/09/30 23:48:57
ok. After the change, InitializeFromCommandLineAnd
| |
| 54 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); | |
| 55 | |
| 56 blimp_enabled_ = cmd_line->HasSwitch(switches::kEnableBlimp) || | |
| 57 local_state_->GetBoolean(prefs::kBlimpEnabled); | |
| 58 | |
| 59 bool record_whole_document_enabled = | |
| 60 cmd_line->HasSwitch(switches::kDownloadWholeDocument) || | |
| 61 local_state_->GetBoolean(prefs::kRecordWholeDocument); | |
| 62 SetRecordWholeDocument(record_whole_document_enabled); | |
| 63 } | |
| 64 | |
| 65 // static | |
| 66 void Settings::RegisterPrefs(PrefRegistrySimple* registry) { | |
| 67 registry->RegisterBooleanPref(prefs::kBlimpEnabled, false); | |
| 68 registry->RegisterBooleanPref(prefs::kRecordWholeDocument, false); | |
| 69 } | |
| 70 | |
| 71 } // namespace client | |
| 72 } // namespace blimp | |
| OLD | NEW |