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

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 CompleteURL 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 909 matching lines...) Expand 10 before | Expand all | Expand 10 after
920 message, line_number, source_url); 920 message, line_number, source_url);
921 } 921 }
922 } 922 }
923 923
924 bool ServiceWorkerVersion::OnMessageReceived(const IPC::Message& message) { 924 bool ServiceWorkerVersion::OnMessageReceived(const IPC::Message& message) {
925 bool handled = true; 925 bool handled = true;
926 IPC_BEGIN_MESSAGE_MAP(ServiceWorkerVersion, message) 926 IPC_BEGIN_MESSAGE_MAP(ServiceWorkerVersion, message)
927 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_GetClient, OnGetClient) 927 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_GetClient, OnGetClient)
928 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_GetClients, 928 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_GetClients,
929 OnGetClients) 929 OnGetClients)
930 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_OpenWindow, 930 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_OpenWindowForClients,
931 OnOpenWindow) 931 OnOpenWindowForClients)
932 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_OpenWindowForPaymentHandler,
933 OnOpenWindowForPaymentHandler)
932 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_SetCachedMetadata, 934 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_SetCachedMetadata,
933 OnSetCachedMetadata) 935 OnSetCachedMetadata)
934 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_ClearCachedMetadata, 936 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_ClearCachedMetadata,
935 OnClearCachedMetadata) 937 OnClearCachedMetadata)
936 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_PostMessageToClient, 938 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_PostMessageToClient,
937 OnPostMessageToClient) 939 OnPostMessageToClient)
938 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_FocusClient, 940 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_FocusClient,
939 OnFocusClient) 941 OnFocusClient)
940 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_NavigateClient, OnNavigateClient) 942 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_NavigateClient, OnNavigateClient)
941 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_SkipWaiting, 943 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_SkipWaiting,
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
1038 callback.Run(status); 1040 callback.Run(status);
1039 } 1041 }
1040 1042
1041 void ServiceWorkerVersion::CountFeature(uint32_t feature) { 1043 void ServiceWorkerVersion::CountFeature(uint32_t feature) {
1042 if (!used_features_.insert(feature).second) 1044 if (!used_features_.insert(feature).second)
1043 return; 1045 return;
1044 for (auto provider_host_by_uuid : controllee_map_) 1046 for (auto provider_host_by_uuid : controllee_map_)
1045 provider_host_by_uuid.second->CountFeature(feature); 1047 provider_host_by_uuid.second->CountFeature(feature);
1046 } 1048 }
1047 1049
1048 void ServiceWorkerVersion::OnOpenWindow(int request_id, GURL url) { 1050 void ServiceWorkerVersion::OnOpenWindowForClients(int request_id, GURL url) {
1051 OnOpenWindow(request_id, url, WindowOpenDisposition::NEW_FOREGROUND_TAB);
1052 }
1053
1054 void ServiceWorkerVersion::OnOpenWindowForPaymentHandler(int request_id,
1055 GURL url) {
1056 OnOpenWindow(request_id, url, WindowOpenDisposition::NEW_POPUP);
1057 }
1058
1059 void ServiceWorkerVersion::OnOpenWindow(int request_id,
1060 GURL url,
1061 WindowOpenDisposition disposition) {
1049 // Just abort if we are shutting down. 1062 // Just abort if we are shutting down.
1050 if (!context_) 1063 if (!context_)
1051 return; 1064 return;
1052 1065
1053 if (!url.is_valid()) { 1066 if (!url.is_valid()) {
1054 DVLOG(1) << "Received unexpected invalid URL from renderer process."; 1067 DVLOG(1) << "Received unexpected invalid URL from renderer process.";
1055 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, 1068 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
1056 base::Bind(&KillEmbeddedWorkerProcess, 1069 base::Bind(&KillEmbeddedWorkerProcess,
1057 embedded_worker_->process_id(), 1070 embedded_worker_->process_id(),
1058 RESULT_CODE_KILLED_BAD_MESSAGE)); 1071 RESULT_CODE_KILLED_BAD_MESSAGE));
(...skipping 10 matching lines...) Expand all
1069 // slightly different. For example, the view-source scheme will not be 1082 // slightly different. For example, the view-source scheme will not be
1070 // filtered out by Blink. 1083 // filtered out by Blink.
1071 if (!ChildProcessSecurityPolicyImpl::GetInstance()->CanRequestURL( 1084 if (!ChildProcessSecurityPolicyImpl::GetInstance()->CanRequestURL(
1072 embedded_worker_->process_id(), url)) { 1085 embedded_worker_->process_id(), url)) {
1073 embedded_worker_->SendMessage(ServiceWorkerMsg_OpenWindowError( 1086 embedded_worker_->SendMessage(ServiceWorkerMsg_OpenWindowError(
1074 request_id, url.spec() + " cannot be opened.")); 1087 request_id, url.spec() + " cannot be opened."));
1075 return; 1088 return;
1076 } 1089 }
1077 1090
1078 service_worker_client_utils::OpenWindow( 1091 service_worker_client_utils::OpenWindow(
1079 url, script_url_, embedded_worker_->process_id(), context_, 1092 url, script_url_, embedded_worker_->process_id(), context_, disposition,
1080 base::Bind(&ServiceWorkerVersion::OnOpenWindowFinished, 1093 base::Bind(&ServiceWorkerVersion::OnOpenWindowFinished,
1081 weak_factory_.GetWeakPtr(), request_id)); 1094 weak_factory_.GetWeakPtr(), request_id));
1082 } 1095 }
1083 1096
1084 void ServiceWorkerVersion::OnOpenWindowFinished( 1097 void ServiceWorkerVersion::OnOpenWindowFinished(
1085 int request_id, 1098 int request_id,
1086 ServiceWorkerStatusCode status, 1099 ServiceWorkerStatusCode status,
1087 const ServiceWorkerClientInfo& client_info) { 1100 const ServiceWorkerClientInfo& client_info) {
1088 DCHECK_CURRENTLY_ON(BrowserThread::IO); 1101 DCHECK_CURRENTLY_ON(BrowserThread::IO);
1089 1102
(...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after
1819 1832
1820 void ServiceWorkerVersion::CleanUpExternalRequest( 1833 void ServiceWorkerVersion::CleanUpExternalRequest(
1821 const std::string& request_uuid, 1834 const std::string& request_uuid,
1822 ServiceWorkerStatusCode status) { 1835 ServiceWorkerStatusCode status) {
1823 if (status == SERVICE_WORKER_OK) 1836 if (status == SERVICE_WORKER_OK)
1824 return; 1837 return;
1825 external_request_uuid_to_request_id_.erase(request_uuid); 1838 external_request_uuid_to_request_id_.erase(request_uuid);
1826 } 1839 }
1827 1840
1828 } // namespace content 1841 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698