Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(103)

Side by Side Diff: content/browser/service_worker/service_worker_version.cc

Issue 2893823004: [Payments] Implement openWindow for service worker based payment handler (Closed)
Patch Set: use popup window for payment handler Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/service_worker/service_worker_version.h" 5 #include "content/browser/service_worker/service_worker_version.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <limits> 9 #include <limits>
10 #include <map> 10 #include <map>
(...skipping 908 matching lines...) Expand 10 before | Expand all | Expand 10 after
919 message, line_number, source_url); 919 message, line_number, source_url);
920 } 920 }
921 } 921 }
922 922
923 bool ServiceWorkerVersion::OnMessageReceived(const IPC::Message& message) { 923 bool ServiceWorkerVersion::OnMessageReceived(const IPC::Message& message) {
924 bool handled = true; 924 bool handled = true;
925 IPC_BEGIN_MESSAGE_MAP(ServiceWorkerVersion, message) 925 IPC_BEGIN_MESSAGE_MAP(ServiceWorkerVersion, message)
926 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_GetClient, OnGetClient) 926 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_GetClient, OnGetClient)
927 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_GetClients, 927 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_GetClients,
928 OnGetClients) 928 OnGetClients)
929 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_OpenWindow, 929 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_OpenWindowForClients,
930 OnOpenWindow) 930 OnOpenWindowForClients)
931 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_OpenWindowForPaymentHandler,
please use gerrit instead 2017/06/02 03:43:17 Excellent!
gogerald1 2017/06/02 13:21:40 Acknowledged.
932 OnOpenWindowForPaymentHandler)
931 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_SetCachedMetadata, 933 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_SetCachedMetadata,
932 OnSetCachedMetadata) 934 OnSetCachedMetadata)
933 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_ClearCachedMetadata, 935 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_ClearCachedMetadata,
934 OnClearCachedMetadata) 936 OnClearCachedMetadata)
935 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_PostMessageToClient, 937 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_PostMessageToClient,
936 OnPostMessageToClient) 938 OnPostMessageToClient)
937 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_FocusClient, 939 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_FocusClient,
938 OnFocusClient) 940 OnFocusClient)
939 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_NavigateClient, OnNavigateClient) 941 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_NavigateClient, OnNavigateClient)
940 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_SkipWaiting, 942 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_SkipWaiting,
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
1037 callback.Run(status); 1039 callback.Run(status);
1038 } 1040 }
1039 1041
1040 void ServiceWorkerVersion::CountFeature(uint32_t feature) { 1042 void ServiceWorkerVersion::CountFeature(uint32_t feature) {
1041 if (!used_features_.insert(feature).second) 1043 if (!used_features_.insert(feature).second)
1042 return; 1044 return;
1043 for (auto provider_host_by_uuid : controllee_map_) 1045 for (auto provider_host_by_uuid : controllee_map_)
1044 provider_host_by_uuid.second->CountFeature(feature); 1046 provider_host_by_uuid.second->CountFeature(feature);
1045 } 1047 }
1046 1048
1047 void ServiceWorkerVersion::OnOpenWindow(int request_id, GURL url) { 1049 void ServiceWorkerVersion::OnOpenWindowForClients(int request_id, GURL url) {
1050 OnOpenWindow(request_id, url, WindowOpenDisposition::NEW_FOREGROUND_TAB);
1051 }
1052
1053 void ServiceWorkerVersion::OnOpenWindowForPaymentHandler(int request_id,
1054 GURL url) {
1055 // Open popup window for payment handler.
1056 OnOpenWindow(request_id, url, WindowOpenDisposition::NEW_POPUP);
1057 }
1058
1059 void ServiceWorkerVersion::OnOpenWindow(int request_id,
1060 GURL url,
1061 WindowOpenDisposition disposition) {
1048 // Just abort if we are shutting down. 1062 // Just abort if we are shutting down.
1049 if (!context_) 1063 if (!context_)
1050 return; 1064 return;
1051 1065
1052 if (!url.is_valid()) { 1066 if (!url.is_valid()) {
1053 DVLOG(1) << "Received unexpected invalid URL from renderer process."; 1067 DVLOG(1) << "Received unexpected invalid URL from renderer process.";
1054 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, 1068 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
1055 base::Bind(&KillEmbeddedWorkerProcess, 1069 base::Bind(&KillEmbeddedWorkerProcess,
1056 embedded_worker_->process_id(), 1070 embedded_worker_->process_id(),
1057 RESULT_CODE_KILLED_BAD_MESSAGE)); 1071 RESULT_CODE_KILLED_BAD_MESSAGE));
(...skipping 10 matching lines...) Expand all
1068 // slightly different. For example, the view-source scheme will not be 1082 // slightly different. For example, the view-source scheme will not be
1069 // filtered out by Blink. 1083 // filtered out by Blink.
1070 if (!ChildProcessSecurityPolicyImpl::GetInstance()->CanRequestURL( 1084 if (!ChildProcessSecurityPolicyImpl::GetInstance()->CanRequestURL(
1071 embedded_worker_->process_id(), url)) { 1085 embedded_worker_->process_id(), url)) {
1072 embedded_worker_->SendMessage(ServiceWorkerMsg_OpenWindowError( 1086 embedded_worker_->SendMessage(ServiceWorkerMsg_OpenWindowError(
1073 request_id, url.spec() + " cannot be opened.")); 1087 request_id, url.spec() + " cannot be opened."));
1074 return; 1088 return;
1075 } 1089 }
1076 1090
1077 service_worker_client_utils::OpenWindow( 1091 service_worker_client_utils::OpenWindow(
1078 url, script_url_, embedded_worker_->process_id(), context_, 1092 url, script_url_, embedded_worker_->process_id(), context_, disposition,
1079 base::Bind(&ServiceWorkerVersion::OnOpenWindowFinished, 1093 base::Bind(&ServiceWorkerVersion::OnOpenWindowFinished,
1080 weak_factory_.GetWeakPtr(), request_id)); 1094 weak_factory_.GetWeakPtr(), request_id));
1081 } 1095 }
1082 1096
1083 void ServiceWorkerVersion::OnOpenWindowFinished( 1097 void ServiceWorkerVersion::OnOpenWindowFinished(
1084 int request_id, 1098 int request_id,
1085 ServiceWorkerStatusCode status, 1099 ServiceWorkerStatusCode status,
1086 const ServiceWorkerClientInfo& client_info) { 1100 const ServiceWorkerClientInfo& client_info) {
1087 DCHECK_CURRENTLY_ON(BrowserThread::IO); 1101 DCHECK_CURRENTLY_ON(BrowserThread::IO);
1088 1102
(...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after
1818 1832
1819 void ServiceWorkerVersion::CleanUpExternalRequest( 1833 void ServiceWorkerVersion::CleanUpExternalRequest(
1820 const std::string& request_uuid, 1834 const std::string& request_uuid,
1821 ServiceWorkerStatusCode status) { 1835 ServiceWorkerStatusCode status) {
1822 if (status == SERVICE_WORKER_OK) 1836 if (status == SERVICE_WORKER_OK)
1823 return; 1837 return;
1824 external_request_uuid_to_request_id_.erase(request_uuid); 1838 external_request_uuid_to_request_id_.erase(request_uuid);
1825 } 1839 }
1826 1840
1827 } // namespace content 1841 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698