summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorxiyuan@chromium.org <xiyuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-25 18:44:19 +0000
committerxiyuan@chromium.org <xiyuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-25 18:44:19 +0000
commitbcc6518c163965f95d676c6dcb4f4dd256b89463 (patch)
tree3a30903536efddcd2e48ef5902f2329efe76d36c /chrome
parent9d6052a1a433df123732b517b6c683cf787c7181 (diff)
downloadchromium_src-bcc6518c163965f95d676c6dcb4f4dd256b89463.zip
chromium_src-bcc6518c163965f95d676c6dcb4f4dd256b89463.tar.gz
chromium_src-bcc6518c163965f95d676c6dcb4f4dd256b89463.tar.bz2
chromeos: Make Chrome app a real app.
- Add a chrome_app component extension similar to web store; - Remove ChromeAppItem and use the real app; - Minor clean up; - use_aura -> use_ash in browser_resources.grd; - Fix style nits; BUG=133015 TEST=Verify that "chrome" app is searchable. Review URL: https://chromiumcodereview.appspot.com/10652003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@143966 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/browser_resources.grd7
-rw-r--r--chrome/browser/extensions/component_loader.cc31
-rw-r--r--chrome/browser/extensions/component_loader.h4
-rw-r--r--chrome/browser/extensions/image_loading_tracker.cc13
-rw-r--r--chrome/browser/resources/chrome_app/manifest.json12
-rw-r--r--chrome/browser/ui/views/ash/app_list/apps_model_builder.cc32
-rw-r--r--chrome/browser/ui/views/ash/app_list/extension_app_item.cc4
-rw-r--r--chrome/browser/ui/views/ash/app_list/search_builder.cc17
-rw-r--r--chrome/common/extensions/extension.cc36
-rw-r--r--chrome/common/extensions/extension_constants.cc1
-rw-r--r--chrome/common/extensions/extension_constants.h3
11 files changed, 103 insertions, 57 deletions
diff --git a/chrome/browser/browser_resources.grd b/chrome/browser/browser_resources.grd
index e26548a..d60979d 100644
--- a/chrome/browser/browser_resources.grd
+++ b/chrome/browser/browser_resources.grd
@@ -153,7 +153,7 @@
<include name="IDR_UBER_UTILS_JS" file="resources\uber\uber_utils.js" type="BINDATA" />
<include name="IDR_WEBSTORE_MANIFEST" file="resources\webstore_app\manifest.json" type="BINDATA" />
<include name="IDR_ENTERPRISE_WEBSTORE_MANIFEST" file="resources\enterprise_webstore_app\manifest.json" type="BINDATA" />
- <if expr="pp_ifdef('use_aura')">
+ <if expr="pp_ifdef('use_ash')">
<include name="IDR_TASK_MANAGER_HTML" file="resources\task_manager\main.html" flattenhtml="true" allowexternalscript="true" type="BINDATA" />
<include name="IDR_TASK_MANAGER_COMMANDS_JS" file="resources\task_manager\commands.js" type="BINDATA" />
<!-- The following defines.js uses flattenhtml feature to remove the platform-dependent code at complie-time. -->
@@ -164,6 +164,7 @@
<include name="IDR_TASK_MANAGER_JS" file="resources\task_manager\main.js" flattenhtml="true" type="BINDATA" />
<include name="IDR_TASK_MANAGER_MEASURE_TIME_JS" file="resources\task_manager\measure_time.js" type="BINDATA" />
<include name="IDR_TASK_MANAGER_MEASURE_TIME_END_JS" file="resources\task_manager\measure_time_end.js" type="BINDATA" />
+ <include name="IDR_CHROME_APP_MANIFEST" file="resources\chrome_app\manifest.json" type="BINDATA" />
</if>
<if expr="not pp_ifdef('chromeos')">
<include name="IDR_SYNC_PROMO_JS" file="resources\sync_promo\sync_promo.js" flattenhtml="true" type="BINDATA" />
@@ -208,14 +209,14 @@
<if expr="pp_ifdef('chromeos')">
<include name="IDR_WALLPAPERMANAGER_MANIFEST" file="resources\chromeos\wallpaper_manager\manifest.json" type="BINDATA" />
</if>
- <if expr="(is_linux and pp_ifdef('toolkit_views')) or pp_ifdef('use_aura')">
+ <if expr="(is_linux and pp_ifdef('toolkit_views')) or pp_ifdef('use_ash')">
<include name="IDR_HTTP_AUTH_HTML" file="resources\http_auth.html" flattenhtml="true" type="BINDATA" />
<include name="IDR_TAB_MODAL_CONFIRM_DIALOG_HTML" file="resources\tab_modal_confirm_dialog.html" flattenhtml="true" type="BINDATA" />
</if>
<if expr="pp_ifdef('chromeos') and pp_ifdef('_google_chrome')">
<include name="IDR_HELP_MANIFEST" file="resources\help_app\manifest.json" type="BINDATA" />
</if>
- <if expr="pp_ifdef('use_aura')">
+ <if expr="pp_ifdef('use_ash')">
<include name="IDR_GESTURE_CONFIG_CSS" file="resources\gesture_config.css" type="BINDATA" />
<include name="IDR_GESTURE_CONFIG_HTML" file="resources\gesture_config.html" type="BINDATA" />
<include name="IDR_GESTURE_CONFIG_JS" file="resources\gesture_config.js" type="BINDATA" />
diff --git a/chrome/browser/extensions/component_loader.cc b/chrome/browser/extensions/component_loader.cc
index 595b001..e49d7a1 100644
--- a/chrome/browser/extensions/component_loader.cc
+++ b/chrome/browser/extensions/component_loader.cc
@@ -35,6 +35,11 @@
#include "chrome/browser/chromeos/login/user_manager.h"
#endif
+#if defined(USE_ASH)
+#include "grit/chromium_strings.h"
+#include "ui/base/l10n/l10n_util.h"
+#endif
+
namespace extensions {
ComponentLoader::ComponentLoader(ExtensionServiceInterface* extension_service,
@@ -96,7 +101,7 @@ const Extension* ComponentLoader::Add(
}
const Extension* ComponentLoader::Add(
- std::string& manifest_contents,
+ const std::string& manifest_contents,
const FilePath& root_directory) {
// The Value is kept for the lifetime of the ComponentLoader. This is
// required in case LoadAll() is called again.
@@ -277,6 +282,26 @@ void ComponentLoader::AddOrReloadEnterpriseWebStore() {
}
}
+void ComponentLoader::AddChromeApp() {
+#if defined(USE_ASH)
+ std::string manifest_contents =
+ ResourceBundle::GetSharedInstance().GetRawDataResource(
+ IDR_CHROME_APP_MANIFEST,
+ ui::SCALE_FACTOR_NONE).as_string();
+
+ // The Value is kept for the lifetime of the ComponentLoader. This is
+ // required in case LoadAll() is called again.
+ DictionaryValue* manifest = ParseManifest(manifest_contents);
+
+ // Update manifest to use a proper name.
+ manifest->SetString(extension_manifest_keys::kName,
+ l10n_util::GetStringUTF8(IDS_SHORT_PRODUCT_NAME));
+
+ if (manifest)
+ Add(manifest, FilePath(FILE_PATH_LITERAL("chrome_app")));
+#endif
+}
+
void ComponentLoader::AddDefaultComponentExtensions() {
#if defined(OS_CHROMEOS)
if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kGuestSession))
@@ -346,6 +371,10 @@ void ComponentLoader::AddDefaultComponentExtensions() {
// it is specified by policy, and on ChromeOS policies are loaded after
// the browser process has started.
AddOrReloadEnterpriseWebStore();
+
+#if defined(USE_ASH)
+ AddChromeApp();
+#endif
}
void ComponentLoader::Observe(
diff --git a/chrome/browser/extensions/component_loader.h b/chrome/browser/extensions/component_loader.h
index 3ad948a..a2a4b02 100644
--- a/chrome/browser/extensions/component_loader.h
+++ b/chrome/browser/extensions/component_loader.h
@@ -40,7 +40,7 @@ class ComponentLoader : public content::NotificationObserver {
// Registers and possibly loads a component extension. If ExtensionService
// has been initialized, the extension is loaded; otherwise, the load is
// deferred until LoadAll is called.
- const Extension* Add(std::string& manifest_contents,
+ const Extension* Add(const std::string& manifest_contents,
const FilePath& root_directory);
// Convenience method for registering a component extension by resource id.
@@ -117,6 +117,8 @@ class ComponentLoader : public content::NotificationObserver {
// Add the enterprise webstore extension, or reload it if already loaded.
void AddOrReloadEnterpriseWebStore();
+ void AddChromeApp();
+
// Determine the extension id.
static std::string GenerateId(const base::DictionaryValue* manifest);
diff --git a/chrome/browser/extensions/image_loading_tracker.cc b/chrome/browser/extensions/image_loading_tracker.cc
index 94379b7..b8c30bb 100644
--- a/chrome/browser/extensions/image_loading_tracker.cc
+++ b/chrome/browser/extensions/image_loading_tracker.cc
@@ -4,6 +4,9 @@
#include "chrome/browser/extensions/image_loading_tracker.h"
+#include <string>
+#include <vector>
+
#include "base/bind.h"
#include "base/file_util.h"
#include "chrome/browser/ui/webui/extensions/extension_icon_source.h"
@@ -215,12 +218,20 @@ void ImageLoadingTracker::LoadImages(const Extension* extension,
for (std::vector<ImageInfo>::const_iterator it = info_list.begin();
it != info_list.end(); ++it) {
- // Load resources for WebStore component extension.
+ // Load resources for special component extensions.
if (load_info.extension_id == extension_misc::kWebStoreAppId) {
if (!loader_)
loader_ = new ImageLoader(this);
loader_->LoadResource(it->resource, it->max_size, id, IDR_WEBSTORE_ICON);
continue;
+ } else if (load_info.extension_id == extension_misc::kChromeAppId) {
+ if (!loader_)
+ loader_ = new ImageLoader(this);
+ loader_->LoadResource(it->resource,
+ it->max_size,
+ id,
+ IDR_PRODUCT_LOGO_128);
+ continue;
}
// If we don't have a path we don't need to do any further work, just
diff --git a/chrome/browser/resources/chrome_app/manifest.json b/chrome/browser/resources/chrome_app/manifest.json
new file mode 100644
index 0000000..f4806e2
--- /dev/null
+++ b/chrome/browser/resources/chrome_app/manifest.json
@@ -0,0 +1,12 @@
+{
+ "key": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDNuYLEQ1QPMcc5HfWI/9jiEf6FdJWqEtgRmIeI7qtjPLBM5oje+Ny2E2mTAhou5qdJiO2CHWdU1DQXY2F7Zu2gZaKZgHLfK4WimHxUT5Xd9/aro/R9PCzjguM1BLusiWYc9xlj1IsZpyiN1hcjU7SCnBhv1feQlv2WSB5KRiXwhQIDAQAB",
+ "name": "Chrome",
+ "version": "0.1",
+ "description": "Chrome as an app",
+ "app": {
+ "launch": {
+ // Note this will be changed by special case to become chrome://newtab.
+ "web_url": "http://THIS-WILL-BE-REPLACED"
+ }
+ }
+}
diff --git a/chrome/browser/ui/views/ash/app_list/apps_model_builder.cc b/chrome/browser/ui/views/ash/app_list/apps_model_builder.cc
index e62d6b25..cf40b6a 100644
--- a/chrome/browser/ui/views/ash/app_list/apps_model_builder.cc
+++ b/chrome/browser/ui/views/ash/app_list/apps_model_builder.cc
@@ -5,53 +5,25 @@
#include "chrome/browser/ui/views/ash/app_list/apps_model_builder.h"
#include "base/i18n/case_conversion.h"
-#include "base/i18n/string_search.h"
-#include "base/string_util.h"
#include "base/utf_string_conversions.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/views/ash/app_list/extension_app_item.h"
-#include "chrome/browser/ui/views/ash/launcher/chrome_launcher_controller.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/extensions/extension.h"
#include "content/public/browser/notification_service.h"
-#include "grit/chromium_strings.h"
-#include "grit/generated_resources.h"
-#include "grit/theme_resources.h"
-#include "ui/base/l10n/l10n_util.h"
#include "ui/base/l10n/l10n_util_collator.h"
-#include "ui/base/resource/resource_bundle.h"
using extensions::Extension;
namespace {
const char* kSpecialApps[] = {
+ extension_misc::kChromeAppId,
extension_misc::kWebStoreAppId,
};
-class ChromeAppItem : public ChromeAppListItem {
- public:
- ChromeAppItem() : ChromeAppListItem(TYPE_OTHER) {
- SetTitle(l10n_util::GetStringUTF8(IDS_SHORT_PRODUCT_NAME));
- ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
- SetIcon(*rb.GetImageNamed(IDR_PRODUCT_LOGO_128).ToSkBitmap());
- }
-
- private:
- // Overridden from ChromeAppListItem:
- virtual void Activate(int event_flags) OVERRIDE {
- ChromeLauncherController* controller = ChromeLauncherController::instance();
- if (event_flags & ui::EF_CONTROL_DOWN)
- controller->CreateNewWindow();
- else
- controller->CreateNewTab();
- }
-
- DISALLOW_COPY_AND_ASSIGN(ChromeAppItem);
-};
-
// ModelItemSortData provides a string key to sort with
// l10n_util::StringComparator.
struct ModelItemSortData {
@@ -171,8 +143,6 @@ void AppsModelBuilder::GetExtensionApps(Apps* apps) {
void AppsModelBuilder::CreateSpecialApps() {
DCHECK(model_ && model_->item_count() == 0);
- model_->Add(new ChromeAppItem());
-
bool is_guest_session = Profile::IsGuestSession();
ExtensionService* service = profile_->GetExtensionService();
DCHECK(service);
diff --git a/chrome/browser/ui/views/ash/app_list/extension_app_item.cc b/chrome/browser/ui/views/ash/app_list/extension_app_item.cc
index c8d8086..942e79d 100644
--- a/chrome/browser/ui/views/ash/app_list/extension_app_item.cc
+++ b/chrome/browser/ui/views/ash/app_list/extension_app_item.cc
@@ -268,6 +268,10 @@ void ExtensionAppItem::Activate(int event_flags) {
}
ui::MenuModel* ExtensionAppItem::GetContextMenuModel() {
+ // No context menu for Chrome app.
+ if (extension_id_ == extension_misc::kChromeAppId)
+ return NULL;
+
if (!context_menu_model_.get()) {
context_menu_model_.reset(new ui::SimpleMenuModel(this));
context_menu_model_->AddItem(LAUNCH, UTF8ToUTF16(title()));
diff --git a/chrome/browser/ui/views/ash/app_list/search_builder.cc b/chrome/browser/ui/views/ash/app_list/search_builder.cc
index dcd1cb7..6b5868a 100644
--- a/chrome/browser/ui/views/ash/app_list/search_builder.cc
+++ b/chrome/browser/ui/views/ash/app_list/search_builder.cc
@@ -74,6 +74,17 @@ void ACMatchClassificationsToTags(
}
}
+const extensions::Extension* GetExtensionByURL(Profile* profile,
+ const GURL& url) {
+ ExtensionService* service = profile->GetExtensionService();
+ // Need to explicitly get chrome app because it does not override new tab and
+ // not having a web extent to include new tab url, thus GetInstalledApp does
+ // not find it.
+ return url.spec() == chrome::kChromeUINewTabURL ?
+ service->extensions()->GetByID(extension_misc::kChromeAppId) :
+ service->GetInstalledApp(url);
+}
+
// SearchBuildResult is an app list SearchResult built from an
// AutocompleteMatch.
class SearchBuilderResult : public app_list::SearchResult,
@@ -94,9 +105,8 @@ class SearchBuilderResult : public app_list::SearchResult,
private:
void UpdateIcon() {
if (match_.type == AutocompleteMatch::EXTENSION_APP) {
- ExtensionService* service = profile_->GetExtensionService();
const extensions::Extension* extension =
- service->GetInstalledApp(match_.destination_url);
+ GetExtensionByURL(profile_, match_.destination_url);
if (extension) {
LoadExtensionIcon(extension);
return;
@@ -220,9 +230,8 @@ void SearchBuilder::OpenResult(const app_list::SearchResult& result,
const AutocompleteMatch& match = builder_result->match();
if (match.type == AutocompleteMatch::EXTENSION_APP) {
- ExtensionService* service = profile_->GetExtensionService();
const extensions::Extension* extension =
- service->GetInstalledApp(match.destination_url);
+ GetExtensionByURL(profile_, match.destination_url);
if (extension)
extension_utils::OpenExtension(profile_, extension, event_flags);
} else {
diff --git a/chrome/common/extensions/extension.cc b/chrome/common/extensions/extension.cc
index 2eef8be..0f13369 100644
--- a/chrome/common/extensions/extension.cc
+++ b/chrome/common/extensions/extension.cc
@@ -96,20 +96,20 @@ const char kDefaultContentSecurityPolicy[] =
"'self' blob: data: filesystem: chrome-extension-resource:"
const char kDefaultPlatformAppContentSecurityPolicy[] =
// Platform apps can only use local resources by default.
- "default-src 'self' chrome-extension-resource:;"
- // For remote resources, they can fetch them via XMLHttpRequest.
- "connect-src *;"
- // And serve them via blob:, data: or filesystem: URLs
- "style-src " PLATFORM_APP_LOCAL_CSP_SOURCES " 'unsafe-inline';"
- "img-src " PLATFORM_APP_LOCAL_CSP_SOURCES ";"
- "frame-src " PLATFORM_APP_LOCAL_CSP_SOURCES ";"
- "font-src " PLATFORM_APP_LOCAL_CSP_SOURCES ";"
- // Media can be loaded from remote resources since:
- // 1. <video> and <audio> have good fallback behavior when offline or under
- // spotty connectivity.
- // 2. Fetching via XHR and serving via blob: URLs currently does not allow
- // streaming or partial buffering.
- "media-src *;";
+ "default-src 'self' chrome-extension-resource:;"
+ // For remote resources, they can fetch them via XMLHttpRequest.
+ "connect-src *;"
+ // And serve them via blob:, data: or filesystem: URLs
+ "style-src " PLATFORM_APP_LOCAL_CSP_SOURCES " 'unsafe-inline';"
+ "img-src " PLATFORM_APP_LOCAL_CSP_SOURCES ";"
+ "frame-src " PLATFORM_APP_LOCAL_CSP_SOURCES ";"
+ "font-src " PLATFORM_APP_LOCAL_CSP_SOURCES ";"
+ // Media can be loaded from remote resources since:
+ // 1. <video> and <audio> have good fallback behavior when offline or under
+ // spotty connectivity.
+ // 2. Fetching via XHR and serving via blob: URLs currently does not allow
+ // streaming or partial buffering.
+ "media-src *;";
const char kDefaultSandboxedPageContentSecurityPolicy[] =
"sandbox allow-scripts allow-forms";
@@ -775,7 +775,7 @@ bool Extension::LoadGlobsHelper(
const char* globs_property_name,
string16* error,
void(UserScript::*add_method)(const std::string& glob),
- UserScript *instance) {
+ UserScript* instance) {
if (!content_script->HasKey(globs_property_name))
return true; // they are optional
@@ -1253,6 +1253,10 @@ bool Extension::LoadLaunchURL(string16* error) {
cloud_print_service_url.ReplaceComponents(replacements);
OverrideLaunchUrl(cloud_print_enable_connector_url);
}
+ } else if (id() == extension_misc::kChromeAppId) {
+ // Override launch url to new tab.
+ launch_web_url_ = chrome::kChromeUINewTabURL;
+ extent_.ClearPatterns();
}
return true;
@@ -3701,7 +3705,7 @@ bool Extension::InstallWarning::operator==(const InstallWarning& other) const {
return format == other.format && message == other.message;
}
-void PrintTo(const Extension::InstallWarning& warning, ::std::ostream* os){
+void PrintTo(const Extension::InstallWarning& warning, ::std::ostream* os) {
*os << "InstallWarning(";
switch (warning.format) {
case Extension::InstallWarning::FORMAT_TEXT:
diff --git a/chrome/common/extensions/extension_constants.cc b/chrome/common/extensions/extension_constants.cc
index 416178d..14242a8 100644
--- a/chrome/common/extensions/extension_constants.cc
+++ b/chrome/common/extensions/extension_constants.cc
@@ -121,6 +121,7 @@ const char kHTermDevAppId[] = "okddffdblfhhnmhodogpojmfkjmhinfp";
const char kCroshBuiltinAppId[] = "nkoccljplnhpfnfiajclkommnmllphnl";
const char kWebStoreAppId[] = "ahfgeienlihckogmohjhadlkjgocpleb";
const char kCloudPrintAppId[] = "mfehgcgbbipciphmccgaenjidiccnmng";
+const char kChromeAppId[] = "mgndgikekgjfcpckkfioiadnlibdjbkf";
const char kAppsPromoHistogram[] = "Extensions.AppsPromo";
const char kAppLaunchHistogram[] = "Extensions.AppLaunch";
#if defined(OS_CHROMEOS)
diff --git a/chrome/common/extensions/extension_constants.h b/chrome/common/extensions/extension_constants.h
index f383801..7497904 100644
--- a/chrome/common/extensions/extension_constants.h
+++ b/chrome/common/extensions/extension_constants.h
@@ -113,6 +113,9 @@ namespace extension_misc {
// The extension id of the Cloud Print component application.
extern const char kCloudPrintAppId[];
+ // The extension id of the Chrome component application.
+ extern const char kChromeAppId[];
+
// Note: this structure is an ASN.1 which encodes the algorithm used
// with its parameters. This is defined in PKCS #1 v2.1 (RFC 3447).
// It is encoding: { OID sha1WithRSAEncryption PARAMETERS NULL }