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

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

Powered by Google App Engine
This is Rietveld 408576698