OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 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 "chrome/browser/accessibility/accessibility_notifier.h" |
| 6 |
| 7 #include "base/prefs/pref_service.h" |
| 8 #include "chrome/browser/chrome_notification_types.h" |
| 9 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 10 #include "chrome/browser/profiles/profile.h" |
| 11 #include "chrome/common/pref_names.h" |
| 12 #include "content/public/browser/browser_accessibility_state.h" |
| 13 #include "content/public/browser/notification_details.h" |
| 14 #include "content/public/browser/notification_service.h" |
| 15 #include "content/public/browser/notification_source.h" |
| 16 |
| 17 AccessibilityNotifier::AccessibilityNotifier(Profile* profile) |
| 18 : profile_(profile), animation_policy_(ANIMATION_POLICY_ALLOWED) { |
| 19 SetProfile(profile); |
| 20 } |
| 21 |
| 22 AccessibilityNotifier::~AccessibilityNotifier() { |
| 23 } |
| 24 |
| 25 void AccessibilityNotifier::Shutdown() { |
| 26 pref_change_registrar_.reset(); |
| 27 } |
| 28 |
| 29 void AccessibilityNotifier::SetProfile(Profile* profile) { |
| 30 pref_change_registrar_.reset(); |
| 31 if (profile) { |
| 32 profile_ = profile; |
| 33 pref_change_registrar_.reset(new PrefChangeRegistrar); |
| 34 pref_change_registrar_->Init(profile->GetPrefs()); |
| 35 pref_change_registrar_->Add( |
| 36 prefs::kAnimationPolicy, |
| 37 base::Bind(&AccessibilityNotifier::UpdateAnimationPolicyFromPref, |
| 38 base::Unretained(this))); |
| 39 } |
| 40 } |
| 41 |
| 42 void AccessibilityNotifier::UpdateAnimationPolicyFromPref() { |
| 43 PrefService* pref_service = profile_->GetPrefs(); |
| 44 std::string image_animation_policy = |
| 45 pref_service->GetString(prefs::kAnimationPolicy); |
| 46 AnimationPolicy animation_policy_from_prefs = ANIMATION_POLICY_ALLOWED; |
| 47 if (image_animation_policy == "once") |
| 48 animation_policy_from_prefs = ANIMATION_POLICY_ANIMATION_ONCE; |
| 49 else if (image_animation_policy == "none") |
| 50 animation_policy_from_prefs = ANIMATION_POLICY_NO_ANIMATION; |
| 51 |
| 52 if (animation_policy_ == animation_policy_from_prefs) |
| 53 return; |
| 54 |
| 55 animation_policy_ = animation_policy_from_prefs; |
| 56 content::BrowserAccessibilityState::GetInstance()->UpdateAnimationPolicy(); |
| 57 } |
OLD | NEW |