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 <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
12 #include "base/i18n/rtl.h" | 12 #include "base/i18n/rtl.h" |
13 #include "base/metrics/field_trial.h" | 13 #include "base/metrics/field_trial.h" |
14 #include "base/metrics/histogram.h" | 14 #include "base/metrics/histogram.h" |
15 #include "base/utf_string_conversions.h" | 15 #include "base/utf_string_conversions.h" |
16 #include "base/values.h" | 16 #include "base/values.h" |
17 #include "chrome/browser/extensions/app_launcher.h" | |
17 #include "chrome/browser/extensions/app_notification.h" | 18 #include "chrome/browser/extensions/app_notification.h" |
18 #include "chrome/browser/extensions/app_notification_manager.h" | 19 #include "chrome/browser/extensions/app_notification_manager.h" |
19 #include "chrome/browser/extensions/crx_installer.h" | 20 #include "chrome/browser/extensions/crx_installer.h" |
20 #include "chrome/browser/extensions/extension_prefs.h" | 21 #include "chrome/browser/extensions/extension_prefs.h" |
21 #include "chrome/browser/extensions/extension_service.h" | 22 #include "chrome/browser/extensions/extension_service.h" |
22 #include "chrome/browser/extensions/extension_sorting.h" | 23 #include "chrome/browser/extensions/extension_sorting.h" |
23 #include "chrome/browser/extensions/extension_system.h" | 24 #include "chrome/browser/extensions/extension_system.h" |
24 #include "chrome/browser/extensions/management_policy.h" | 25 #include "chrome/browser/extensions/management_policy.h" |
25 #include "chrome/browser/favicon/favicon_service_factory.h" | 26 #include "chrome/browser/favicon/favicon_service_factory.h" |
26 #include "chrome/browser/prefs/pref_service.h" | 27 #include "chrome/browser/prefs/pref_service.h" |
(...skipping 29 matching lines...) Expand all Loading... | |
56 using application_launch::LaunchParams; | 57 using application_launch::LaunchParams; |
57 using application_launch::OpenApplication; | 58 using application_launch::OpenApplication; |
58 using content::WebContents; | 59 using content::WebContents; |
59 using extensions::CrxInstaller; | 60 using extensions::CrxInstaller; |
60 using extensions::Extension; | 61 using extensions::Extension; |
61 using extensions::ExtensionPrefs; | 62 using extensions::ExtensionPrefs; |
62 | 63 |
63 const net::UnescapeRule::Type kUnescapeRules = | 64 const net::UnescapeRule::Type kUnescapeRules = |
64 net::UnescapeRule::NORMAL | net::UnescapeRule::URL_SPECIAL_CHARS; | 65 net::UnescapeRule::NORMAL | net::UnescapeRule::URL_SPECIAL_CHARS; |
65 | 66 |
67 AppsPagePresenceHandler::AppsPagePresenceHandler() {} | |
68 | |
69 AppsPagePresenceHandler::~AppsPagePresenceHandler() {} | |
70 | |
71 void AppsPagePresenceHandler::RegisterMessages() { | |
72 web_ui()->RegisterMessageCallback("getShouldShowApps", | |
73 base::Bind(&AppsPagePresenceHandler::HandleGetShouldShowApps, | |
74 base::Unretained(this))); | |
75 } | |
76 | |
77 void AppsPagePresenceHandler::HandleGetShouldShowApps(const ListValue* args) { | |
78 extensions::GetIsAppLauncherEnabled( | |
79 base::Bind(&AppsPagePresenceHandler::GotIsAppLauncherEnabled, | |
80 base::Unretained(this))); | |
81 } | |
82 | |
83 void AppsPagePresenceHandler::GotIsAppLauncherEnabled(bool is_enabled) { | |
84 PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs(); | |
85 prefs->SetBoolean(prefs::kNtpShouldShowAppsPage, !is_enabled); | |
86 base::FundamentalValue should_show_apps(!is_enabled); | |
87 web_ui()->CallJavascriptFunction("ntp.gotShouldShowApps", should_show_apps); | |
88 } | |
89 | |
66 AppLauncherHandler::AppInstallInfo::AppInstallInfo() {} | 90 AppLauncherHandler::AppInstallInfo::AppInstallInfo() {} |
67 | 91 |
68 AppLauncherHandler::AppInstallInfo::~AppInstallInfo() {} | 92 AppLauncherHandler::AppInstallInfo::~AppInstallInfo() {} |
69 | 93 |
70 AppLauncherHandler::AppLauncherHandler(ExtensionService* extension_service) | 94 AppLauncherHandler::AppLauncherHandler(ExtensionService* extension_service) |
71 : extension_service_(extension_service), | 95 : extension_service_(extension_service), |
72 ignore_changes_(false), | 96 ignore_changes_(false), |
73 attempted_bookmark_app_install_(false), | 97 attempted_bookmark_app_install_(false), |
74 has_loaded_apps_(false) { | 98 has_loaded_apps_(false) { |
75 } | 99 } |
(...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
772 void AppLauncherHandler::OnPreferenceChanged() { | 796 void AppLauncherHandler::OnPreferenceChanged() { |
773 DictionaryValue dictionary; | 797 DictionaryValue dictionary; |
774 FillAppDictionary(&dictionary); | 798 FillAppDictionary(&dictionary); |
775 web_ui()->CallJavascriptFunction("ntp.appsPrefChangeCallback", dictionary); | 799 web_ui()->CallJavascriptFunction("ntp.appsPrefChangeCallback", dictionary); |
776 } | 800 } |
777 | 801 |
778 // static | 802 // static |
779 void AppLauncherHandler::RegisterUserPrefs(PrefServiceSyncable* pref_service) { | 803 void AppLauncherHandler::RegisterUserPrefs(PrefServiceSyncable* pref_service) { |
780 pref_service->RegisterListPref(prefs::kNtpAppPageNames, | 804 pref_service->RegisterListPref(prefs::kNtpAppPageNames, |
781 PrefServiceSyncable::SYNCABLE_PREF); | 805 PrefServiceSyncable::SYNCABLE_PREF); |
806 pref_service->RegisterBooleanPref(prefs::kNtpShouldShowAppsPage, | |
807 true, | |
Evan Stade
2013/01/23 23:34:24
shouldn't this default to NewTabUI::ShouldShowApps
jeremya
2013/01/24 02:40:04
It should probably default to the result of just t
| |
808 PrefServiceSyncable::UNSYNCABLE_PREF); | |
782 } | 809 } |
783 | 810 |
784 void AppLauncherHandler::CleanupAfterUninstall() { | 811 void AppLauncherHandler::CleanupAfterUninstall() { |
785 extension_id_prompting_.clear(); | 812 extension_id_prompting_.clear(); |
786 } | 813 } |
787 | 814 |
788 // static | 815 // static |
789 void AppLauncherHandler::RecordAppLaunchType( | 816 void AppLauncherHandler::RecordAppLaunchType( |
790 extension_misc::AppLaunchBucket bucket) { | 817 extension_misc::AppLaunchBucket bucket) { |
791 UMA_HISTOGRAM_ENUMERATION(extension_misc::kAppLaunchHistogram, bucket, | 818 UMA_HISTOGRAM_ENUMERATION(extension_misc::kAppLaunchHistogram, bucket, |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
883 | 910 |
884 ExtensionUninstallDialog* AppLauncherHandler::GetExtensionUninstallDialog() { | 911 ExtensionUninstallDialog* AppLauncherHandler::GetExtensionUninstallDialog() { |
885 if (!extension_uninstall_dialog_.get()) { | 912 if (!extension_uninstall_dialog_.get()) { |
886 Browser* browser = chrome::FindBrowserWithWebContents( | 913 Browser* browser = chrome::FindBrowserWithWebContents( |
887 web_ui()->GetWebContents()); | 914 web_ui()->GetWebContents()); |
888 extension_uninstall_dialog_.reset( | 915 extension_uninstall_dialog_.reset( |
889 ExtensionUninstallDialog::Create(browser, this)); | 916 ExtensionUninstallDialog::Create(browser, this)); |
890 } | 917 } |
891 return extension_uninstall_dialog_.get(); | 918 return extension_uninstall_dialog_.get(); |
892 } | 919 } |
OLD | NEW |