| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "chrome/browser/profile_resetter/resettable_settings_snapshot.h" | 5 #include "chrome/browser/profile_resetter/resettable_settings_snapshot.h" |
| 6 | 6 |
| 7 #include "base/json/json_writer.h" | 7 #include "base/json/json_writer.h" |
| 8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 | 119 |
| 120 if (dse_url_ != snapshot.dse_url_) | 120 if (dse_url_ != snapshot.dse_url_) |
| 121 bit_mask |= DSE_URL; | 121 bit_mask |= DSE_URL; |
| 122 | 122 |
| 123 if (enabled_extensions_ != snapshot.enabled_extensions_) | 123 if (enabled_extensions_ != snapshot.enabled_extensions_) |
| 124 bit_mask |= EXTENSIONS; | 124 bit_mask |= EXTENSIONS; |
| 125 | 125 |
| 126 if (shortcuts_ != snapshot.shortcuts_) | 126 if (shortcuts_ != snapshot.shortcuts_) |
| 127 bit_mask |= SHORTCUTS; | 127 bit_mask |= SHORTCUTS; |
| 128 | 128 |
| 129 COMPILE_ASSERT(ResettableSettingsSnapshot::ALL_FIELDS == 31, | 129 static_assert(ResettableSettingsSnapshot::ALL_FIELDS == 31, |
| 130 add_new_field_here); | 130 "new field needs to be added here"); |
| 131 | 131 |
| 132 return bit_mask; | 132 return bit_mask; |
| 133 } | 133 } |
| 134 | 134 |
| 135 void ResettableSettingsSnapshot::RequestShortcuts( | 135 void ResettableSettingsSnapshot::RequestShortcuts( |
| 136 const base::Closure& callback) { | 136 const base::Closure& callback) { |
| 137 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 137 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 138 DCHECK(!cancellation_flag_.get() && !shortcuts_determined()); | 138 DCHECK(!cancellation_flag_.get() && !shortcuts_determined()); |
| 139 | 139 |
| 140 cancellation_flag_ = new SharedCancellationFlag; | 140 cancellation_flag_ = new SharedCancellationFlag; |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 i != shortcuts.end(); ++i) { | 204 i != shortcuts.end(); ++i) { |
| 205 base::string16 arguments; | 205 base::string16 arguments; |
| 206 // Replace "\"" to simplify server-side analysis. | 206 // Replace "\"" to simplify server-side analysis. |
| 207 base::ReplaceChars(i->second, base::ASCIIToUTF16("\""), | 207 base::ReplaceChars(i->second, base::ASCIIToUTF16("\""), |
| 208 base::ASCIIToUTF16("\'"), &arguments); | 208 base::ASCIIToUTF16("\'"), &arguments); |
| 209 list->AppendString(arguments); | 209 list->AppendString(arguments); |
| 210 } | 210 } |
| 211 dict.Set(kShortcuts, list); | 211 dict.Set(kShortcuts, list); |
| 212 } | 212 } |
| 213 | 213 |
| 214 COMPILE_ASSERT(ResettableSettingsSnapshot::ALL_FIELDS == 31, | 214 static_assert(ResettableSettingsSnapshot::ALL_FIELDS == 31, |
| 215 serialize_new_field_here); | 215 "new field needs to be serialized here"); |
| 216 | 216 |
| 217 std::string json; | 217 std::string json; |
| 218 base::JSONWriter::Write(&dict, &json); | 218 base::JSONWriter::Write(&dict, &json); |
| 219 return json; | 219 return json; |
| 220 } | 220 } |
| 221 | 221 |
| 222 void SendSettingsFeedback(const std::string& report, | 222 void SendSettingsFeedback(const std::string& report, |
| 223 Profile* profile, | 223 Profile* profile, |
| 224 SnapshotCaller caller) { | 224 SnapshotCaller caller) { |
| 225 scoped_refptr<FeedbackData> feedback_data = new FeedbackData(); | 225 scoped_refptr<FeedbackData> feedback_data = new FeedbackData(); |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 extension_names += '\n'; | 359 extension_names += '\n'; |
| 360 extension_names += i->second; | 360 extension_names += i->second; |
| 361 } | 361 } |
| 362 if (!extension_names.empty()) { | 362 if (!extension_names.empty()) { |
| 363 AddPair(list.get(), | 363 AddPair(list.get(), |
| 364 l10n_util::GetStringUTF16(IDS_RESET_PROFILE_SETTINGS_EXTENSIONS), | 364 l10n_util::GetStringUTF16(IDS_RESET_PROFILE_SETTINGS_EXTENSIONS), |
| 365 extension_names); | 365 extension_names); |
| 366 } | 366 } |
| 367 return list.Pass(); | 367 return list.Pass(); |
| 368 } | 368 } |
| OLD | NEW |