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/webui/ntp/app_launcher_handler.h" | 5 #include "chrome/browser/ui/webui/ntp/app_launcher_handler.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 const Extension* extension) { | 340 const Extension* extension) { |
341 if (!ShouldShow(extension)) | 341 if (!ShouldShow(extension)) |
342 return; | 342 return; |
343 | 343 |
344 std::unique_ptr<base::DictionaryValue> app_info(GetAppInfo(extension)); | 344 std::unique_ptr<base::DictionaryValue> app_info(GetAppInfo(extension)); |
345 if (!app_info.get()) | 345 if (!app_info.get()) |
346 return; | 346 return; |
347 | 347 |
348 visible_apps_.insert(extension->id()); | 348 visible_apps_.insert(extension->id()); |
349 ExtensionPrefs* prefs = ExtensionPrefs::Get(extension_service_->profile()); | 349 ExtensionPrefs* prefs = ExtensionPrefs::Get(extension_service_->profile()); |
350 base::FundamentalValue highlight(prefs->IsFromBookmark(extension->id()) && | 350 base::Value highlight(prefs->IsFromBookmark(extension->id()) && |
351 attempted_bookmark_app_install_); | 351 attempted_bookmark_app_install_); |
352 attempted_bookmark_app_install_ = false; | 352 attempted_bookmark_app_install_ = false; |
353 web_ui()->CallJavascriptFunctionUnsafe("ntp.appAdded", *app_info, highlight); | 353 web_ui()->CallJavascriptFunctionUnsafe("ntp.appAdded", *app_info, highlight); |
354 } | 354 } |
355 | 355 |
356 void AppLauncherHandler::OnExtensionUnloaded( | 356 void AppLauncherHandler::OnExtensionUnloaded( |
357 content::BrowserContext* browser_context, | 357 content::BrowserContext* browser_context, |
358 const Extension* extension, | 358 const Extension* extension, |
359 extensions::UnloadedExtensionInfo::Reason reason) { | 359 extensions::UnloadedExtensionInfo::Reason reason) { |
360 AppRemoved(extension, false); | 360 AppRemoved(extension, false); |
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
794 base::DictionaryValue dictionary; | 794 base::DictionaryValue dictionary; |
795 FillAppDictionary(&dictionary); | 795 FillAppDictionary(&dictionary); |
796 web_ui()->CallJavascriptFunctionUnsafe("ntp.appsPrefChangeCallback", | 796 web_ui()->CallJavascriptFunctionUnsafe("ntp.appsPrefChangeCallback", |
797 dictionary); | 797 dictionary); |
798 } | 798 } |
799 | 799 |
800 void AppLauncherHandler::OnLocalStatePreferenceChanged() { | 800 void AppLauncherHandler::OnLocalStatePreferenceChanged() { |
801 #if BUILDFLAG(ENABLE_APP_LIST) | 801 #if BUILDFLAG(ENABLE_APP_LIST) |
802 web_ui()->CallJavascriptFunctionUnsafe( | 802 web_ui()->CallJavascriptFunctionUnsafe( |
803 "ntp.appLauncherPromoPrefChangeCallback", | 803 "ntp.appLauncherPromoPrefChangeCallback", |
804 base::FundamentalValue(g_browser_process->local_state()->GetBoolean( | 804 base::Value(g_browser_process->local_state()->GetBoolean( |
805 prefs::kShowAppLauncherPromo))); | 805 prefs::kShowAppLauncherPromo))); |
806 #endif | 806 #endif |
807 } | 807 } |
808 | 808 |
809 void AppLauncherHandler::CleanupAfterUninstall() { | 809 void AppLauncherHandler::CleanupAfterUninstall() { |
810 extension_id_prompting_.clear(); | 810 extension_id_prompting_.clear(); |
811 } | 811 } |
812 | 812 |
813 void AppLauncherHandler::PromptToEnableApp(const std::string& extension_id) { | 813 void AppLauncherHandler::PromptToEnableApp(const std::string& extension_id) { |
814 if (!extension_id_prompting_.empty()) | 814 if (!extension_id_prompting_.empty()) |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
873 void AppLauncherHandler::AppRemoved(const Extension* extension, | 873 void AppLauncherHandler::AppRemoved(const Extension* extension, |
874 bool is_uninstall) { | 874 bool is_uninstall) { |
875 if (!ShouldShow(extension)) | 875 if (!ShouldShow(extension)) |
876 return; | 876 return; |
877 | 877 |
878 std::unique_ptr<base::DictionaryValue> app_info(GetAppInfo(extension)); | 878 std::unique_ptr<base::DictionaryValue> app_info(GetAppInfo(extension)); |
879 if (!app_info.get()) | 879 if (!app_info.get()) |
880 return; | 880 return; |
881 | 881 |
882 web_ui()->CallJavascriptFunctionUnsafe( | 882 web_ui()->CallJavascriptFunctionUnsafe( |
883 "ntp.appRemoved", *app_info, base::FundamentalValue(is_uninstall), | 883 "ntp.appRemoved", *app_info, base::Value(is_uninstall), |
884 base::FundamentalValue(!extension_id_prompting_.empty())); | 884 base::Value(!extension_id_prompting_.empty())); |
885 } | 885 } |
886 | 886 |
887 bool AppLauncherHandler::ShouldShow(const Extension* extension) const { | 887 bool AppLauncherHandler::ShouldShow(const Extension* extension) const { |
888 if (ignore_changes_ || !has_loaded_apps_ || !extension->is_app()) | 888 if (ignore_changes_ || !has_loaded_apps_ || !extension->is_app()) |
889 return false; | 889 return false; |
890 | 890 |
891 Profile* profile = Profile::FromWebUI(web_ui()); | 891 Profile* profile = Profile::FromWebUI(web_ui()); |
892 return extensions::ui_util::ShouldDisplayInNewTabPage(extension, profile); | 892 return extensions::ui_util::ShouldDisplayInNewTabPage(extension, profile); |
893 } | 893 } |
OLD | NEW |