diff options
Diffstat (limited to 'chromium/third_party/blink/renderer/modules/content_index')
14 files changed, 73 insertions, 50 deletions
diff --git a/chromium/third_party/blink/renderer/modules/content_index/content_description_type_converter.cc b/chromium/third_party/blink/renderer/modules/content_index/content_description_type_converter.cc index debf6e50079..cbf40e6a8ce 100644 --- a/chromium/third_party/blink/renderer/modules/content_index/content_description_type_converter.cc +++ b/chromium/third_party/blink/renderer/modules/content_index/content_description_type_converter.cc @@ -5,7 +5,7 @@ #include "third_party/blink/renderer/modules/content_index/content_description_type_converter.h" #include "third_party/blink/public/mojom/content_index/content_index.mojom-blink.h" -#include "third_party/blink/renderer/modules/content_index/content_icon_definition.h" +#include "third_party/blink/renderer/bindings/modules/v8/v8_content_icon_definition.h" #include "third_party/blink/renderer/platform/heap/heap.h" #include "third_party/blink/renderer/platform/weborigin/kurl.h" diff --git a/chromium/third_party/blink/renderer/modules/content_index/content_description_type_converter.h b/chromium/third_party/blink/renderer/modules/content_index/content_description_type_converter.h index 8552d8f5b1c..da76c761479 100644 --- a/chromium/third_party/blink/renderer/modules/content_index/content_description_type_converter.h +++ b/chromium/third_party/blink/renderer/modules/content_index/content_description_type_converter.h @@ -7,7 +7,7 @@ #include "mojo/public/cpp/bindings/type_converter.h" #include "third_party/blink/public/mojom/content_index/content_index.mojom-blink-forward.h" -#include "third_party/blink/renderer/modules/content_index/content_description.h" +#include "third_party/blink/renderer/bindings/modules/v8/v8_content_description.h" #include "third_party/blink/renderer/modules/modules_export.h" namespace mojo { diff --git a/chromium/third_party/blink/renderer/modules/content_index/content_description_type_converter_test.cc b/chromium/third_party/blink/renderer/modules/content_index/content_description_type_converter_test.cc index e3e3de0f386..5a3733c1d5f 100644 --- a/chromium/third_party/blink/renderer/modules/content_index/content_description_type_converter_test.cc +++ b/chromium/third_party/blink/renderer/modules/content_index/content_description_type_converter_test.cc @@ -6,8 +6,8 @@ #include "testing/gtest/include/gtest/gtest.h" #include "third_party/blink/public/mojom/content_index/content_index.mojom-blink.h" -#include "third_party/blink/renderer/modules/content_index/content_description.h" -#include "third_party/blink/renderer/modules/content_index/content_icon_definition.h" +#include "third_party/blink/renderer/bindings/modules/v8/v8_content_description.h" +#include "third_party/blink/renderer/bindings/modules/v8/v8_content_icon_definition.h" #include "third_party/blink/renderer/platform/weborigin/kurl.h" #include "third_party/blink/renderer/platform/wtf/text/wtf_string.h" #include "third_party/blink/renderer/platform/wtf/vector.h" diff --git a/chromium/third_party/blink/renderer/modules/content_index/content_index.cc b/chromium/third_party/blink/renderer/modules/content_index/content_index.cc index 929c5965d65..7d77fb47c2f 100644 --- a/chromium/third_party/blink/renderer/modules/content_index/content_index.cc +++ b/chromium/third_party/blink/renderer/modules/content_index/content_index.cc @@ -8,12 +8,13 @@ #include "third_party/blink/public/common/browser_interface_broker_proxy.h" #include "third_party/blink/public/platform/web_size.h" #include "third_party/blink/renderer/bindings/core/v8/script_promise_resolver.h" +#include "third_party/blink/renderer/bindings/modules/v8/v8_content_icon_definition.h" #include "third_party/blink/renderer/core/dom/dom_exception.h" #include "third_party/blink/renderer/core/execution_context/execution_context.h" #include "third_party/blink/renderer/modules/content_index/content_description_type_converter.h" -#include "third_party/blink/renderer/modules/content_index/content_icon_definition.h" #include "third_party/blink/renderer/modules/content_index/content_index_icon_loader.h" #include "third_party/blink/renderer/modules/service_worker/service_worker_registration.h" +#include "third_party/blink/renderer/platform/bindings/exception_state.h" #include "third_party/blink/renderer/platform/heap/garbage_collected.h" #include "third_party/blink/renderer/platform/heap/persistent.h" #include "third_party/blink/renderer/platform/weborigin/security_origin.h" @@ -73,21 +74,19 @@ ContentIndex::ContentIndex(ServiceWorkerRegistration* registration, ContentIndex::~ContentIndex() = default; ScriptPromise ContentIndex::add(ScriptState* script_state, - const ContentDescription* description) { + const ContentDescription* description, + ExceptionState& exception_state) { if (!registration_->active()) { - return ScriptPromise::Reject( - script_state, - V8ThrowException::CreateTypeError(script_state->GetIsolate(), - "No active registration available on " - "the ServiceWorkerRegistration.")); + exception_state.ThrowTypeError( + "No active registration available on the ServiceWorkerRegistration."); + return ScriptPromise(); } WTF::String description_error = ValidateDescription(*description, registration_.Get()); if (!description_error.IsNull()) { - return ScriptPromise::Reject( - script_state, V8ThrowException::CreateTypeError( - script_state->GetIsolate(), description_error)); + exception_state.ThrowTypeError(description_error); + return ScriptPromise(); } auto* resolver = MakeGarbageCollected<ScriptPromiseResolver>(script_state); @@ -106,7 +105,7 @@ ScriptPromise ContentIndex::add(ScriptState* script_state, void ContentIndex::DidGetIconSizes( ScriptPromiseResolver* resolver, mojom::blink::ContentDescriptionPtr description, - const Vector<WebSize>& icon_sizes) { + const Vector<gfx::Size>& icon_sizes) { if (!icon_sizes.IsEmpty() && description->icons.IsEmpty()) { ScriptState* script_state = resolver->GetScriptState(); ScriptState::Scope scope(script_state); @@ -176,13 +175,12 @@ void ContentIndex::DidAdd(ScriptPromiseResolver* resolver, } ScriptPromise ContentIndex::deleteDescription(ScriptState* script_state, - const String& id) { + const String& id, + ExceptionState& exception_state) { if (!registration_->active()) { - return ScriptPromise::Reject( - script_state, - V8ThrowException::CreateTypeError(script_state->GetIsolate(), - "No active registration available on " - "the ServiceWorkerRegistration.")); + exception_state.ThrowTypeError( + "No active registration available on the ServiceWorkerRegistration."); + return ScriptPromise(); } auto* resolver = MakeGarbageCollected<ScriptPromiseResolver>(script_state); @@ -221,13 +219,12 @@ void ContentIndex::DidDeleteDescription(ScriptPromiseResolver* resolver, } } -ScriptPromise ContentIndex::getDescriptions(ScriptState* script_state) { +ScriptPromise ContentIndex::getDescriptions(ScriptState* script_state, + ExceptionState& exception_state) { if (!registration_->active()) { - return ScriptPromise::Reject( - script_state, - V8ThrowException::CreateTypeError(script_state->GetIsolate(), - "No active registration available on " - "the ServiceWorkerRegistration.")); + exception_state.ThrowTypeError( + "No active registration available on the ServiceWorkerRegistration."); + return ScriptPromise(); } auto* resolver = MakeGarbageCollected<ScriptPromiseResolver>(script_state); @@ -273,7 +270,7 @@ void ContentIndex::DidGetDescriptions( } } -void ContentIndex::Trace(blink::Visitor* visitor) { +void ContentIndex::Trace(Visitor* visitor) { visitor->Trace(registration_); ScriptWrappable::Trace(visitor); } diff --git a/chromium/third_party/blink/renderer/modules/content_index/content_index.h b/chromium/third_party/blink/renderer/modules/content_index/content_index.h index 49e2ff85628..1394dc2d710 100644 --- a/chromium/third_party/blink/renderer/modules/content_index/content_index.h +++ b/chromium/third_party/blink/renderer/modules/content_index/content_index.h @@ -16,6 +16,7 @@ namespace blink { class ContentDescription; +class ExceptionState; class ScriptPromiseResolver; class ScriptState; class ServiceWorkerRegistration; @@ -30,11 +31,15 @@ class ContentIndex final : public ScriptWrappable { // Web-exposed function defined in the IDL file. ScriptPromise add(ScriptState* script_state, - const ContentDescription* description); - ScriptPromise deleteDescription(ScriptState* script_state, const String& id); - ScriptPromise getDescriptions(ScriptState* script_state); + const ContentDescription* description, + ExceptionState& exception_state); + ScriptPromise deleteDescription(ScriptState* script_state, + const String& id, + ExceptionState& exception_state); + ScriptPromise getDescriptions(ScriptState* script_state, + ExceptionState& exception_state); - void Trace(blink::Visitor* visitor) override; + void Trace(Visitor* visitor) override; private: mojom::blink::ContentIndexService* GetService(); @@ -42,7 +47,7 @@ class ContentIndex final : public ScriptWrappable { // Callbacks. void DidGetIconSizes(ScriptPromiseResolver* resolver, mojom::blink::ContentDescriptionPtr description, - const Vector<WebSize>& icon_sizes); + const Vector<gfx::Size>& icon_sizes); void DidGetIcons(ScriptPromiseResolver* resolver, mojom::blink::ContentDescriptionPtr description, Vector<SkBitmap> icons); diff --git a/chromium/third_party/blink/renderer/modules/content_index/content_index.idl b/chromium/third_party/blink/renderer/modules/content_index/content_index.idl index 8a116d02860..fa954d14963 100644 --- a/chromium/third_party/blink/renderer/modules/content_index/content_index.idl +++ b/chromium/third_party/blink/renderer/modules/content_index/content_index.idl @@ -8,7 +8,7 @@ Exposed=(Window,Worker), RuntimeEnabled=ContentIndex ] interface ContentIndex { - [CallWith=ScriptState, MeasureAs=ContentIndexAdd] Promise<void> add(ContentDescription description); - [CallWith=ScriptState, MeasureAs=ContentIndexDelete, ImplementedAs=deleteDescription] Promise<void> delete(DOMString id); - [CallWith=ScriptState, MeasureAs=ContentIndexGet, ImplementedAs=getDescriptions] Promise<sequence<ContentDescription>> getAll(); -};
\ No newline at end of file + [CallWith=ScriptState, RaisesException, MeasureAs=ContentIndexAdd] Promise<void> add(ContentDescription description); + [CallWith=ScriptState, RaisesException, MeasureAs=ContentIndexDelete, ImplementedAs=deleteDescription] Promise<void> delete(DOMString id); + [CallWith=ScriptState, RaisesException, MeasureAs=ContentIndexGet, ImplementedAs=getDescriptions] Promise<sequence<ContentDescription>> getAll(); +}; diff --git a/chromium/third_party/blink/renderer/modules/content_index/content_index_event.cc b/chromium/third_party/blink/renderer/modules/content_index/content_index_event.cc index 6e5595e7f25..4c38fcb84e4 100644 --- a/chromium/third_party/blink/renderer/modules/content_index/content_index_event.cc +++ b/chromium/third_party/blink/renderer/modules/content_index/content_index_event.cc @@ -4,7 +4,7 @@ #include "third_party/blink/renderer/modules/content_index/content_index_event.h" -#include "third_party/blink/renderer/modules/service_worker/extendable_event_init.h" +#include "third_party/blink/renderer/bindings/modules/v8/v8_extendable_event_init.h" namespace blink { diff --git a/chromium/third_party/blink/renderer/modules/content_index/content_index_event.h b/chromium/third_party/blink/renderer/modules/content_index/content_index_event.h index 53d277df2fc..912389ab49e 100644 --- a/chromium/third_party/blink/renderer/modules/content_index/content_index_event.h +++ b/chromium/third_party/blink/renderer/modules/content_index/content_index_event.h @@ -5,7 +5,7 @@ #ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_CONTENT_INDEX_CONTENT_INDEX_EVENT_H_ #define THIRD_PARTY_BLINK_RENDERER_MODULES_CONTENT_INDEX_CONTENT_INDEX_EVENT_H_ -#include "third_party/blink/renderer/modules/content_index/content_index_event_init.h" +#include "third_party/blink/renderer/bindings/modules/v8/v8_content_index_event_init.h" #include "third_party/blink/renderer/modules/event_modules.h" #include "third_party/blink/renderer/modules/modules_export.h" #include "third_party/blink/renderer/modules/service_worker/extendable_event.h" diff --git a/chromium/third_party/blink/renderer/modules/content_index/content_index_event.idl b/chromium/third_party/blink/renderer/modules/content_index/content_index_event.idl index a7cb4834573..33aa9bffc86 100644 --- a/chromium/third_party/blink/renderer/modules/content_index/content_index_event.idl +++ b/chromium/third_party/blink/renderer/modules/content_index/content_index_event.idl @@ -5,9 +5,9 @@ // https://github.com/rknoll/content-index [ - Constructor(DOMString type, ContentIndexEventInit init), Exposed=ServiceWorker, RuntimeEnabled=ContentIndex ] interface ContentIndexEvent : ExtendableEvent { + constructor(DOMString type, ContentIndexEventInit init); readonly attribute DOMString id; }; diff --git a/chromium/third_party/blink/renderer/modules/content_index/content_index_icon_loader.cc b/chromium/third_party/blink/renderer/modules/content_index/content_index_icon_loader.cc index cd1ea626f1d..aa477aa0e6c 100644 --- a/chromium/third_party/blink/renderer/modules/content_index/content_index_icon_loader.cc +++ b/chromium/third_party/blink/renderer/modules/content_index/content_index_icon_loader.cc @@ -25,10 +25,12 @@ constexpr base::TimeDelta kIconFetchTimeout = base::TimeDelta::FromSeconds(30); void FetchIcon(ExecutionContext* execution_context, const KURL& icon_url, - const WebSize& icon_size, + const gfx::Size& icon_size, ThreadedIconLoader::IconCallback callback) { ResourceRequest resource_request(icon_url); resource_request.SetRequestContext(mojom::RequestContextType::IMAGE); + resource_request.SetRequestDestination( + network::mojom::RequestDestination::kImage); resource_request.SetPriority(ResourceLoadPriority::kMedium); resource_request.SetTimeoutInterval(kIconFetchTimeout); @@ -47,7 +49,7 @@ WebVector<Manifest::ImageResource> ToImageResource( image_resource.type = WebString(icon_definition->type).Utf16(); for (const auto& size : WebIconSizesParser::ParseIconSizes(icon_definition->sizes)) { - image_resource.sizes.emplace_back(size.width, size.height); + image_resource.sizes.emplace_back(size); } if (image_resource.sizes.empty()) image_resource.sizes.emplace_back(0, 0); @@ -58,13 +60,13 @@ WebVector<Manifest::ImageResource> ToImageResource( } KURL FindBestIcon(WebVector<Manifest::ImageResource> image_resources, - const WebSize& icon_size) { + const gfx::Size& icon_size) { return KURL(ManifestIconSelector::FindBestMatchingIcon( image_resources.ReleaseVector(), - /* ideal_icon_height_in_px= */ icon_size.height, + /* ideal_icon_height_in_px= */ icon_size.height(), /* minimum_icon_size_in_px= */ 0, - /* max_width_to_height_ratio= */ icon_size.width * 1.0f / - icon_size.height, + /* max_width_to_height_ratio= */ icon_size.width() * 1.0f / + icon_size.height(), Manifest::ImageResource::Purpose::ANY)); } @@ -75,7 +77,7 @@ ContentIndexIconLoader::ContentIndexIconLoader() = default; void ContentIndexIconLoader::Start( ExecutionContext* execution_context, mojom::blink::ContentDescriptionPtr description, - const Vector<WebSize>& icon_sizes, + const Vector<gfx::Size>& icon_sizes, IconsCallback callback) { DCHECK(!description->icons.IsEmpty()); DCHECK(!icon_sizes.IsEmpty()); diff --git a/chromium/third_party/blink/renderer/modules/content_index/content_index_icon_loader.h b/chromium/third_party/blink/renderer/modules/content_index/content_index_icon_loader.h index 2643f0666ca..da933d03295 100644 --- a/chromium/third_party/blink/renderer/modules/content_index/content_index_icon_loader.h +++ b/chromium/third_party/blink/renderer/modules/content_index/content_index_icon_loader.h @@ -27,7 +27,7 @@ class MODULES_EXPORT ContentIndexIconLoader final void Start(ExecutionContext* execution_context, mojom::blink::ContentDescriptionPtr description, - const Vector<WebSize>& icon_sizes, + const Vector<gfx::Size>& icon_sizes, IconsCallback callback); void Trace(Visitor* visitor) {} diff --git a/chromium/third_party/blink/renderer/modules/content_index/idls.gni b/chromium/third_party/blink/renderer/modules/content_index/idls.gni new file mode 100644 index 00000000000..ecd395aa12d --- /dev/null +++ b/chromium/third_party/blink/renderer/modules/content_index/idls.gni @@ -0,0 +1,19 @@ +# Copyright 2020 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +modules_idl_files = [ + "content_index.idl", + "content_index_event.idl", +] + +modules_dictionary_idl_files = [ + "content_description.idl", + "content_icon_definition.idl", + "content_index_event_init.idl", +] + +modules_dependency_idl_files = [ + "service_worker_global_scope_content_index.idl", + "service_worker_registration_content_index.idl", +] diff --git a/chromium/third_party/blink/renderer/modules/content_index/service_worker_registration_content_index.cc b/chromium/third_party/blink/renderer/modules/content_index/service_worker_registration_content_index.cc index 8cd1fbbd845..e2ebdceb869 100644 --- a/chromium/third_party/blink/renderer/modules/content_index/service_worker_registration_content_index.cc +++ b/chromium/third_party/blink/renderer/modules/content_index/service_worker_registration_content_index.cc @@ -48,7 +48,7 @@ ContentIndex* ServiceWorkerRegistrationContentIndex::index() { return content_index_.Get(); } -void ServiceWorkerRegistrationContentIndex::Trace(blink::Visitor* visitor) { +void ServiceWorkerRegistrationContentIndex::Trace(Visitor* visitor) { visitor->Trace(registration_); visitor->Trace(content_index_); Supplement<ServiceWorkerRegistration>::Trace(visitor); diff --git a/chromium/third_party/blink/renderer/modules/content_index/service_worker_registration_content_index.h b/chromium/third_party/blink/renderer/modules/content_index/service_worker_registration_content_index.h index 7852ebacc0f..49e3a83c829 100644 --- a/chromium/third_party/blink/renderer/modules/content_index/service_worker_registration_content_index.h +++ b/chromium/third_party/blink/renderer/modules/content_index/service_worker_registration_content_index.h @@ -32,7 +32,7 @@ class ServiceWorkerRegistrationContentIndex final static ContentIndex* index(ServiceWorkerRegistration& registration); ContentIndex* index(); - void Trace(blink::Visitor* visitor) override; + void Trace(Visitor* visitor) override; private: Member<ServiceWorkerRegistration> registration_; |