Skip to content

Commit

Permalink
PaymentApp: Add interfaces for implementing InvokePaymentApp().
Browse files Browse the repository at this point in the history
This CL adds basic interfaces(including mojom) in renderer and browser in order
to implement InvokePaymentApp(). The interfaces will actually be implemented in
https://crrev.com/2610163002.

BUG=661608

Review-Url: https://codereview.chromium.org/2615063002
Cr-Commit-Position: refs/heads/master@{#442515}
  • Loading branch information
romandev authored and Commit bot committed Jan 10, 2017
1 parent eb5e406 commit 1cc5c53
Show file tree
Hide file tree
Showing 13 changed files with 55 additions and 0 deletions.
2 changes: 2 additions & 0 deletions components/payments/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ mojom("payment_app") {
]

public_deps = [
":payment_request",
"//mojo/common:common_custom_types",
"//url/mojo:url_mojom_gurl",
]
}

Expand Down
11 changes: 11 additions & 0 deletions components/payments/payment_app.mojom
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

module payments.mojom;

import "components/payments/payment_request.mojom";
import "url/mojo/url.mojom";

enum PaymentAppManifestError {
NONE,
NOT_IMPLEMENTED,
Expand Down Expand Up @@ -31,3 +34,11 @@ interface PaymentAppManager {
GetManifest()
=> (PaymentAppManifest payment_app_manifest, PaymentAppManifestError error);
};

struct PaymentAppRequestData {
url.mojom.Url origin;
array<PaymentMethodData> methodData;
PaymentItem total;
array<PaymentDetailsModifier> modifiers;
string optionId;
};
7 changes: 7 additions & 0 deletions content/browser/payments/payment_app_provider_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ void PaymentAppProviderImpl::GetAllManifests(
base::Bind(&GetAllManifestsOnIO, payment_app_context, callback));
}

void PaymentAppProviderImpl::InvokePaymentApp(
BrowserContext* browser_context,
int64_t registration_id,
payments::mojom::PaymentAppRequestDataPtr data) {
NOTIMPLEMENTED();
}

PaymentAppProviderImpl::PaymentAppProviderImpl() {}

PaymentAppProviderImpl::~PaymentAppProviderImpl() {}
Expand Down
4 changes: 4 additions & 0 deletions content/browser/payments/payment_app_provider_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ class CONTENT_EXPORT PaymentAppProviderImpl : public PaymentAppProvider {
// Should be accessed only on the UI thread.
void GetAllManifests(BrowserContext* browser_context,
const GetAllManifestsCallback& callback) override;
void InvokePaymentApp(
BrowserContext* browser_context,
int64_t registration_id,
payments::mojom::PaymentAppRequestDataPtr data) override;

private:
PaymentAppProviderImpl();
Expand Down
6 changes: 6 additions & 0 deletions content/browser/service_worker/embedded_worker_test_helper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,12 @@ class EmbeddedWorkerTestHelper::MockServiceWorkerEventDispatcher
NOTIMPLEMENTED();
}

void DispatchPaymentRequestEvent(
payments::mojom::PaymentAppRequestDataPtr data,
const DispatchPaymentRequestEventCallback& callback) override {
NOTIMPLEMENTED();
}

void DispatchExtendableMessageEvent(
mojom::ExtendableMessageEventPtr event,
const DispatchExtendableMessageEventCallback& callback) override {
Expand Down
1 change: 1 addition & 0 deletions content/common/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@ source_set("common") {
"//cc/ipc",
"//cc/surfaces",
"//components/discardable_memory/common",
"//components/payments:payment_app",
"//components/tracing",
"//components/tracing:startup_tracing",
"//content:resources",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

module content.mojom;

import "components/payments/payment_app.mojom";
import "content/common/url_loader.mojom";
import "mojo/common/string16.mojom";
import "mojo/common/time.mojom";
Expand Down Expand Up @@ -45,6 +46,9 @@ interface ServiceWorkerEventDispatcher {
blink.mojom.BackgroundSyncEventLastChance last_chance)
=> (blink.mojom.ServiceWorkerEventStatus status,
mojo.common.mojom.Time dispatch_event_time);
DispatchPaymentRequestEvent(payments.mojom.PaymentAppRequestData data)
=> (blink.mojom.ServiceWorkerEventStatus status,
mojo.common.mojom.Time dispatch_event_time);
DispatchExtendableMessageEvent(ExtendableMessageEvent event)
=> (blink.mojom.ServiceWorkerEventStatus status,
mojo.common.mojom.Time dispatch_event_time);
Expand Down
4 changes: 4 additions & 0 deletions content/public/browser/payment_app_provider.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ class CONTENT_EXPORT PaymentAppProvider {
// Should be accessed only on the UI thread.
virtual void GetAllManifests(BrowserContext* browser_context,
const GetAllManifestsCallback& callback) = 0;
virtual void InvokePaymentApp(
BrowserContext* browser_context,
int64_t registration_id,
payments::mojom::PaymentAppRequestDataPtr data) = 0;

protected:
virtual ~PaymentAppProvider() {}
Expand Down
1 change: 1 addition & 0 deletions content/renderer/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@ target(link_target_type, "renderer") {
"//cc/surfaces:surface_id",
"//cc/surfaces:surfaces",
"//components/discardable_memory/client",
"//components/payments:payment_app",
"//components/url_formatter",
"//content:resources",
"//content/child",
Expand Down
1 change: 1 addition & 0 deletions content/renderer/DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ include_rules = [
# Allow inclusion of specific components that we depend on.
# See comment in content/DEPS for which components are allowed.
"+components/discardable_memory/client",
"+components/payments",
"+components/scheduler",
"+components/url_formatter",

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -904,6 +904,12 @@ void ServiceWorkerContextClient::DispatchSyncEvent(
web_last_chance);
}

void ServiceWorkerContextClient::DispatchPaymentRequestEvent(
payments::mojom::PaymentAppRequestDataPtr data,
const DispatchPaymentRequestEventCallback& callback) {
NOTIMPLEMENTED();
}

void ServiceWorkerContextClient::Send(IPC::Message* message) {
sender_->Send(message);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "base/memory/ref_counted.h"
#include "base/strings/string16.h"
#include "base/time/time.h"
#include "components/payments/payment_app.mojom.h"
#include "content/child/webmessageportchannel_impl.h"
#include "content/common/service_worker/service_worker_event_dispatcher.mojom.h"
#include "content/common/service_worker/service_worker_status_code.h"
Expand Down Expand Up @@ -68,6 +69,9 @@ class ServiceWorkerContextClient : public blink::WebServiceWorkerContextClient,
using SyncCallback =
base::Callback<void(ServiceWorkerStatusCode,
base::Time /* dispatch_event_time */)>;
using PaymentRequestEventCallback =
base::Callback<void(ServiceWorkerStatusCode,
base::Time /* dispatch_event_time */)>;
using FetchCallback =
base::Callback<void(ServiceWorkerStatusCode,
base::Time /* dispatch_event_time */)>;
Expand Down Expand Up @@ -224,6 +228,9 @@ class ServiceWorkerContextClient : public blink::WebServiceWorkerContextClient,
const std::string& tag,
blink::mojom::BackgroundSyncEventLastChance last_chance,
const DispatchSyncEventCallback& callback) override;
void DispatchPaymentRequestEvent(
payments::mojom::PaymentAppRequestDataPtr data,
const DispatchPaymentRequestEventCallback& callback) override;

void OnActivateEvent(int request_id);
void OnInstallEvent(int request_id);
Expand Down
1 change: 1 addition & 0 deletions content/test/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -1406,6 +1406,7 @@ test("content_unittests") {
"//components/display_compositor",
"//components/leveldb/public/cpp",
"//components/payments:payment_app",
"//components/payments:payment_request",
"//components/rappor:test_support",
"//content:resources",
"//content/app:both_for_content_tests",
Expand Down

0 comments on commit 1cc5c53

Please sign in to comment.