| Index: chrome/browser/dom_ui/app_launcher_handler.cc
|
| diff --git a/chrome/browser/dom_ui/app_launcher_handler.cc b/chrome/browser/dom_ui/app_launcher_handler.cc
|
| index e57dfdcf19e28438ad92cc4532fd69f4bc6bc4e3..74bea4b195d78c86d6a7d5820a970d88d843cd8a 100644
|
| --- a/chrome/browser/dom_ui/app_launcher_handler.cc
|
| +++ b/chrome/browser/dom_ui/app_launcher_handler.cc
|
| @@ -20,6 +20,7 @@
|
| #include "chrome/browser/tab_contents/tab_contents.h"
|
| #include "chrome/browser/ui/browser.h"
|
| #include "chrome/browser/ui/browser_list.h"
|
| +#include "chrome/browser/ui/browser_window.h"
|
| #include "chrome/common/chrome_switches.h"
|
| #include "chrome/common/extensions/extension.h"
|
| #include "chrome/common/extensions/extension_constants.h"
|
| @@ -97,7 +98,8 @@ void AppLauncherHandler::CreateAppInfo(const Extension* extension,
|
| std::string("chrome://favicon/") + extension->GetFullLaunchURL().spec()));
|
| value->SetInteger("launch_container", extension->launch_container());
|
| value->SetInteger("launch_type",
|
| - extension_prefs->GetLaunchType(extension->id()));
|
| + extension_prefs->GetLaunchType(extension->id(),
|
| + ExtensionPrefs::LAUNCH_REGULAR));
|
|
|
| int app_launch_index = extension_prefs->GetAppLaunchIndex(extension->id());
|
| if (app_launch_index == -1) {
|
| @@ -137,6 +139,8 @@ void AppLauncherHandler::RegisterMessages() {
|
| NewCallback(this, &AppLauncherHandler::HandleUninstallApp));
|
| dom_ui_->RegisterMessageCallback("hideAppsPromo",
|
| NewCallback(this, &AppLauncherHandler::HandleHideAppsPromo));
|
| + dom_ui_->RegisterMessageCallback("createAppShortcut",
|
| + NewCallback(this, &AppLauncherHandler::HandleCreateAppShortcut));
|
| }
|
|
|
| void AppLauncherHandler::Observe(NotificationType type,
|
| @@ -193,11 +197,9 @@ void AppLauncherHandler::FillAppDictionary(DictionaryValue* dictionary) {
|
|
|
| #if defined(OS_MACOSX)
|
| // App windows are not yet implemented on mac.
|
| - bool disable_app_window_launch = true;
|
| -#else
|
| - bool disable_app_window_launch = false;
|
| + dictionary->SetBoolean("disableAppWindowLaunch", true);
|
| + dictionary->SetBoolean("disableCreateAppShortcut", true);
|
| #endif
|
| - dictionary->SetBoolean("disableAppWindowLaunch", disable_app_window_launch);
|
| }
|
|
|
| void AppLauncherHandler::HandleGetApps(const ListValue* args) {
|
| @@ -257,14 +259,11 @@ void AppLauncherHandler::HandleLaunchApp(const ListValue* args) {
|
|
|
| AnimateAppIcon(extension, rect);
|
|
|
| + // Look at preference to find the right launch container. If no preference
|
| + // is set, launch as a regular tab.
|
| extension_misc::LaunchContainer launch_container =
|
| - extension->launch_container();
|
| - ExtensionPrefs::LaunchType prefs_launch_type =
|
| - extensions_service_->extension_prefs()->GetLaunchType(extension_id);
|
| -
|
| - // If the user chose to open in a window, change the container type.
|
| - if (prefs_launch_type == ExtensionPrefs::LAUNCH_WINDOW)
|
| - launch_container = extension_misc::LAUNCH_WINDOW;
|
| + extensions_service_->extension_prefs()->GetLaunchContainer(
|
| + extension, ExtensionPrefs::LAUNCH_REGULAR);
|
|
|
| TabContents* new_contents = Browser::OpenApplication(
|
| profile, extension, launch_container, old_contents);
|
| @@ -328,6 +327,24 @@ void AppLauncherHandler::HandleHideAppsPromo(const ListValue* args) {
|
| extensions_service_->default_apps()->SetPromoHidden();
|
| }
|
|
|
| +void AppLauncherHandler::HandleCreateAppShortcut(const ListValue* args) {
|
| + std::string extension_id;
|
| + if (!args->GetString(0, &extension_id)) {
|
| + NOTREACHED();
|
| + return;
|
| + }
|
| +
|
| + const Extension* extension =
|
| + extensions_service_->GetExtensionById(extension_id, false);
|
| + CHECK(extension);
|
| +
|
| + Browser* browser = BrowserList::GetLastActive();
|
| + if (!browser)
|
| + return;
|
| + browser->window()->ShowCreateChromeAppShortcutsDialog(
|
| + browser->profile(), extension);
|
| +}
|
| +
|
| // static
|
| void AppLauncherHandler::RecordWebStoreLaunch(bool promo_active) {
|
| if (!promo_active) return;
|
|
|