1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703
|
// Copyright 2018 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_WEB_APPLICATIONS_WEB_APP_H_
#define CHROME_BROWSER_WEB_APPLICATIONS_WEB_APP_H_
#include <stdint.h>
#include <iosfwd>
#include <optional>
#include <set>
#include <string>
#include <vector>
#include "base/containers/flat_map.h"
#include "base/containers/flat_set.h"
#include "base/time/time.h"
#include "base/values.h"
#include "base/version.h"
#include "build/build_config.h"
#include "chrome/browser/web_applications/generated_icon_fix_util.h"
#include "chrome/browser/web_applications/isolated_web_apps/isolated_web_app_integrity_block_data.h"
#include "chrome/browser/web_applications/isolated_web_apps/isolated_web_app_storage_location.h"
#include "chrome/browser/web_applications/isolated_web_apps/isolation_data.h"
#include "chrome/browser/web_applications/mojom/user_display_mode.mojom-forward.h"
#include "chrome/browser/web_applications/proto/web_app.pb.h"
#include "chrome/browser/web_applications/proto/web_app_os_integration_state.pb.h"
#include "chrome/browser/web_applications/scope_extension_info.h"
#include "chrome/browser/web_applications/user_display_mode.h"
#include "chrome/browser/web_applications/web_app_chromeos_data.h"
#include "chrome/browser/web_applications/web_app_constants.h"
#include "chrome/browser/web_applications/web_app_install_info.h"
#include "chrome/browser/web_applications/web_app_management_type.h"
#include "components/services/app_service/public/cpp/file_handler.h"
#include "components/services/app_service/public/cpp/icon_info.h"
#include "components/services/app_service/public/cpp/protocol_handler_info.h"
#include "components/services/app_service/public/cpp/share_target.h"
#include "components/sync/model/string_ordinal.h"
#include "components/sync/protocol/web_app_specifics.pb.h"
#include "components/webapps/common/web_app_id.h"
#include "services/network/public/cpp/permissions_policy/permissions_policy_declaration.h"
#include "third_party/blink/public/common/manifest/manifest.h"
#include "third_party/blink/public/mojom/manifest/capture_links.mojom-shared.h"
#include "third_party/blink/public/mojom/manifest/display_mode.mojom-shared.h"
#include "third_party/skia/include/core/SkColor.h"
#include "url/gurl.h"
#if BUILDFLAG(IS_CHROMEOS)
#include "chromeos/ash/experiences/system_web_apps/types/system_web_app_data.h"
#endif
namespace webapps {
enum class WebappInstallSource;
}
namespace web_app {
class TabbedModeScopeMatcher;
class WebApp {
public:
// Deprecated, use the other constructor instead.
explicit WebApp(const webapps::AppId& app_id);
// This creates a web app object, and will CHECK-fail if the arguments are
// invalid. To be valid, the following invariants must hold:
// - All GURLs and the `manifest_id` must be non-empty and valid.
// - `start_url`, `manifest_id` and `scope` must be same-origin.
// - `manifest_id` must not contain a fragment.
// - `scope` must not contain a query or fragment.
// - `scope` must be a prefix of `start_url`.
WebApp(const webapps::ManifestId& manifest_id,
const GURL& start_url,
const GURL& scope,
std::optional<webapps::AppId> parent_app_id = std::nullopt,
std::optional<webapps::ManifestId> parent_manifest_id = std::nullopt);
~WebApp();
// Copyable and move-assignable to support Copy-on-Write with Commit.
WebApp(const WebApp& web_app);
WebApp& operator=(WebApp&& web_app);
WebApp(WebApp&&);
WebApp& operator=(const WebApp&) = delete;
const webapps::AppId& app_id() const { return app_id_; }
// UTF8 encoded application name. This name is not translated, use
// WebAppRegistrar.GetAppShortName to get the translated name.
const std::string& untranslated_name() const { return name_; }
// UTF8 encoded long application description (a full application name). This
// description is not translated, use WebAppRegistrar.GetAppDescription to get
// the translated description.
const std::string& untranslated_description() const { return description_; }
const GURL& start_url() const { return start_url_; }
const std::string* launch_query_params() const {
return launch_query_params_ ? &launch_query_params_.value() : nullptr;
}
const GURL& scope() const { return scope_; }
const std::optional<SkColor>& theme_color() const { return theme_color_; }
const std::optional<SkColor>& dark_mode_theme_color() const {
return dark_mode_theme_color_;
}
const std::optional<SkColor>& background_color() const {
return background_color_;
}
const std::optional<SkColor>& dark_mode_background_color() const {
return dark_mode_background_color_;
}
DisplayMode display_mode() const { return display_mode_; }
mojom::UserDisplayMode user_display_mode() const {
return ToMojomUserDisplayMode(
ResolvePlatformSpecificUserDisplayMode(sync_proto()));
}
const std::vector<DisplayMode>& display_mode_override() const {
return display_mode_override_;
}
syncer::StringOrdinal user_page_ordinal() const {
return syncer::StringOrdinal(sync_proto().user_page_ordinal());
}
syncer::StringOrdinal user_launch_ordinal() const {
return syncer::StringOrdinal(sync_proto().user_launch_ordinal());
}
const std::optional<WebAppChromeOsData>& chromeos_data() const {
return chromeos_data_;
}
struct ClientData {
ClientData();
~ClientData();
ClientData(const ClientData& client_data);
base::Value AsDebugValue() const;
#if BUILDFLAG(IS_CHROMEOS)
std::optional<ash::SystemWebAppData> system_web_app_data;
#endif
};
const ClientData& client_data() const { return client_data_; }
ClientData* client_data() { return &client_data_; }
// Installation status:
// - Not locally installed: The app is not installed at all on this device,
// but does exist in the user's sync profile (and only is listed as part of
// the user's app library).
// - Fully installed: The app is fully installed on this device.
// - Partially installed no integration: The app is considered installed, but
// does not have any OS integration with the operating system (no shortcuts,
// etc). This is used for preinstalled apps on non-CrOS device.
proto::InstallState install_state() const { return install_state_; }
// Sync-initiated installation produces a stub app awaiting for full
// installation process. The |is_from_sync_and_pending_installation| app has
// only app_id, launch_url and sync_fallback_data fields defined, no icons. If
// online install succeeds, icons get downloaded and all the fields get their
// values. If online install fails, we do the fallback installation to
// generate icons using |sync_fallback_data| fields.
bool is_from_sync_and_pending_installation() const {
return is_from_sync_and_pending_installation_;
}
// Represents whether the web app is being uninstalled.
bool is_uninstalling() const { return is_uninstalling_; }
// Represents the last time the Badging API was used.
const base::Time& last_badging_time() const { return last_badging_time_; }
// Represents the last time this app is launched.
const base::Time& last_launch_time() const { return last_launch_time_; }
// Represents the time when this app is installed.
const base::Time& first_install_time() const { return first_install_time_; }
// Represents the time when this app is updated.
const base::Time& manifest_update_time() const {
return manifest_update_time_;
}
// Represents the "icons" field in the manifest.
const std::vector<apps::IconInfo>& manifest_icons() const {
return manifest_icons_;
}
// Represents which icon sizes we successfully downloaded from the
// |manifest_icons| for the given |purpose|.
const SortedSizesPx& downloaded_icon_sizes(IconPurpose purpose) const;
// Represents whether the icons for the web app are generated by Chrome due to
// no suitable icons being available.
bool is_generated_icon() const { return is_generated_icon_; }
const apps::FileHandlers& file_handlers() const { return file_handlers_; }
ApiApprovalState file_handler_approval_state() const {
return file_handler_approval_state_;
}
const std::optional<apps::ShareTarget>& share_target() const {
return share_target_;
}
const std::vector<std::string>& additional_search_terms() const {
return additional_search_terms_;
}
const std::vector<apps::ProtocolHandlerInfo>& protocol_handlers() const {
return protocol_handlers_;
}
const base::flat_set<std::string>& allowed_launch_protocols() const {
return allowed_launch_protocols_;
}
const base::flat_set<std::string>& disallowed_launch_protocols() const {
return disallowed_launch_protocols_;
}
// URL within scope to launch for a "show on lock screen" action. Valid iff
// this is considered a lock-screen-capable app.
const GURL& lock_screen_start_url() const { return lock_screen_start_url_; }
// URL within scope to launch for a "new note" action. Valid iff this is
// considered a note-taking app.
const GURL& note_taking_new_note_url() const {
return note_taking_new_note_url_;
}
const base::flat_set<ScopeExtensionInfo>& scope_extensions() const {
return scope_extensions_;
}
const base::flat_set<ScopeExtensionInfo>& validated_scope_extensions() const {
return validated_scope_extensions_;
}
RunOnOsLoginMode run_on_os_login_mode() const {
return run_on_os_login_mode_;
}
bool window_controls_overlay_enabled() const {
return window_controls_overlay_enabled_;
}
// While local |name| and |theme_color| may vary from device to device, the
// synced copies of these fields are replicated to all devices. The synced
// copies are read by a device to generate a placeholder icon (if needed). Any
// device may write new values to |sync_proto|, random last update
// wins.
const sync_pb::WebAppSpecifics& sync_proto() const {
// Ensure the sync proto has been initialized.
CHECK(sync_proto_.has_start_url());
CHECK(GURL(sync_proto_.start_url()).is_valid());
CHECK(sync_proto_.has_relative_manifest_id());
return sync_proto_;
}
// Represents the "shortcuts" field in the manifest.
const std::vector<WebAppShortcutsMenuItemInfo>& shortcuts_menu_item_infos()
const {
return shortcuts_menu_item_infos_;
}
blink::mojom::CaptureLinks capture_links() const { return capture_links_; }
const GURL& manifest_url() const { return manifest_url_; }
webapps::ManifestId manifest_id() const;
const std::optional<LaunchHandler>& launch_handler() const {
return launch_handler_;
}
const std::optional<webapps::AppId>& parent_app_id() const {
return parent_app_id_;
}
const network::ParsedPermissionsPolicy& permissions_policy() const {
return permissions_policy_;
}
std::optional<webapps::WebappInstallSource> latest_install_source() const {
return latest_install_source_;
}
const std::optional<int64_t>& app_size_in_bytes() const {
return app_size_in_bytes_;
}
const std::optional<int64_t>& data_size_in_bytes() const {
return data_size_in_bytes_;
}
struct ExternalManagementConfig {
ExternalManagementConfig();
ExternalManagementConfig(
bool is_placeholder,
const base::flat_set<GURL>& install_urls,
const base::flat_set<std::string>& additional_policy_ids);
~ExternalManagementConfig();
ExternalManagementConfig(
const ExternalManagementConfig& external_management_config);
ExternalManagementConfig& operator=(
const ExternalManagementConfig& external_management_config);
ExternalManagementConfig& operator=(
ExternalManagementConfig&& external_management_config);
friend bool operator==(const ExternalManagementConfig&,
const ExternalManagementConfig&) = default;
base::Value::Dict AsDebugValue() const;
bool is_placeholder = false;
base::flat_set<GURL> install_urls;
// A list of additional terms to use when matching this app against
// identifiers in admin policies (for shelf pinning, default file handlers,
// etc).
// Note that list is not meant to be an exhaustive enumeration of all
// possible policy_ids but rather just a supplement for tricky cases.
base::flat_set<std::string> additional_policy_ids;
// Any new fields added should consider adding config merge logic to
// BuildOperationsToDedupeInstallUrlConfigsIntoSelectedApp().
};
using ExternalConfigMap =
base::flat_map<WebAppManagement::Type, ExternalManagementConfig>;
const ExternalConfigMap& management_to_external_config_map() const {
return management_to_external_config_map_;
}
const std::optional<blink::Manifest::TabStrip> tab_strip() const {
return tab_strip_;
}
// Returns the list of patterns to match URLs against for tabbed mode home
// tab navigations.
const std::vector<TabbedModeScopeMatcher>& GetTabbedModeHomeScope() const;
// Only used on Mac.
bool always_show_toolbar_in_fullscreen() const {
return always_show_toolbar_in_fullscreen_;
}
const proto::os_state::WebAppOsIntegration& current_os_integration_states()
const {
return current_os_integration_states_;
}
// If present, signals that this app is an Isolated Web App, and contains
// IWA-specific information like from where the contents should be served.
const std::optional<IsolationData>& isolation_data() const {
return isolation_data_;
}
proto::LinkCapturingUserPreference user_link_capturing_preference() const {
return user_link_capturing_preference_;
}
const base::Time& latest_install_time() const { return latest_install_time_; }
const std::optional<proto::GeneratedIconFix>& generated_icon_fix() const;
int supported_links_offer_ignore_count() const {
return supported_links_offer_ignore_count_;
}
int supported_links_offer_dismiss_count() const {
return supported_links_offer_dismiss_count_;
}
bool is_diy_app() const { return is_diy_app_; }
bool was_shortcut_app() const { return was_shortcut_app_; }
bool diy_app_icons_masked_on_mac() const {
return diy_app_icons_masked_on_mac_;
}
const std::vector<blink::Manifest::RelatedApplication>& related_applications()
const {
return related_applications_;
}
// A Web App can be installed from multiple sources simultaneously. Installs
// add a source to the app. Uninstalls remove a source from the app.
void AddSource(WebAppManagement::Type source);
void RemoveSource(WebAppManagement::Type source);
bool HasAnySources() const;
bool HasOnlySource(WebAppManagement::Type source) const;
WebAppManagementTypes GetSources() const;
bool IsSynced() const;
// Returns true if the app is preinstalled through PreinstalledWebAppManager.
// Does not include apps preloaded through the App Preload Service.
bool IsPreinstalledApp() const;
bool IsPolicyInstalledApp() const;
bool IsIwaPolicyInstalledApp() const;
bool IsIwaShimlessRmaApp() const;
bool IsSystemApp() const;
bool IsWebAppStoreInstalledApp() const;
bool IsSubAppInstalledApp() const;
bool IsKioskInstalledApp() const;
bool CanUserUninstallWebApp() const;
bool WasInstalledByUser() const;
// Returns the highest priority source. AppService assumes that every app has
// just one install source.
WebAppManagement::Type GetHighestPrioritySource() const;
void SetName(const std::string& name);
void SetDescription(const std::string& description);
void SetStartUrl(const GURL& start_url);
void SetLaunchQueryParams(std::optional<std::string> launch_query_params);
// Sets the scope after clearing the query and fragment from the scope url, as
// per spec. This call will check-fail if the scope is not valid.
void SetScope(const GURL& scope);
void SetThemeColor(std::optional<SkColor> theme_color);
void SetDarkModeThemeColor(std::optional<SkColor> theme_color);
void SetBackgroundColor(std::optional<SkColor> background_color);
void SetDarkModeBackgroundColor(std::optional<SkColor> background_color);
void SetDisplayMode(DisplayMode display_mode);
// Sets the UserDisplayMode for the current platform (CrOS or default).
void SetUserDisplayMode(mojom::UserDisplayMode user_display_mode);
void SetDisplayModeOverride(std::vector<DisplayMode> display_mode_override);
void SetWebAppChromeOsData(std::optional<WebAppChromeOsData> chromeos_data);
void SetInstallState(proto::InstallState install_state);
void SetIsFromSyncAndPendingInstallation(
bool is_from_sync_and_pending_installation);
void SetIsUninstalling(bool is_uninstalling);
void SetManifestIcons(std::vector<apps::IconInfo> manifest_icons);
// Performs sorting and uniquifying of |sizes| if passed as vector.
void SetDownloadedIconSizes(IconPurpose purpose, SortedSizesPx sizes);
void SetIsGeneratedIcon(bool is_generated_icon);
// Sets information about the shortcuts menu for the app.
void SetShortcutsMenuInfo(
std::vector<WebAppShortcutsMenuItemInfo> shortcuts_menu_infos);
void SetFileHandlers(apps::FileHandlers file_handlers);
void SetFileHandlerApprovalState(ApiApprovalState approval_state);
void SetShareTarget(std::optional<apps::ShareTarget> share_target);
void SetAdditionalSearchTerms(
std::vector<std::string> additional_search_terms);
void SetProtocolHandlers(
std::vector<apps::ProtocolHandlerInfo> protocol_handlers);
void SetAllowedLaunchProtocols(
base::flat_set<std::string> allowed_launch_protocols);
void SetDisallowedLaunchProtocols(
base::flat_set<std::string> disallowed_launch_protocols);
void SetScopeExtensions(base::flat_set<ScopeExtensionInfo> scope_extensions);
void SetValidatedScopeExtensions(
base::flat_set<ScopeExtensionInfo> validated_scope_extensions);
void SetLockScreenStartUrl(const GURL& lock_screen_start_url);
void SetNoteTakingNewNoteUrl(const GURL& note_taking_new_note_url);
void SetLastBadgingTime(const base::Time& time);
void SetLastLaunchTime(const base::Time& time);
void SetFirstInstallTime(const base::Time& time);
void SetManifestUpdateTime(const base::Time& time);
void SetRunOnOsLoginMode(RunOnOsLoginMode mode);
void SetSyncProto(sync_pb::WebAppSpecifics sync_proto);
void SetCaptureLinks(blink::mojom::CaptureLinks capture_links);
void SetManifestUrl(const GURL& manifest_url);
void SetManifestId(const webapps::ManifestId& manifest_id);
void SetWindowControlsOverlayEnabled(bool enabled);
void SetLaunchHandler(std::optional<LaunchHandler> launch_handler);
void SetParentAppId(const std::optional<webapps::AppId>& parent_app_id);
void SetPermissionsPolicy(
network::ParsedPermissionsPolicy permissions_policy);
void SetLatestInstallSource(
std::optional<webapps::WebappInstallSource> latest_install_source);
void SetAppSizeInBytes(std::optional<int64_t> app_size_in_bytes);
void SetDataSizeInBytes(std::optional<int64_t> data_size_in_bytes);
void SetWebAppManagementExternalConfigMap(
ExternalConfigMap management_to_external_config_map);
void SetTabStrip(std::optional<blink::Manifest::TabStrip> tab_strip);
void SetCurrentOsIntegrationStates(
proto::os_state::WebAppOsIntegration current_os_integration_states);
void SetIsolationData(IsolationData isolation_data);
void SetLinkCapturingUserPreference(
proto::LinkCapturingUserPreference user_link_capturing_preference);
void SetSupportedLinksOfferIgnoreCount(int ignore_count);
void SetSupportedLinksOfferDismissCount(int dismiss_count);
void SetIsDiyApp(bool is_diy_app);
void SetWasShortcutApp(bool was_shortcut_app);
void SetDiyAppIconsMaskedOnMac(bool diy_app_icons_masked_on_mac);
void SetRelatedApplications(
std::vector<blink::Manifest::RelatedApplication> related_applications);
void AddPlaceholderInfoToManagementExternalConfigMap(
WebAppManagement::Type source_type,
bool is_placeholder);
// This adds an install_url per management type (source) for the
// ExternalConfigMap.
void AddInstallURLToManagementExternalConfigMap(WebAppManagement::Type type,
GURL install_url);
// This adds a policy_id per management type (source) for the
// ExternalConfigMap.
void AddPolicyIdToManagementExternalConfigMap(WebAppManagement::Type type,
std::string policy_id);
// Encapsulate the addition of install_url and is_placeholder information
// for cases where both need to be added.
void AddExternalSourceInformation(WebAppManagement::Type source_type,
GURL install_url,
bool is_placeholder);
bool RemoveInstallUrlForSource(WebAppManagement::Type type,
const GURL& install_url);
// Only used on Mac, determines if the toolbar should be permanently shown
// when in fullscreen.
void SetAlwaysShowToolbarInFullscreen(bool show);
void SetLatestInstallTime(const base::Time& latest_install_time);
void SetGeneratedIconFix(
std::optional<proto::GeneratedIconFix> generated_icon_fix);
// For logging and debug purposes.
bool operator==(const WebApp&) const;
// Used by the WebAppTest suite to cover only platform agnostic fields to
// avoid needing multiple platform specific expectation files per test.
// Otherwise, the same as AsDebugValue().
base::Value AsDebugValueWithOnlyPlatformAgnosticFields() const;
base::Value AsDebugValue() const;
private:
friend class WebAppDatabase;
friend std::unique_ptr<WebApp> ParseWebAppProto(const proto::WebApp& proto);
friend std::unique_ptr<proto::WebApp> WebAppToProto(const WebApp& web_app);
friend std::ostream& operator<<(std::ostream&, const WebApp&);
webapps::AppId app_id_;
// This set always contains at least one source.
WebAppManagementTypes sources_;
std::string name_;
std::string description_;
GURL start_url_;
std::optional<std::string> launch_query_params_;
GURL scope_;
std::optional<SkColor> theme_color_;
std::optional<SkColor> dark_mode_theme_color_;
std::optional<SkColor> background_color_;
std::optional<SkColor> dark_mode_background_color_;
DisplayMode display_mode_ = DisplayMode::kUndefined;
std::vector<DisplayMode> display_mode_override_;
std::optional<WebAppChromeOsData> chromeos_data_;
proto::InstallState install_state_ =
proto::InstallState::INSTALLED_WITHOUT_OS_INTEGRATION;
bool is_from_sync_and_pending_installation_ = false;
// Note: This field is not persisted in the database.
// TODO(crbug.com/40162790): Add this field to the protocol buffer file and
// other places to save it to the database, and then make sure to continue
// uninstallation on startup if any web apps have this field set to true.
bool is_uninstalling_ = false;
std::vector<apps::IconInfo> manifest_icons_;
SortedSizesPx downloaded_icon_sizes_any_;
SortedSizesPx downloaded_icon_sizes_monochrome_;
SortedSizesPx downloaded_icon_sizes_maskable_;
bool is_generated_icon_ = false;
std::vector<WebAppShortcutsMenuItemInfo> shortcuts_menu_item_infos_;
apps::FileHandlers file_handlers_;
std::optional<apps::ShareTarget> share_target_;
std::vector<std::string> additional_search_terms_;
std::vector<apps::ProtocolHandlerInfo> protocol_handlers_;
base::flat_set<std::string> allowed_launch_protocols_;
base::flat_set<std::string> disallowed_launch_protocols_;
base::flat_set<ScopeExtensionInfo> scope_extensions_;
base::flat_set<ScopeExtensionInfo> validated_scope_extensions_;
GURL lock_screen_start_url_;
GURL note_taking_new_note_url_;
base::Time last_badging_time_;
base::Time last_launch_time_;
base::Time first_install_time_;
base::Time manifest_update_time_;
RunOnOsLoginMode run_on_os_login_mode_ = RunOnOsLoginMode::kNotRun;
sync_pb::WebAppSpecifics sync_proto_;
blink::mojom::CaptureLinks capture_links_ =
blink::mojom::CaptureLinks::kUndefined;
ClientData client_data_;
// This can be empty.
GURL manifest_url_;
webapps::ManifestId manifest_id_;
// The state of the user's approval of the app's use of the File Handler API.
ApiApprovalState file_handler_approval_state_ =
ApiApprovalState::kRequiresPrompt;
bool window_controls_overlay_enabled_ = false;
std::optional<LaunchHandler> launch_handler_;
std::optional<webapps::AppId> parent_app_id_;
network::ParsedPermissionsPolicy permissions_policy_;
// The source of the latest install. WebAppRegistrar provides range
// validation. Optional only to support legacy installations, since this used
// to be tracked as a pref. It might also be null if the value read from the
// database is not recognized by this client.
std::optional<webapps::WebappInstallSource> latest_install_source_;
std::optional<int64_t> app_size_in_bytes_;
std::optional<int64_t> data_size_in_bytes_;
// Maps WebAppManagement::Type to config values for externally installed apps,
// like is_placeholder and install URLs.
ExternalConfigMap management_to_external_config_map_;
std::optional<blink::Manifest::TabStrip> tab_strip_;
// Only used on Mac.
bool always_show_toolbar_in_fullscreen_ = true;
proto::os_state::WebAppOsIntegration current_os_integration_states_;
std::optional<IsolationData> isolation_data_;
proto::LinkCapturingUserPreference user_link_capturing_preference_ =
proto::NAVIGATION_CAPTURING_PREFERENCE_DEFAULT;
base::Time latest_install_time_;
std::optional<proto::GeneratedIconFix> generated_icon_fix_;
int supported_links_offer_ignore_count_ = 0;
int supported_links_offer_dismiss_count_ = 0;
bool is_diy_app_ = false;
bool was_shortcut_app_ = false;
bool diy_app_icons_masked_on_mac_ = false;
std::vector<blink::Manifest::RelatedApplication> related_applications_;
// New fields must be added to:
// - |operator==|
// - AsDebugValue()
// - WebAppDatabase::CreateWebApp()
// - WebAppDatabase::CreateWebAppProto()
// - CreateRandomWebApp()
// - web_app.proto
// If parsed from manifest, also add to:
// - GetManifestDataChanges() inside manifest_update_utils.h
// - SetWebAppManifestFields()
// If the field relates to the app icons, add revert logic for it in:
// - ManifestUpdateCheckCommand::RevertIdentityChangesIfNeeded()
// Some data is derived from other fields in this class but can be somewhat
// expensive to calculate and/or might not be copyable. That data can be
// lazily calculated and stored in this struct. When the WebApp instance is
// copied the cached derived data is not copied.
struct CachedDerivedData {
CachedDerivedData();
~CachedDerivedData();
CachedDerivedData(CachedDerivedData&&);
CachedDerivedData& operator=(CachedDerivedData&&);
CachedDerivedData(const CachedDerivedData&);
CachedDerivedData& operator=(const CachedDerivedData&);
// Lazily initialized list of patterns to match URLs against for tabbed mode
// home tab navigations. If a URL matches any pattern in this list, it is
// considered within home tab scope.
//
// An empty list means there is no home tab scope to match against (i.e.
// nothing matches), whereas an uninitialized list means it has not yet been
// needed.
std::optional<std::vector<TabbedModeScopeMatcher>> home_tab_scope;
};
mutable CachedDerivedData cached_derived_data_;
};
// For logging and debug purposes.
std::ostream& operator<<(std::ostream& out, const WebApp& app);
std::ostream& operator<<(
std::ostream& out,
const WebApp::ExternalManagementConfig& management_config);
namespace proto::os_state {
bool operator==(const WebAppOsIntegration& os_integration_state1,
const WebAppOsIntegration& os_integration_state2);
} // namespace proto::os_state
std::vector<std::string> GetSerializedAllowedOrigins(
const network::ParsedPermissionsPolicyDeclaration
permissions_policy_declaration);
} // namespace web_app
namespace sync_pb {
bool operator==(const WebAppSpecifics& sync_proto1,
const WebAppSpecifics& sync_proto2);
} // namespace sync_pb
#endif // CHROME_BROWSER_WEB_APPLICATIONS_WEB_APP_H_
|