summaryrefslogtreecommitdiffstats
path: root/chrome/browser/dom_ui
diff options
context:
space:
mode:
authorarv@chromium.org <arv@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-21 18:57:23 +0000
committerarv@chromium.org <arv@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-21 18:57:23 +0000
commit3c92499fe304b9b65d647e3d78303aab3cd931c9 (patch)
tree5d277bf1419334a3798b26f3d5e5a4bdefbcc6eb /chrome/browser/dom_ui
parentb5fe86e4e754ea16b709cfb65dc497fe03a7f077 (diff)
downloadchromium_src-3c92499fe304b9b65d647e3d78303aab3cd931c9.zip
chromium_src-3c92499fe304b9b65d647e3d78303aab3cd931c9.tar.gz
chromium_src-3c92499fe304b9b65d647e3d78303aab3cd931c9.tar.bz2
NTP: Add ability to uninstall apps from the ntp.
BUG=44915 TEST=Start chrome with --enable-apps (and optionally --enable-accelerated-compositing). Install some apps. Now hover over the app icon and click the wrench icon. Review URL: http://codereview.chromium.org/2832014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@50368 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/dom_ui')
-rw-r--r--chrome/browser/dom_ui/app_launcher_handler.cc34
-rw-r--r--chrome/browser/dom_ui/app_launcher_handler.h7
-rw-r--r--chrome/browser/dom_ui/ntp_resource_cache.cc11
3 files changed, 40 insertions, 12 deletions
diff --git a/chrome/browser/dom_ui/app_launcher_handler.cc b/chrome/browser/dom_ui/app_launcher_handler.cc
index 31384cb..9dbdafb 100644
--- a/chrome/browser/dom_ui/app_launcher_handler.cc
+++ b/chrome/browser/dom_ui/app_launcher_handler.cc
@@ -55,6 +55,8 @@ void AppLauncherHandler::RegisterMessages() {
NewCallback(this, &AppLauncherHandler::HandleGetApps));
dom_ui_->RegisterMessageCallback("launchApp",
NewCallback(this, &AppLauncherHandler::HandleLaunchApp));
+ dom_ui_->RegisterMessageCallback("uninstallApp",
+ NewCallback(this, &AppLauncherHandler::HandleUninstallApp));
}
void AppLauncherHandler::Observe(NotificationType type,
@@ -80,6 +82,7 @@ void AppLauncherHandler::CreateAppInfo(Extension* extension,
value->SetString(L"name", extension->name());
value->SetString(L"description", extension->description());
value->SetString(L"launch_url", extension->GetFullLaunchURL().spec());
+ value->SetString(L"options_url", extension->options_url().spec());
FilePath relative_path =
extension->GetIconPath(Extension::EXTENSION_ICON_LARGE).relative_path();
@@ -95,20 +98,10 @@ void AppLauncherHandler::CreateAppInfo(Extension* extension,
}
void AppLauncherHandler::HandleGetApps(const Value* value) {
- std::string gallery_title;
- std::string gallery_url;
-
- // TODO(aa): Decide the final values for these and remove the switches.
- gallery_title = CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
- switches::kAppsGalleryTitle);
- gallery_url = CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
- switches::kAppsGalleryURL);
bool show_debug_link = CommandLine::ForCurrentProcess()->HasSwitch(
switches::kAppsDebug);
DictionaryValue dictionary;
- dictionary.SetString(L"galleryTitle", gallery_title);
- dictionary.SetString(L"galleryURL", gallery_url);
dictionary.SetBoolean(L"showDebugLink", show_debug_link);
ListValue* list = new ListValue();
@@ -217,3 +210,24 @@ void AppLauncherHandler::AnimateAppIcon(Extension* extension,
#endif
}
}
+
+void AppLauncherHandler::HandleUninstallApp(const Value* value) {
+ if (!value->IsType(Value::TYPE_LIST)) {
+ NOTREACHED();
+ return;
+ }
+
+ std::string extension_id;
+ const ListValue* list = static_cast<const ListValue*>(value);
+ if (!list->GetString(0, &extension_id)) {
+ NOTREACHED();
+ return;
+ }
+
+ // Make sure that the extension exists.
+ Extension* extension =
+ extensions_service_->GetExtensionById(extension_id, false);
+ DCHECK(extension);
+
+ extensions_service_->UninstallExtension(extension_id, false);
+}
diff --git a/chrome/browser/dom_ui/app_launcher_handler.h b/chrome/browser/dom_ui/app_launcher_handler.h
index f169580..b20923c 100644
--- a/chrome/browser/dom_ui/app_launcher_handler.h
+++ b/chrome/browser/dom_ui/app_launcher_handler.h
@@ -35,12 +35,15 @@ class AppLauncherHandler
// Populate a dictionary with the information from an extension.
static void CreateAppInfo(Extension* extension, DictionaryValue* value);
- // Callback for the "getAll" message.
+ // Callback for the "getApps" message.
void HandleGetApps(const Value* value);
- // Callback for the "launch" message.
+ // Callback for the "launchApp" message.
void HandleLaunchApp(const Value* value);
+ // Callback for the "uninstallApp" message.
+ void HandleUninstallApp(const Value* value);
+
private:
// Starts the animation of the app icon.
void AnimateAppIcon(Extension* extension, const gfx::Rect& rect);
diff --git a/chrome/browser/dom_ui/ntp_resource_cache.cc b/chrome/browser/dom_ui/ntp_resource_cache.cc
index 829a431..9ad62b7 100644
--- a/chrome/browser/dom_ui/ntp_resource_cache.cc
+++ b/chrome/browser/dom_ui/ntp_resource_cache.cc
@@ -286,6 +286,12 @@ void NTPResourceCache::CreateNewTabHTML() {
localized_strings.SetString(L"tips",
l10n_util::GetString(IDS_NEW_TAB_TIPS));
localized_strings.SetString(L"close", l10n_util::GetString(IDS_CLOSE));
+ localized_strings.SetString(L"appsettings",
+ l10n_util::GetString(IDS_NEW_TAB_APP_SETTINGS));
+ localized_strings.SetString(L"appuninstall",
+ l10n_util::GetString(IDS_NEW_TAB_APP_UNINSTALL));
+ localized_strings.SetString(L"appoptions",
+ l10n_util::GetString(IDS_NEW_TAB_APP_OPTIONS));
// Don't initiate the sync related message passing with the page if the sync
// code is not present.
@@ -301,6 +307,11 @@ void NTPResourceCache::CreateNewTabHTML() {
Animation::ShouldRenderRichAnimation() ? "true" : "false";
localized_strings.SetString(L"anim", anim);
+ const CommandLine* command_line = CommandLine::ForCurrentProcess();
+ bool has_3d =
+ command_line->HasSwitch(switches::kEnableAcceleratedCompositing);
+ localized_strings.SetString(L"has_3d", has_3d ? "true" : "false");
+
// Pass the shown_sections pref early so that we can prevent flicker.
ShownSectionsHandler::SetFirstAppLauncherRunPref(profile_->GetPrefs());
const int shown_sections = profile_->GetPrefs()->GetInteger(