Chromium Code Reviews| Index: chrome/browser/ui/webui/settings/font_handler.cc |
| diff --git a/chrome/browser/ui/webui/settings/font_handler.cc b/chrome/browser/ui/webui/settings/font_handler.cc |
| index 9192acd162776b396ee9033ec44fbcd552e8d2d1..15c032f0395223d85c95d02446cff64fc163d0fd 100644 |
| --- a/chrome/browser/ui/webui/settings/font_handler.cc |
| +++ b/chrome/browser/ui/webui/settings/font_handler.cc |
| @@ -59,6 +59,17 @@ void FontHandler::RegisterMessages() { |
| base::Unretained(this))); |
| } |
| +void FontHandler::OnJavascriptAllowed() { |
| + extensions::ExtensionRegistry* observer = |
| + extensions::ExtensionRegistry::Get(profile_); |
|
Dan Beam
2016/04/18 23:13:20
indent off
tommycli
2016/04/19 17:45:38
Done.
|
| + if (!extension_registry_observer_.IsObserving(observer)) |
|
Dan Beam
2016/04/18 23:13:20
why do you need this if?
tommycli
2016/04/19 17:45:37
Done.
|
| + extension_registry_observer_.Add(observer); |
| +} |
| + |
| +void FontHandler::OnJavascriptDisallowed() { |
| + extension_registry_observer_.RemoveAll(); |
| +} |
| + |
| void FontHandler::HandleFetchFontsData(const base::ListValue* args) { |
| CHECK_EQ(1U, args->GetSize()); |
| std::string callback_id; |
| @@ -71,10 +82,7 @@ void FontHandler::HandleFetchFontsData(const base::ListValue* args) { |
| void FontHandler::HandleObserveAdvancedFontExtensionAvailable( |
| const base::ListValue* /*args*/) { |
| - extensions::ExtensionRegistry* observer = |
| - extensions::ExtensionRegistry::Get(profile_); |
| - if (!extension_registry_observer_.IsObserving(observer)) |
| - extension_registry_observer_.Add(observer); |
| + AllowJavascript(); |
| NotifyAdvancedFontSettingsAvailability(); |
| } |
| @@ -97,7 +105,7 @@ const extensions::Extension* FontHandler::GetAdvancedFontSettingsExtension() { |
| } |
| void FontHandler::NotifyAdvancedFontSettingsAvailability() { |
| - web_ui()->CallJavascriptFunction( |
| + CallJavascriptFunction( |
| "cr.webUIListenerCallback", |
| base::StringValue("advanced-font-settings-installed"), |
| base::FundamentalValue(GetAdvancedFontSettingsExtension() != nullptr)); |
| @@ -171,8 +179,4 @@ void FontHandler::FontListHasLoaded(std::string callback_id, |
| ResolveJavascriptCallback(base::StringValue(callback_id), response); |
| } |
| -void FontHandler::RenderViewReused() { |
| - extension_registry_observer_.RemoveAll(); |
| -} |
| - |
| } // namespace settings |