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

Side by Side Diff: content/browser/permissions/permission_service_impl.cc

Issue 750633003: Implement HasPermission() method in PermissionService. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixed comments, switched to use BrowserContext, passing PermissionStatus in callback Created 6 years 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/permissions/permission_service_impl.h" 5 #include "content/browser/permissions/permission_service_impl.h"
6 6
7 #include "content/browser/geolocation/geolocation_provider_impl.h" 7 #include "content/browser/geolocation/geolocation_provider_impl.h"
8 #include "content/public/browser/content_browser_client.h" 8 #include "content/public/browser/content_browser_client.h"
9 #include "content/public/browser/render_process_host.h" 9 #include "content/public/browser/render_process_host.h"
10 #include "content/public/browser/web_contents.h"
10 11
11 namespace content { 12 namespace content {
12 13
13 namespace { 14 namespace {
14 15
15 PermissionType PermissionNameToPermissionType(PermissionName name) { 16 PermissionType PermissionNameToPermissionType(PermissionName name) {
16 switch(name) { 17 switch(name) {
17 case PERMISSION_NAME_GEOLOCATION: 18 case PERMISSION_NAME_GEOLOCATION:
18 return PERMISSION_GEOLOCATION; 19 return PERMISSION_GEOLOCATION;
19 } 20 }
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 it.GetCurrentValue()->origin); 108 it.GetCurrentValue()->origin);
108 } 109 }
109 110
110 pending_requests_.Clear(); 111 pending_requests_.Clear();
111 } 112 }
112 113
113 void PermissionServiceImpl::HasPermission( 114 void PermissionServiceImpl::HasPermission(
114 PermissionName permission, 115 PermissionName permission,
115 const mojo::String& origin, 116 const mojo::String& origin,
116 const mojo::Callback<void(PermissionStatus)>& callback) { 117 const mojo::Callback<void(PermissionStatus)>& callback) {
117 NOTIMPLEMENTED(); 118 DCHECK(context_->GetBrowserContext());
119
120 // If there is no web_contents() we use |origin| as the embedding_origin.
121 GURL embedding_origin = context_->web_contents()
122 ? context_->web_contents()->GetLastCommittedURL().GetOrigin()
123 : GURL(origin);
mlamouri (slow - plz ping) 2014/11/24 19:06:01 I think it would be better to have a PermissionSer
timvolodine 2014/11/27 17:53:42 done. but we still need the |origin| so cannot mov
124
125 GetContentClient()->browser()->HasPermission(
126 PermissionNameToPermissionType(permission),
127 context_->GetBrowserContext(),
128 GURL(origin),
129 embedding_origin,
130 base::Bind(&PermissionServiceImpl::OnHasPermissionResponse,
131 weak_factory_.GetWeakPtr(),
132 callback));
133 }
134
135 void PermissionServiceImpl::OnHasPermissionResponse(
136 const mojo::Callback<void(PermissionStatus)>& callback,
137 PermissionStatus content_setting) {
138 callback.Run(content_setting);
mlamouri (slow - plz ping) 2014/11/24 19:06:01 nit: s/content_setting/permission_status/
timvolodine 2014/11/27 17:53:42 Done.
118 } 139 }
119 140
120 } // namespace content 141 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698