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

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: correct file changes 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 1026 matching lines...) Expand 10 before | Expand all | Expand 10 after
1037 callback.Run(status); 1037 callback.Run(status);
1038 } 1038 }
1039 1039
1040 void ServiceWorkerVersion::CountFeature(uint32_t feature) { 1040 void ServiceWorkerVersion::CountFeature(uint32_t feature) {
1041 if (!used_features_.insert(feature).second) 1041 if (!used_features_.insert(feature).second)
1042 return; 1042 return;
1043 for (auto provider_host_by_uuid : controllee_map_) 1043 for (auto provider_host_by_uuid : controllee_map_)
1044 provider_host_by_uuid.second->CountFeature(feature); 1044 provider_host_by_uuid.second->CountFeature(feature);
1045 } 1045 }
1046 1046
1047 void ServiceWorkerVersion::OnOpenWindow(int request_id, GURL url) { 1047 void ServiceWorkerVersion::OnOpenWindow(int request_id,
1048 GURL redirect_url,
1049 GURL url_to_open) {
1048 // Just abort if we are shutting down. 1050 // Just abort if we are shutting down.
1049 if (!context_) 1051 if (!context_)
1050 return; 1052 return;
1051 1053
1052 if (!url.is_valid()) { 1054 if (!url_to_open.is_valid()) {
1053 DVLOG(1) << "Received unexpected invalid URL from renderer process."; 1055 DVLOG(1) << "Received unexpected invalid URL from renderer process.";
1054 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, 1056 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
1055 base::Bind(&KillEmbeddedWorkerProcess, 1057 base::Bind(&KillEmbeddedWorkerProcess,
1056 embedded_worker_->process_id(), 1058 embedded_worker_->process_id(),
1057 RESULT_CODE_KILLED_BAD_MESSAGE)); 1059 RESULT_CODE_KILLED_BAD_MESSAGE));
1058 return; 1060 return;
1059 } 1061 }
1060 1062
1061 // The renderer treats all URLs in the about: scheme as being about:blank. 1063 // The renderer treats all URLs in the about: scheme as being about:blank.
1062 // Canonicalize about: URLs to about:blank. 1064 // Canonicalize about: URLs to about:blank.
1063 if (url.SchemeIs(url::kAboutScheme)) 1065 if (url_to_open.SchemeIs(url::kAboutScheme))
1064 url = GURL(url::kAboutBlankURL); 1066 url_to_open = GURL(url::kAboutBlankURL);
1065 1067
1066 // Reject requests for URLs that the process is not allowed to access. It's 1068 // Reject requests for URLs that the process is not allowed to access. It's
1067 // possible to receive such requests since the renderer-side checks are 1069 // possible to receive such requests since the renderer-side checks are
1068 // slightly different. For example, the view-source scheme will not be 1070 // slightly different. For example, the view-source scheme will not be
1069 // filtered out by Blink. 1071 // filtered out by Blink.
1070 if (!ChildProcessSecurityPolicyImpl::GetInstance()->CanRequestURL( 1072 if (!ChildProcessSecurityPolicyImpl::GetInstance()->CanRequestURL(
1071 embedded_worker_->process_id(), url)) { 1073 embedded_worker_->process_id(), url_to_open)) {
1072 embedded_worker_->SendMessage(ServiceWorkerMsg_OpenWindowError( 1074 embedded_worker_->SendMessage(ServiceWorkerMsg_OpenWindowError(
1073 request_id, url.spec() + " cannot be opened.")); 1075 request_id, url_to_open.spec() + " cannot be opened."));
1074 return; 1076 return;
1075 } 1077 }
1076 1078
1077 service_worker_client_utils::OpenWindow( 1079 service_worker_client_utils::OpenWindow(
1078 url, script_url_, embedded_worker_->process_id(), context_, 1080 redirect_url, url_to_open, script_url_, embedded_worker_->process_id(),
1081 context_,
1079 base::Bind(&ServiceWorkerVersion::OnOpenWindowFinished, 1082 base::Bind(&ServiceWorkerVersion::OnOpenWindowFinished,
1080 weak_factory_.GetWeakPtr(), request_id)); 1083 weak_factory_.GetWeakPtr(), request_id));
1081 } 1084 }
1082 1085
1083 void ServiceWorkerVersion::OnOpenWindowFinished( 1086 void ServiceWorkerVersion::OnOpenWindowFinished(
1084 int request_id, 1087 int request_id,
1085 ServiceWorkerStatusCode status, 1088 ServiceWorkerStatusCode status,
1086 const ServiceWorkerClientInfo& client_info) { 1089 const ServiceWorkerClientInfo& client_info) {
1087 DCHECK_CURRENTLY_ON(BrowserThread::IO); 1090 DCHECK_CURRENTLY_ON(BrowserThread::IO);
1088 1091
(...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after
1818 1821
1819 void ServiceWorkerVersion::CleanUpExternalRequest( 1822 void ServiceWorkerVersion::CleanUpExternalRequest(
1820 const std::string& request_uuid, 1823 const std::string& request_uuid,
1821 ServiceWorkerStatusCode status) { 1824 ServiceWorkerStatusCode status) {
1822 if (status == SERVICE_WORKER_OK) 1825 if (status == SERVICE_WORKER_OK)
1823 return; 1826 return;
1824 external_request_uuid_to_request_id_.erase(request_uuid); 1827 external_request_uuid_to_request_id_.erase(request_uuid);
1825 } 1828 }
1826 1829
1827 } // namespace content 1830 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698