| 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 "base/string_util.h" | 7 #include "base/string_util.h" |
| 8 #include "base/stringprintf.h" | 8 #include "base/stringprintf.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 per_tab_pref_change_registrar_.Init(per_tab_prefs_.get()); | 357 per_tab_pref_change_registrar_.Init(per_tab_prefs_.get()); |
| 358 for (int i = 0; i < kPerTabPrefsToObserveLength; ++i) { | 358 for (int i = 0; i < kPerTabPrefsToObserveLength; ++i) { |
| 359 per_tab_pref_change_registrar_.Add(kPerTabPrefsToObserve[i], this); | 359 per_tab_pref_change_registrar_.Add(kPerTabPrefsToObserve[i], this); |
| 360 } | 360 } |
| 361 | 361 |
| 362 renderer_preferences_util::UpdateFromSystemSettings( | 362 renderer_preferences_util::UpdateFromSystemSettings( |
| 363 web_contents()->GetMutableRendererPrefs(), GetProfile()); | 363 web_contents()->GetMutableRendererPrefs(), GetProfile()); |
| 364 | 364 |
| 365 registrar_.Add(this, chrome::NOTIFICATION_USER_STYLE_SHEET_UPDATED, | 365 registrar_.Add(this, chrome::NOTIFICATION_USER_STYLE_SHEET_UPDATED, |
| 366 content::NotificationService::AllSources()); | 366 content::NotificationService::AllSources()); |
| 367 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 367 #if defined(OS_POSIX) && !defined(OS_MACOSX) && defined(ENABLE_THEMES) |
| 368 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED, | 368 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED, |
| 369 content::Source<ThemeService>( | 369 content::Source<ThemeService>( |
| 370 ThemeServiceFactory::GetForProfile(GetProfile()))); | 370 ThemeServiceFactory::GetForProfile(GetProfile()))); |
| 371 #endif | 371 #endif |
| 372 } | 372 } |
| 373 | 373 |
| 374 PrefsTabHelper::~PrefsTabHelper() { | 374 PrefsTabHelper::~PrefsTabHelper() { |
| 375 } | 375 } |
| 376 | 376 |
| 377 // static | 377 // static |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 578 per_tab_pref_change_registrar_.RemoveAll(); | 578 per_tab_pref_change_registrar_.RemoveAll(); |
| 579 } | 579 } |
| 580 | 580 |
| 581 void PrefsTabHelper::Observe(int type, | 581 void PrefsTabHelper::Observe(int type, |
| 582 const content::NotificationSource& source, | 582 const content::NotificationSource& source, |
| 583 const content::NotificationDetails& details) { | 583 const content::NotificationDetails& details) { |
| 584 switch (type) { | 584 switch (type) { |
| 585 case chrome::NOTIFICATION_USER_STYLE_SHEET_UPDATED: | 585 case chrome::NOTIFICATION_USER_STYLE_SHEET_UPDATED: |
| 586 UpdateWebPreferences(); | 586 UpdateWebPreferences(); |
| 587 break; | 587 break; |
| 588 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 588 #if defined(OS_POSIX) && !defined(OS_MACOSX) && defined(ENABLE_THEMES) |
| 589 case chrome::NOTIFICATION_BROWSER_THEME_CHANGED: { | 589 case chrome::NOTIFICATION_BROWSER_THEME_CHANGED: { |
| 590 UpdateRendererPreferences(); | 590 UpdateRendererPreferences(); |
| 591 break; | 591 break; |
| 592 } | 592 } |
| 593 #endif | 593 #endif |
| 594 case chrome::NOTIFICATION_PREF_CHANGED: { | 594 case chrome::NOTIFICATION_PREF_CHANGED: { |
| 595 std::string* pref_name_in = content::Details<std::string>(details).ptr(); | 595 std::string* pref_name_in = content::Details<std::string>(details).ptr(); |
| 596 DCHECK(content::Source<PrefService>(source).ptr() == | 596 DCHECK(content::Source<PrefService>(source).ptr() == |
| 597 GetProfile()->GetPrefs() || | 597 GetProfile()->GetPrefs() || |
| 598 content::Source<PrefService>(source).ptr() == per_tab_prefs_); | 598 content::Source<PrefService>(source).ptr() == per_tab_prefs_); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 658 | 658 |
| 659 void PrefsTabHelper::UpdateRendererPreferences() { | 659 void PrefsTabHelper::UpdateRendererPreferences() { |
| 660 renderer_preferences_util::UpdateFromSystemSettings( | 660 renderer_preferences_util::UpdateFromSystemSettings( |
| 661 web_contents()->GetMutableRendererPrefs(), GetProfile()); | 661 web_contents()->GetMutableRendererPrefs(), GetProfile()); |
| 662 web_contents()->GetRenderViewHost()->SyncRendererPrefs(); | 662 web_contents()->GetRenderViewHost()->SyncRendererPrefs(); |
| 663 } | 663 } |
| 664 | 664 |
| 665 Profile* PrefsTabHelper::GetProfile() { | 665 Profile* PrefsTabHelper::GetProfile() { |
| 666 return Profile::FromBrowserContext(web_contents()->GetBrowserContext()); | 666 return Profile::FromBrowserContext(web_contents()->GetBrowserContext()); |
| 667 } | 667 } |
| OLD | NEW |