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

Side by Side Diff: chrome/browser/ui/prefs/prefs_tab_helper.cc

Issue 1456843002: Finch experiment: auto-detect text encoding (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merged with the cl using the new methods Created 5 years 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 unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/dom/Document.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/ui/prefs/prefs_tab_helper.h" 5 #include "chrome/browser/ui/prefs/prefs_tab_helper.h"
6 6
7 #include <set> 7 #include <set>
8 #include <string> 8 #include <string>
9 9
10 #include "base/command_line.h"
10 #include "base/memory/singleton.h" 11 #include "base/memory/singleton.h"
12 #include "base/metrics/field_trial.h"
11 #include "base/prefs/overlay_user_pref_store.h" 13 #include "base/prefs/overlay_user_pref_store.h"
12 #include "base/prefs/pref_change_registrar.h" 14 #include "base/prefs/pref_change_registrar.h"
13 #include "base/prefs/pref_service.h" 15 #include "base/prefs/pref_service.h"
14 #include "base/strings/string_number_conversions.h" 16 #include "base/strings/string_number_conversions.h"
15 #include "base/strings/string_util.h" 17 #include "base/strings/string_util.h"
16 #include "base/strings/stringprintf.h" 18 #include "base/strings/stringprintf.h"
17 #include "base/strings/utf_string_conversions.h" 19 #include "base/strings/utf_string_conversions.h"
18 #include "chrome/browser/browser_process.h" 20 #include "chrome/browser/browser_process.h"
19 #include "chrome/browser/chrome_notification_types.h" 21 #include "chrome/browser/chrome_notification_types.h"
20 #include "chrome/browser/profiles/incognito_helpers.h" 22 #include "chrome/browser/profiles/incognito_helpers.h"
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 void RegisterLocalizedFontPref(user_prefs::PrefRegistrySyncable* registry, 313 void RegisterLocalizedFontPref(user_prefs::PrefRegistrySyncable* registry,
312 const char* path, 314 const char* path,
313 int default_message_id) { 315 int default_message_id) {
314 int val = 0; 316 int val = 0;
315 bool success = base::StringToInt(l10n_util::GetStringUTF8( 317 bool success = base::StringToInt(l10n_util::GetStringUTF8(
316 default_message_id), &val); 318 default_message_id), &val);
317 DCHECK(success); 319 DCHECK(success);
318 registry->RegisterIntegerPref(path, val); 320 registry->RegisterIntegerPref(path, val);
319 } 321 }
320 322
323 bool IsAutodetectEncodingEnabled() {
battre 2015/12/02 13:08:26 nit: Should this be IsAutodetectEncodingEnabledByD
Jinsuk Kim 2015/12/02 23:14:38 Done.
324 const std::string group_name = base::FieldTrialList::FindFullName(
325 "AutodetectEncoding");
326 return base::StartsWith(group_name,
327 "Enabled",
328 base::CompareCase::INSENSITIVE_ASCII);
329 }
330
321 } // namespace 331 } // namespace
322 332
323 // Watching all these settings per tab is slow when a user has a lot of tabs and 333 // Watching all these settings per tab is slow when a user has a lot of tabs and
324 // and they use session restore. So watch them once per profile. 334 // and they use session restore. So watch them once per profile.
325 // http://crbug.com/452693 335 // http://crbug.com/452693
326 class PrefWatcher : public KeyedService { 336 class PrefWatcher : public KeyedService {
327 public: 337 public:
328 explicit PrefWatcher(Profile* profile) : profile_(profile) { 338 explicit PrefWatcher(Profile* profile) : profile_(profile) {
329 pref_change_registrar_.Init(profile_->GetPrefs()); 339 pref_change_registrar_.Init(profile_->GetPrefs());
330 340
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 #endif 584 #endif
575 585
576 RegisterLocalizedFontPref(registry, prefs::kWebKitDefaultFontSize, 586 RegisterLocalizedFontPref(registry, prefs::kWebKitDefaultFontSize,
577 IDS_DEFAULT_FONT_SIZE); 587 IDS_DEFAULT_FONT_SIZE);
578 RegisterLocalizedFontPref(registry, prefs::kWebKitDefaultFixedFontSize, 588 RegisterLocalizedFontPref(registry, prefs::kWebKitDefaultFixedFontSize,
579 IDS_DEFAULT_FIXED_FONT_SIZE); 589 IDS_DEFAULT_FIXED_FONT_SIZE);
580 RegisterLocalizedFontPref(registry, prefs::kWebKitMinimumFontSize, 590 RegisterLocalizedFontPref(registry, prefs::kWebKitMinimumFontSize,
581 IDS_MINIMUM_FONT_SIZE); 591 IDS_MINIMUM_FONT_SIZE);
582 RegisterLocalizedFontPref(registry, prefs::kWebKitMinimumLogicalFontSize, 592 RegisterLocalizedFontPref(registry, prefs::kWebKitMinimumLogicalFontSize,
583 IDS_MINIMUM_LOGICAL_FONT_SIZE); 593 IDS_MINIMUM_LOGICAL_FONT_SIZE);
594 bool uses_universal_detector = IsAutodetectEncodingEnabled() ?
595 true : l10n_util::GetStringUTF8(IDS_USES_UNIVERSAL_DETECTOR) == "true";
battre 2015/12/02 13:08:26 ... = IsAutodetectEncodingEnabled() || l10n_util::
Jinsuk Kim 2015/12/02 23:14:38 Done.
584 registry->RegisterBooleanPref( 596 registry->RegisterBooleanPref(
585 prefs::kWebKitUsesUniversalDetector, 597 prefs::kWebKitUsesUniversalDetector,
586 l10n_util::GetStringUTF8(IDS_USES_UNIVERSAL_DETECTOR) == "true", 598 uses_universal_detector,
587 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); 599 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
588 registry->RegisterStringPref( 600 registry->RegisterStringPref(
589 prefs::kStaticEncodings, 601 prefs::kStaticEncodings,
590 l10n_util::GetStringUTF8(IDS_STATIC_ENCODING_LIST)); 602 l10n_util::GetStringUTF8(IDS_STATIC_ENCODING_LIST));
591 registry->RegisterStringPref(prefs::kRecentlySelectedEncoding, std::string()); 603 registry->RegisterStringPref(prefs::kRecentlySelectedEncoding, std::string());
592 } 604 }
593 605
594 // static 606 // static
595 void PrefsTabHelper::GetServiceInstance() { 607 void PrefsTabHelper::GetServiceInstance() {
596 PrefWatcherFactory::GetInstance(); 608 PrefWatcherFactory::GetInstance();
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
658 } 670 }
659 } 671 }
660 672
661 void PrefsTabHelper::OnWebPrefChanged(const std::string& pref_name) { 673 void PrefsTabHelper::OnWebPrefChanged(const std::string& pref_name) {
662 #if !defined(OS_ANDROID) 674 #if !defined(OS_ANDROID)
663 OnFontFamilyPrefChanged(pref_name); 675 OnFontFamilyPrefChanged(pref_name);
664 #endif 676 #endif
665 677
666 web_contents_->GetRenderViewHost()->OnWebkitPreferencesChanged(); 678 web_contents_->GetRenderViewHost()->OnWebkitPreferencesChanged();
667 } 679 }
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/dom/Document.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698