| OLD | NEW | 
|    1 // Copyright 2015 The Chromium Authors. All rights reserved. |    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 |    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/extensions/api/settings_private/settings_private_event_
     router.h" |    5 #include "chrome/browser/extensions/api/settings_private/settings_private_event_
     router.h" | 
|    6  |    6  | 
|    7 #include <utility> |    7 #include <utility> | 
|    8 #include <vector> |    8 #include <vector> | 
|    9  |    9  | 
|   10 #include "base/bind.h" |   10 #include "base/bind.h" | 
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  121   } |  121   } | 
|  122   listening_ = should_listen; |  122   listening_ = should_listen; | 
|  123 } |  123 } | 
|  124  |  124  | 
|  125 void SettingsPrivateEventRouter::OnPreferenceChanged( |  125 void SettingsPrivateEventRouter::OnPreferenceChanged( | 
|  126     const std::string& pref_name) { |  126     const std::string& pref_name) { | 
|  127   // This posts an asynchronous task to ensure that all pref stores are updated, |  127   // This posts an asynchronous task to ensure that all pref stores are updated, | 
|  128   // as |prefs_util_->GetPref()| relies on this information to determine if a |  128   // as |prefs_util_->GetPref()| relies on this information to determine if a | 
|  129   // preference is controlled by e.g. extensions. |  129   // preference is controlled by e.g. extensions. | 
|  130   base::ThreadTaskRunnerHandle::Get()->PostTask( |  130   base::ThreadTaskRunnerHandle::Get()->PostTask( | 
|  131       FROM_HERE, base::Bind(&SettingsPrivateEventRouter::SendPrefChange, |  131       FROM_HERE, base::BindOnce(&SettingsPrivateEventRouter::SendPrefChange, | 
|  132                             weak_ptr_factory_.GetWeakPtr(), pref_name)); |  132                                 weak_ptr_factory_.GetWeakPtr(), pref_name)); | 
|  133 } |  133 } | 
|  134  |  134  | 
|  135 void SettingsPrivateEventRouter::SendPrefChange(const std::string& pref_name) { |  135 void SettingsPrivateEventRouter::SendPrefChange(const std::string& pref_name) { | 
|  136   EventRouter* event_router = EventRouter::Get(context_); |  136   EventRouter* event_router = EventRouter::Get(context_); | 
|  137   if (!event_router->HasEventListener( |  137   if (!event_router->HasEventListener( | 
|  138           api::settings_private::OnPrefsChanged::kEventName)) { |  138           api::settings_private::OnPrefsChanged::kEventName)) { | 
|  139     return; |  139     return; | 
|  140   } |  140   } | 
|  141  |  141  | 
|  142   std::unique_ptr<api::settings_private::PrefObject> pref_object = |  142   std::unique_ptr<api::settings_private::PrefObject> pref_object = | 
| (...skipping 11 matching lines...) Expand all  Loading... | 
|  154       api::settings_private::OnPrefsChanged::kEventName, std::move(args))); |  154       api::settings_private::OnPrefsChanged::kEventName, std::move(args))); | 
|  155   event_router->BroadcastEvent(std::move(extension_event)); |  155   event_router->BroadcastEvent(std::move(extension_event)); | 
|  156 } |  156 } | 
|  157  |  157  | 
|  158 SettingsPrivateEventRouter* SettingsPrivateEventRouter::Create( |  158 SettingsPrivateEventRouter* SettingsPrivateEventRouter::Create( | 
|  159     content::BrowserContext* context) { |  159     content::BrowserContext* context) { | 
|  160   return new SettingsPrivateEventRouter(context); |  160   return new SettingsPrivateEventRouter(context); | 
|  161 } |  161 } | 
|  162  |  162  | 
|  163 }  // namespace extensions |  163 }  // namespace extensions | 
| OLD | NEW |