-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Persist scope_extensions to web app database
These changes persist the 'scope_extensions' info in the web app manifest to the web app database after it is parsed by the manifest parser. This feature will allow progressive web apps to extend their scope. Design Doc: https://docs.google.com/document/d/1-idhx8heajbPYl3cdXFVCjpIuf96cRa_DrRk6147ELI/edit?usp=sharing Prototype CL: https://chromium-review.googlesource.com/c/chromium/src/+/4034807 Chrome Status: https://chromestatus.com/feature/5746537956114432 Bug: 1250011 Change-Id: Ie2e013f039c33a41bd9db451095e343f44e01e80 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4198368 Reviewed-by: Alan Cutter <alancutter@chromium.org> Commit-Queue: Alan Cutter <alancutter@chromium.org> Cr-Commit-Position: refs/heads/main@{#1104812}
- Loading branch information
1 parent
6d05f33
commit ef9a1cf
Showing
14 changed files
with
302 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Copyright 2023 The Chromium Authors | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include <tuple> | ||
|
||
#include "chrome/browser/web_applications/scope_extension_info.h" | ||
|
||
namespace web_app { | ||
|
||
ScopeExtensionInfo::ScopeExtensionInfo(const url::Origin& origin, | ||
bool has_origin_wildcard) | ||
: origin(origin), has_origin_wildcard(has_origin_wildcard) {} | ||
|
||
base::Value ScopeExtensionInfo::AsDebugValue() const { | ||
base::Value root(base::Value::Type::DICT); | ||
root.SetStringKey("origin", origin.GetDebugString()); | ||
root.SetBoolKey("has_origin_wildcard", has_origin_wildcard); | ||
return root; | ||
} | ||
|
||
bool operator==(const ScopeExtensionInfo& scope_extension1, | ||
const ScopeExtensionInfo& scope_extension2) { | ||
return scope_extension1.origin == scope_extension2.origin && | ||
scope_extension1.has_origin_wildcard == | ||
scope_extension2.has_origin_wildcard; | ||
} | ||
|
||
bool operator!=(const ScopeExtensionInfo& scope_extension1, | ||
const ScopeExtensionInfo& scope_extension2) { | ||
return !(scope_extension1 == scope_extension2); | ||
} | ||
|
||
bool operator<(const ScopeExtensionInfo& scope_extension1, | ||
const ScopeExtensionInfo& scope_extension2) { | ||
return std::tie(scope_extension1.origin, | ||
scope_extension1.has_origin_wildcard) < | ||
std::tie(scope_extension2.origin, | ||
scope_extension2.has_origin_wildcard); | ||
} | ||
|
||
} // namespace web_app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Copyright 2023 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_SCOPE_EXTENSION_INFO_H_ | ||
#define CHROME_BROWSER_WEB_APPLICATIONS_SCOPE_EXTENSION_INFO_H_ | ||
|
||
#include "base/values.h" | ||
#include "url/origin.h" | ||
|
||
namespace web_app { | ||
|
||
// Contains information about a web app's scope extension information derived | ||
// from its web app manifest. | ||
struct ScopeExtensionInfo { | ||
ScopeExtensionInfo() = default; | ||
ScopeExtensionInfo(const url::Origin& origin, bool has_origin_wildcard); | ||
|
||
// Copyable to support web_app::WebApp being copyable as it has a | ||
// ScopeExtensions member variable. | ||
ScopeExtensionInfo(const ScopeExtensionInfo&) = default; | ||
ScopeExtensionInfo& operator=(const ScopeExtensionInfo&) = default; | ||
// Movable to support being contained in std::vector, which requires value | ||
// types to be copyable or movable. | ||
ScopeExtensionInfo(ScopeExtensionInfo&&) = default; | ||
ScopeExtensionInfo& operator=(ScopeExtensionInfo&&) = default; | ||
|
||
~ScopeExtensionInfo() = default; | ||
|
||
base::Value AsDebugValue() const; | ||
|
||
url::Origin origin; | ||
|
||
bool has_origin_wildcard = false; | ||
}; | ||
|
||
bool operator==(const ScopeExtensionInfo& scope_extension1, | ||
const ScopeExtensionInfo& scope_extension2); | ||
|
||
bool operator!=(const ScopeExtensionInfo& scope_extension1, | ||
const ScopeExtensionInfo& scope_extension2); | ||
|
||
// Allow ScopeExtensionInfo to be used as a key in STL (for example, a std::set | ||
// or std::map). | ||
bool operator<(const ScopeExtensionInfo& scope_extension1, | ||
const ScopeExtensionInfo& scope_extension2); | ||
|
||
} // namespace web_app | ||
|
||
#endif // CHROME_BROWSER_WEB_APPLICATIONS_SCOPE_EXTENSION_INFO_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.