chromium/components/webapk/webapk.proto

// Copyright 2016 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

syntax = "proto2";

option optimize_for = LITE_RUNTIME;

package webapk;

option java_package = "org.chromium.components.webapk.proto";
option java_outer_classname = "WebApkProto";

// Response after creating or updating a WebAPK.
message WebApkResponse {
  // Package name to install WebAPK at.
  optional string package_name = 1;

  // Version code of the WebAPK.
  optional string version = 2;

  // Unique id identifying session with WebAPK server.
  optional string token = 6;

  // This flag may be used, for example, if the WebAPK server is unable to
  // fulfill an update request and likely won't be able to fulfill subsequent
  // update requests from this WebAPK. One case where the server is unable to
  // fulfill update requests is if the Web Manifest is dynamically generated
  // based on the user's country etc. Therefore, we want the client to back off
  // from spamming update requests too often.
  optional bool relax_updates = 8;

  reserved 3, 4, 5, 7, 9;
}

// Sent as part of request to create or update a WebAPK.
message WebApk {
  enum UpdateReason {
    NONE = 1;
    OLD_SHELL_APK = 2;
    PRIMARY_ICON_HASH_DIFFERS = 3;
    SCOPE_DIFFERS = 5;
    START_URL_DIFFERS = 6;
    SHORT_NAME_DIFFERS = 7;
    NAME_DIFFERS = 8;
    BACKGROUND_COLOR_DIFFERS = 9;
    THEME_COLOR_DIFFERS = 10;
    ORIENTATION_DIFFERS = 11;
    DISPLAY_MODE_DIFFERS = 12;
    WEB_SHARE_TARGET_DIFFERS = 13;
    MANUALLY_TRIGGERED = 14;
    PRIMARY_ICON_MASKABLE_DIFFERS = 15;
    SHORTCUTS_DIFFER = 16;
    SPLASH_ICON_HASH_DIFFERS = 17;
    DARK_BACKGROUND_COLOR_DIFFERS = 18;
    DARK_THEME_COLOR_DIFFERS = 19;
    PRIMARY_ICON_CHANGE_BELOW_THRESHOLD = 20;
    PRIMARY_ICON_CHANGE_SHELL_UPDATE = 21;

    reserved 4;
  }

  // Package name of the WebAPK.
  optional string package_name = 1;

  // Version code of the WebAPK.
  optional string version = 2;

  // The URL of the Web App Manifest.
  optional string manifest_url = 3;

  // Chrome's package name.
  optional string requester_application_package = 5;

  // Chrome's version.
  optional string requester_application_version = 6;

  // The Web App Manifest.
  optional WebAppManifest manifest = 7;

  // The cpu abi of the browser making the request.
  optional string android_abi = 8;

  // If set true, this flag indicates that the Web App Manifest of the site is
  // no longer available.
  optional bool stale_manifest = 9;

  // A list of all reasons why the WebAPK needs to be updated.
  repeated UpdateReason update_reasons = 11;

  // The Android OS version (e.g '11').
  optional string android_version = 12;

  // Whether this builds supports app identity updates via dialog.
  optional bool app_identity_update_supported = 13;

  // The key used for identifying a WebAPK.
  optional string app_key = 14;

  reserved 4, 10;
}

// Contains data from the Web App Manifest.
message WebAppManifest {
  optional string name = 1;
  optional string short_name = 2;
  optional string start_url = 4;
  repeated string scopes = 5;
  repeated Image icons = 6;
  optional string orientation = 9;
  optional string display_mode = 10;
  optional string theme_color = 11;
  optional string background_color = 12;
  repeated ShareTarget share_targets = 17;
  repeated ShortcutItem shortcuts = 18;
  optional string id = 19;
  optional string dark_theme_color = 20;
  optional string dark_background_color = 21;
  optional bool has_custom_name = 22;

  reserved 3, 7, 8, 13 to 16;
}

message Image {
  enum Usage {
    PRIMARY_ICON = 1;
    SPLASH_ICON = 3;
    SHORTCUT_ICON = 4;

    reserved 2;
  }

  // Image's URL.
  optional string src = 1;

  // Murmur2 hash of the icon's bytes. There should not be any transformations
  // applied to the icon's bytes prior to taking the Murmur2 hash.
  optional string hash = 5;

  // Actual bytes of the image. This image may be re-encoded from the original
  // image and may not match the murmur2 hash field above.
  optional bytes image_data = 6;

  // Possible purposes that an icon can be used for.
  enum Purpose {
    // Missing purpose.
    PURPOSE_UNDEFINED = 0;
    // The icon can be displayed in any context.
    ANY = 1;

    // The icon can be used where a monochrome icon with a solid fill is needed.
    // MONOCHROME = 2; This is not currently used, so ignore it.

    // The icon is designed with the intention to be masked.
    MASKABLE = 3;

    reserved 2;
  }

  // The purposes this image may be used for.
  repeated Purpose purposes = 7;

  // Specifies Chrome's intended usages for the image.
  repeated Usage usages = 8;

  reserved 2, 3, 4, 9;
}

// A proto representing a ShareTargetParamsFile
// https://wicg.github.io/web-share-target/level-2/#sharetargetfiles-and-its-members
message ShareTargetParamsFile {
  optional string name = 1;
  repeated string accept = 2;
}

// A proto representing ShareTargetParams
// https://wicg.github.io/web-share-target/#dom-sharetargetparams
// Each field corresponds to key in ShareData. These are the query parameter
// keys to be used for the data supplied in a ShareData instance.
// ShareData: https://w3c.github.io/web-share#dom-sharedata
message ShareTargetParams {
  optional string title = 1;
  optional string text = 2;
  optional string url = 3;
  repeated ShareTargetParamsFile files = 4;
}

// A proto representing a ShareTarget.
// https://wicg.github.io/web-share-target/#dom-sharetarget
message ShareTarget {
  // The URL to be resolved when sharing.
  optional string action = 2;
  optional ShareTargetParams params = 3;
  optional string method = 4;
  optional string enctype = 5;
  reserved 1;
}

message ShortcutItem {
  optional string name = 1;
  optional string short_name = 2;
  optional string url = 3;
  repeated Image icons = 4;
}