Chrome Extension Type and Chrome Extension ID

Hosted App
    The .crx file for a hosted app must contain an icon and a manifest that has details about how the app should function. (from http://code.google.com/chrome/apps/docs/developers_guide.html). It will not run any JavaScript. It will give special permissions to a webApp.

Packaged App
    A web app that’s bundled up as an extension, so that the user downloads all of its content. (from http://code.google.com/chrome/apps/docs/developers_guide.html). A packaged app is a web app that’s bundled into a .crx file and can use Chrome extension features. You build a packaged app just like you build an extension, except that a packaged app can’t include a browser action or page action. Instead, a packaged app includes at least one HTML file within its .crx file that provides the app’s user interface.

Themes
    A theme is a special kind of extension that changes the way the browser looks.Themes are packaged like regular extensions, but they don’t contain JavaScript or HTML code.

Extension
    Extension can change the UI in the browser.
  

what is the chrome extension ID and what is a valid extension ID for chrome ?
    Chrome extension ID can be of size 16 bytes.
        // first 16 bytes of SHA256 hashed public key.
        const size_t Extension::kIdSize = 16; (in binrary form)

   
    In text form it has to be equal to 32 bytes.
    Support only lower case letter between a to p (16 characters of engligh alphabet is allowed)
    Max number of apps allowed is 16^16.

How Google chrome finds the type of App given a .crx?
    It finds the extension type by parsing the manifest.json file.
   
    If it has "theme" then it is Extension::TYPE_THEME.
    If it has "platform_app" set to true then it is Extension::TYPE_PLATFORM_APP.
    If it has "app" key and it has "urls" or "launch" then it is Extension::TYPE_HOSTED_APP.
    If it has "app" key and it don’t have "urls" and "launch" then it is Extension::TYPE_PACKAGED_APP.
    else it is "Extension::TYPE_EXTENSION and Extension::TYPE_USER_SCRIPT"

        
    chromium/src/chrome/common/extensions/manifest.cc
    chromium/src/chrome/common/extensions/manifest.h

    class Manifest {
     public:
      // Flags for matching types of extension manifests.
      enum Type {
        kTypeNone = 0,

        // Extension::TYPE_EXTENSION and Extension::TYPE_USER_SCRIPT
        kTypeExtension = 1 << 0,

        // Extension::TYPE_THEME
        kTypeTheme = 1 << 1,

        // Extension::TYPE_HOSTED_APP
        kTypeHostedApp = 1 << 2,

        // Extension::TYPE_PACKAGED_APP
        kTypePackagedApp = 1 << 3,

        // Extension::TYPE_PLATFORM_APP
        kTypePlatformApp = 1 << 4,

        // All types
        kTypeAll = (1 << 5) – 1,
      };
      ….
    }

    Manifest::Type Manifest::GetType() const {
      if (value_->HasKey(keys::kTheme))
        return kTypeTheme;
      bool is_platform_app = false;
      if (value_->GetBoolean(keys::kPlatformApp, &is_platform_app) &&
          is_platform_app)
        return kTypePlatformApp;
      if (value_->HasKey(keys::kApp)) {
        if (value_->Get(keys::kWebURLs, NULL) ||
            value_->Get(keys::kLaunchWebURL, NULL))
          return kTypeHostedApp;
        else
          return kTypePackagedApp;
      } else {
        return kTypeExtension;
      }
    }

Advertisements
This entry was posted in browser, Chrome, Cr-48, webKit and tagged , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s