summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authoraa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-15 08:47:48 +0000
committeraa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-15 08:47:48 +0000
commit92bcd16fb15f54a0ea510597bebdad7d4d4297dc (patch)
tree51b8063da05a5d674e993eed0a83aafea6419b7d /chrome
parentf36ed64560f4b52724d223bc870addc5a5e3b73c (diff)
downloadchromium_src-92bcd16fb15f54a0ea510597bebdad7d4d4297dc.zip
chromium_src-92bcd16fb15f54a0ea510597bebdad7d4d4297dc.tar.gz
chromium_src-92bcd16fb15f54a0ea510597bebdad7d4d4297dc.tar.bz2
Reland 36337: Add launch configuration to apps. Create a desktop shortcut if launch configuration is present. Future
changes will add UI asking if the user wants to create a shortcut first, and change the presentation when the shortcut is launched. TBR=erikkay@chromium.org git-svn-id: svn://svn.chromium.org/chrome/trunk/src@36340 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/extensions/crx_installer.cc25
-rw-r--r--chrome/browser/utility_process_host.cc3
-rw-r--r--chrome/common/extensions/extension.cc18
-rw-r--r--chrome/common/extensions/extension.h8
-rw-r--r--chrome/common/extensions/extension_constants.cc5
-rw-r--r--chrome/common/extensions/extension_constants.h2
6 files changed, 55 insertions, 6 deletions
diff --git a/chrome/browser/extensions/crx_installer.cc b/chrome/browser/extensions/crx_installer.cc
index ca01297..defeff4 100644
--- a/chrome/browser/extensions/crx_installer.cc
+++ b/chrome/browser/extensions/crx_installer.cc
@@ -5,6 +5,7 @@
#include "chrome/browser/extensions/crx_installer.h"
#include "app/l10n_util.h"
+#include "app/resource_bundle.h"
#include "base/file_util.h"
#include "base/scoped_temp_dir.h"
#include "base/string_util.h"
@@ -13,9 +14,12 @@
#include "chrome/browser/chrome_thread.h"
#include "chrome/browser/extensions/convert_user_script.h"
#include "chrome/browser/extensions/extension_file_util.h"
+#include "chrome/browser/shell_integration.h"
+#include "chrome/browser/web_applications/web_app.h"
#include "chrome/common/extensions/extension_error_reporter.h"
#include "chrome/common/notification_service.h"
#include "chrome/common/notification_type.h"
+#include "grit/browser_resources.h"
#include "grit/chromium_strings.h"
#include "third_party/skia/include/core/SkBitmap.h"
@@ -153,10 +157,11 @@ void CrxInstaller::OnUnpackSuccess(const FilePath& temp_dir,
return;
}
- if (client_.get()) {
+ if (client_.get() || extension_->IsApp()) {
Extension::DecodeIcon(extension_.get(), Extension::EXTENSION_ICON_LARGE,
&install_icon_);
}
+
ChromeThread::PostTask(
ChromeThread::UI, FROM_HERE,
NewRunnableMethod(this, &CrxInstaller::ConfirmInstall));
@@ -232,6 +237,24 @@ void CrxInstaller::CompleteInstall() {
return;
}
+ if (extension_->IsApp()) {
+ SkBitmap icon = install_icon_.get() ? *install_icon_ :
+ *ResourceBundle::GetSharedInstance().GetBitmapNamed(
+ IDR_EXTENSION_DEFAULT_ICON);
+
+ ShellIntegration::ShortcutInfo shortcut_info;
+ shortcut_info.url = extension_->app_launch_url();
+ shortcut_info.title = UTF8ToUTF16(extension_->name());
+ shortcut_info.description = UTF8ToUTF16(extension_->description());
+ shortcut_info.favicon = icon;
+ shortcut_info.create_on_desktop = true;
+
+ // TODO(aa): Seems nasty to be reusing the old webapps code this way. What
+ // baggage am I inheriting?
+ web_app::CreateShortcut(frontend_->profile()->GetPath(), shortcut_info,
+ NULL);
+ }
+
// This is lame, but we must reload the extension because absolute paths
// inside the content scripts are established inside InitFromValue() and we
// just moved the extension.
diff --git a/chrome/browser/utility_process_host.cc b/chrome/browser/utility_process_host.cc
index ccef437..29ed98f 100644
--- a/chrome/browser/utility_process_host.cc
+++ b/chrome/browser/utility_process_host.cc
@@ -83,6 +83,9 @@ bool UtilityProcessHost::StartProcess(const FilePath& exposed_dir) {
if (browser_command_line.HasSwitch(switches::kChromeFrame))
cmd_line->AppendSwitch(switches::kChromeFrame);
+ if (browser_command_line.HasSwitch(switches::kEnableExtensionApps))
+ cmd_line->AppendSwitch(switches::kEnableExtensionApps);
+
#if defined(OS_POSIX)
// TODO(port): Sandbox this on Linux. Also, zygote this to work with
// Linux updating.
diff --git a/chrome/common/extensions/extension.cc b/chrome/common/extensions/extension.cc
index 2a0f139..9f86ac8 100644
--- a/chrome/common/extensions/extension.cc
+++ b/chrome/common/extensions/extension.cc
@@ -506,10 +506,24 @@ bool Extension::LoadAppHelper(const DictionaryValue* app, std::string* error) {
return false;
}
+ // launch URL
+ std::string launch_url_spec;
+ if (!app->GetString(keys::kAppLaunchUrl, &launch_url_spec)) {
+ *error = errors::kInvalidAppLaunchUrl;
+ return false;
+ }
+ app_launch_url_ = GURL(launch_url_spec);
+ if (!app_launch_url_.is_valid()) {
+ *error = errors::kInvalidAppLaunchUrl;
+ return false;
+ }
+ // The launch URL is automatically an allowed origin.
+ app_origins_.push_back(app_launch_url_.GetOrigin());
+
+ // origins
ListValue* origins;
if (!app->GetList(keys::kAppOrigins, &origins) || origins->GetSize() == 0) {
- *error =
- ExtensionErrorUtils::FormatErrorMessage(errors::kInvalidAppOrigin, "");
+ *error = errors::kInvalidAppOrigin;
return false;
}
for (ListValue::const_iterator iter = origins->begin();
diff --git a/chrome/common/extensions/extension.h b/chrome/common/extensions/extension.h
index 5ed2f7f..03eaee3 100644
--- a/chrome/common/extensions/extension.h
+++ b/chrome/common/extensions/extension.h
@@ -286,9 +286,10 @@ class Extension {
bool GetBackgroundPageReady();
void SetBackgroundPageReady();
- // The origins that this app is registered to.
+ // App stuff.
const std::vector<GURL>& app_origins() const { return app_origins_; }
- bool IsApp() const { return !app_origins_.empty(); }
+ const GURL& app_launch_url() const { return app_launch_url_; }
+ bool IsApp() const { return !app_launch_url_.is_empty(); }
private:
// Helper method that loads a UserScript object from a
@@ -422,6 +423,9 @@ class Extension {
// The vector of origin URLs associated with an app.
std::vector<GURL> app_origins_;
+ // The URL an app should launch to.
+ GURL app_launch_url_;
+
// Runtime data:
diff --git a/chrome/common/extensions/extension_constants.cc b/chrome/common/extensions/extension_constants.cc
index f756e13..817b54f 100644
--- a/chrome/common/extensions/extension_constants.cc
+++ b/chrome/common/extensions/extension_constants.cc
@@ -9,6 +9,7 @@ namespace extension_manifest_keys {
const wchar_t* kAllFrames = L"all_frames";
const wchar_t* kApp = L"app";
const wchar_t* kAppOrigins = L"origins";
+const wchar_t* kAppLaunchUrl = L"launch.url";
const wchar_t* kBackground = L"background_page";
const wchar_t* kBrowserAction = L"browser_action";
const wchar_t* kChromeURLOverrides = L"chrome_url_overrides";
@@ -75,7 +76,9 @@ const char* kChromeVersionTooLow =
const char* kInvalidAllFrames =
"Invalid value for 'content_scripts[*].all_frames'.";
const char* kInvalidApp = "Invalid app.";
-const char* kInvalidAppOrigin = "Invalid app origin[*]";
+const char* kInvalidAppOrigin = "Invalid app origin[*].";
+const char* kInvalidAppLaunchUrl =
+ "Required value 'app.launch.url' is missing or invalid.";
const char* kInvalidBrowserAction =
"Invalid value for 'browser_action'.";
const char* kInvalidChromeURLOverrides =
diff --git a/chrome/common/extensions/extension_constants.h b/chrome/common/extensions/extension_constants.h
index b7d945e..430070e 100644
--- a/chrome/common/extensions/extension_constants.h
+++ b/chrome/common/extensions/extension_constants.h
@@ -10,6 +10,7 @@ namespace extension_manifest_keys {
extern const wchar_t* kAllFrames;
extern const wchar_t* kApp;
extern const wchar_t* kAppOrigins;
+ extern const wchar_t* kAppLaunchUrl;
extern const wchar_t* kBackground;
extern const wchar_t* kBrowserAction;
extern const wchar_t* kMinimumChromeVersion;
@@ -73,6 +74,7 @@ namespace extension_manifest_errors {
extern const char* kInvalidAllFrames;
extern const char* kInvalidApp;
extern const char* kInvalidAppOrigin;
+ extern const char* kInvalidAppLaunchUrl;
extern const char* kInvalidBackground;
extern const char* kInvalidBrowserAction;
extern const char* kInvalidChromeURLOverrides;