Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <set> | 10 #include <set> |
| 11 #include <string> | 11 #include <string> |
| 12 | 12 |
| 13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/memory/singleton.h" | 15 #include "base/memory/singleton.h" |
| 16 #include "base/strings/string_number_conversions.h" | 16 #include "base/strings/string_number_conversions.h" |
| 17 #include "base/strings/string_util.h" | 17 #include "base/strings/string_util.h" |
| 18 #include "base/strings/stringprintf.h" | 18 #include "base/strings/stringprintf.h" |
| 19 #include "base/strings/utf_string_conversions.h" | 19 #include "base/strings/utf_string_conversions.h" |
| 20 #include "base/threading/thread_task_runner_handle.h" | 20 #include "base/threading/thread_task_runner_handle.h" |
| 21 #include "build/build_config.h" | 21 #include "build/build_config.h" |
| 22 #include "chrome/browser/browser_process.h" | 22 #include "chrome/browser/browser_process.h" |
| 23 #include "chrome/browser/chrome_notification_types.h" | 23 #include "chrome/browser/chrome_notification_types.h" |
| 24 #include "chrome/browser/profiles/incognito_helpers.h" | 24 #include "chrome/browser/profiles/incognito_helpers.h" |
| 25 #include "chrome/browser/profiles/profile.h" | 25 #include "chrome/browser/profiles/profile.h" |
| 26 #include "chrome/browser/renderer_preferences_util.h" | 26 #include "chrome/browser/renderer_preferences_util.h" |
| 27 #include "chrome/browser/ui/zoom/chrome_zoom_level_prefs.h" | |
| 28 #include "chrome/common/pref_font_webkit_names.h" | 27 #include "chrome/common/pref_font_webkit_names.h" |
| 29 #include "chrome/common/pref_names.h" | 28 #include "chrome/common/pref_names.h" |
| 30 #include "chrome/common/pref_names_util.h" | 29 #include "chrome/common/pref_names_util.h" |
| 31 #include "chrome/grit/locale_settings.h" | 30 #include "chrome/grit/locale_settings.h" |
| 32 #include "chrome/grit/platform_locale_settings.h" | 31 #include "chrome/grit/platform_locale_settings.h" |
| 33 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 32 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
| 34 #include "components/keyed_service/content/browser_context_keyed_service_factory .h" | 33 #include "components/keyed_service/content/browser_context_keyed_service_factory .h" |
| 35 #include "components/keyed_service/core/keyed_service.h" | 34 #include "components/keyed_service/core/keyed_service.h" |
| 36 #include "components/pref_registry/pref_registry_syncable.h" | 35 #include "components/pref_registry/pref_registry_syncable.h" |
| 37 #include "components/prefs/overlay_user_pref_store.h" | 36 #include "components/prefs/overlay_user_pref_store.h" |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 53 | 52 |
| 54 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) | 53 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) |
| 55 #include "chrome/browser/themes/theme_service.h" | 54 #include "chrome/browser/themes/theme_service.h" |
| 56 #include "chrome/browser/themes/theme_service_factory.h" | 55 #include "chrome/browser/themes/theme_service_factory.h" |
| 57 #endif | 56 #endif |
| 58 | 57 |
| 59 #if defined(OS_WIN) | 58 #if defined(OS_WIN) |
| 60 #include "base/win/windows_version.h" | 59 #include "base/win/windows_version.h" |
| 61 #endif | 60 #endif |
| 62 | 61 |
| 62 #if !defined(OS_ANDROID) | |
|
Bernhard Bauer
2017/05/15 09:33:28
Can you move this up before OS_POSIX etc. so the b
Kevin McNee
2017/05/15 20:02:10
Done.
| |
| 63 #include "chrome/browser/ui/zoom/chrome_zoom_level_prefs.h" | |
| 64 #endif | |
| 65 | |
| 63 using content::WebContents; | 66 using content::WebContents; |
| 64 using content::WebPreferences; | 67 using content::WebPreferences; |
| 65 | 68 |
| 66 DEFINE_WEB_CONTENTS_USER_DATA_KEY(PrefsTabHelper); | 69 DEFINE_WEB_CONTENTS_USER_DATA_KEY(PrefsTabHelper); |
| 67 | 70 |
| 68 namespace { | 71 namespace { |
| 69 | 72 |
| 70 // The list of prefs we want to observe. | 73 // The list of prefs we want to observe. |
| 71 const char* const kPrefsToObserve[] = { | 74 const char* const kPrefsToObserve[] = { |
| 72 #if BUILDFLAG(ENABLE_EXTENSIONS) | 75 #if BUILDFLAG(ENABLE_EXTENSIONS) |
| (...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 466 PrefWatcher* PrefWatcher::Get(Profile* profile) { | 469 PrefWatcher* PrefWatcher::Get(Profile* profile) { |
| 467 return PrefWatcherFactory::GetForProfile(profile); | 470 return PrefWatcherFactory::GetForProfile(profile); |
| 468 } | 471 } |
| 469 | 472 |
| 470 PrefsTabHelper::PrefsTabHelper(WebContents* contents) | 473 PrefsTabHelper::PrefsTabHelper(WebContents* contents) |
| 471 : web_contents_(contents), | 474 : web_contents_(contents), |
| 472 profile_(Profile::FromBrowserContext(web_contents_->GetBrowserContext())), | 475 profile_(Profile::FromBrowserContext(web_contents_->GetBrowserContext())), |
| 473 weak_ptr_factory_(this) { | 476 weak_ptr_factory_(this) { |
| 474 PrefService* prefs = profile_->GetPrefs(); | 477 PrefService* prefs = profile_->GetPrefs(); |
| 475 if (prefs) { | 478 if (prefs) { |
| 479 #if !defined(OS_ANDROID) | |
| 476 // If the tab is in an incognito profile, we track changes in the default | 480 // If the tab is in an incognito profile, we track changes in the default |
| 477 // zoom level of the parent profile instead. | 481 // zoom level of the parent profile instead. |
| 478 Profile* profile_to_track = profile_->GetOriginalProfile(); | 482 Profile* profile_to_track = profile_->GetOriginalProfile(); |
| 479 ChromeZoomLevelPrefs* zoom_level_prefs = | 483 ChromeZoomLevelPrefs* zoom_level_prefs = |
| 480 profile_to_track->GetZoomLevelPrefs(); | 484 profile_to_track->GetZoomLevelPrefs(); |
| 485 #endif // !defined(OS_ANDROID) | |
| 481 | 486 |
| 482 base::Closure renderer_callback = base::Bind( | 487 base::Closure renderer_callback = base::Bind( |
|
msw
2017/05/12 18:06:32
It seems like you can include this in a !defined(O
Kevin McNee
2017/05/15 20:02:10
Done.
| |
| 483 &PrefsTabHelper::UpdateRendererPreferences, base::Unretained(this)); | 488 &PrefsTabHelper::UpdateRendererPreferences, base::Unretained(this)); |
| 489 #if !defined(OS_ANDROID) | |
| 484 // Tests should not need to create a ZoomLevelPrefs. | 490 // Tests should not need to create a ZoomLevelPrefs. |
| 485 if (zoom_level_prefs) { | 491 if (zoom_level_prefs) { |
| 486 default_zoom_level_subscription_ = | 492 default_zoom_level_subscription_ = |
| 487 zoom_level_prefs->RegisterDefaultZoomLevelCallback(renderer_callback); | 493 zoom_level_prefs->RegisterDefaultZoomLevelCallback(renderer_callback); |
| 488 } | 494 } |
| 495 #endif // !defined(OS_ANDROID) | |
| 489 | 496 |
| 490 PrefWatcher::Get(profile_)->RegisterHelper(this); | 497 PrefWatcher::Get(profile_)->RegisterHelper(this); |
| 491 } | 498 } |
| 492 | 499 |
| 493 content::RendererPreferences* render_prefs = | 500 content::RendererPreferences* render_prefs = |
| 494 web_contents_->GetMutableRendererPrefs(); | 501 web_contents_->GetMutableRendererPrefs(); |
| 495 renderer_preferences_util::UpdateFromSystemSettings(render_prefs, | 502 renderer_preferences_util::UpdateFromSystemSettings(render_prefs, |
| 496 profile_, | 503 profile_, |
| 497 web_contents_); | 504 web_contents_); |
| 498 | 505 |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 681 } | 688 } |
| 682 | 689 |
| 683 void PrefsTabHelper::NotifyWebkitPreferencesChanged( | 690 void PrefsTabHelper::NotifyWebkitPreferencesChanged( |
| 684 const std::string& pref_name) { | 691 const std::string& pref_name) { |
| 685 #if !defined(OS_ANDROID) | 692 #if !defined(OS_ANDROID) |
| 686 OnFontFamilyPrefChanged(pref_name); | 693 OnFontFamilyPrefChanged(pref_name); |
| 687 #endif | 694 #endif |
| 688 | 695 |
| 689 web_contents_->GetRenderViewHost()->OnWebkitPreferencesChanged(); | 696 web_contents_->GetRenderViewHost()->OnWebkitPreferencesChanged(); |
| 690 } | 697 } |
| OLD | NEW |