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

Side by Side Diff: chrome/browser/geolocation/chrome_geolocation_permission_context.cc

Issue 235633002: <webview>: Move Geolocation permission to chrome layer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More cleanup + Updated UMA Created 6 years, 8 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
« no previous file with comments | « no previous file | chrome/browser/guestview/guestview_constants.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/geolocation/chrome_geolocation_permission_context.h" 5 #include "chrome/browser/geolocation/chrome_geolocation_permission_context.h"
6 6
7 #include <functional> 7 #include <functional>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/prefs/pref_service.h" 12 #include "base/prefs/pref_service.h"
13 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
14 #include "chrome/browser/content_settings/host_content_settings_map.h" 14 #include "chrome/browser/content_settings/host_content_settings_map.h"
15 #include "chrome/browser/content_settings/permission_request_id.h" 15 #include "chrome/browser/content_settings/permission_request_id.h"
16 #include "chrome/browser/content_settings/tab_specific_content_settings.h" 16 #include "chrome/browser/content_settings/tab_specific_content_settings.h"
17 #include "chrome/browser/extensions/suggest_permission_util.h" 17 #include "chrome/browser/extensions/suggest_permission_util.h"
18 #include "chrome/browser/guestview/webview/webview_guest.h"
18 #include "chrome/browser/profiles/profile.h" 19 #include "chrome/browser/profiles/profile.h"
19 #include "chrome/browser/tab_contents/tab_util.h" 20 #include "chrome/browser/tab_contents/tab_util.h"
20 #include "chrome/browser/ui/website_settings/permission_bubble_manager.h" 21 #include "chrome/browser/ui/website_settings/permission_bubble_manager.h"
21 #include "chrome/browser/ui/website_settings/permission_bubble_request.h" 22 #include "chrome/browser/ui/website_settings/permission_bubble_request.h"
22 #include "chrome/common/pref_names.h" 23 #include "chrome/common/pref_names.h"
23 #include "content/public/browser/browser_thread.h" 24 #include "content/public/browser/browser_thread.h"
24 #include "content/public/browser/render_view_host.h" 25 #include "content/public/browser/render_view_host.h"
25 #include "content/public/browser/web_contents.h" 26 #include "content/public/browser/web_contents.h"
26 #include "extensions/browser/extension_registry.h" 27 #include "extensions/browser/extension_registry.h"
27 #include "extensions/browser/process_map.h" 28 #include "extensions/browser/process_map.h"
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 requesting_frame_origin, user_gesture, callback)); 151 requesting_frame_origin, user_gesture, callback));
151 return; 152 return;
152 } 153 }
153 154
154 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 155 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
155 if (shutting_down_) 156 if (shutting_down_)
156 return; 157 return;
157 158
158 content::WebContents* web_contents = 159 content::WebContents* web_contents =
159 tab_util::GetWebContentsByID(render_process_id, render_view_id); 160 tab_util::GetWebContentsByID(render_process_id, render_view_id);
161
162 WebViewGuest* guest = WebViewGuest::FromWebContents(web_contents);
lazyboy 2014/04/11 19:27:06 The guest specialization code lying here seems mes
163 if (guest) {
164 guest->RequestGeolocationPermission(bridge_id,
165 requesting_frame,
166 user_gesture,
167 callback);
168 return;
169 }
160 const PermissionRequestID id(render_process_id, render_view_id, bridge_id, 0); 170 const PermissionRequestID id(render_process_id, render_view_id, bridge_id, 0);
161 ExtensionRegistry* extension_registry = ExtensionRegistry::Get(profile_); 171 ExtensionRegistry* extension_registry = ExtensionRegistry::Get(profile_);
162 if (extension_registry) { 172 if (extension_registry) {
163 const extensions::Extension* extension = 173 const extensions::Extension* extension =
164 extension_registry->enabled_extensions().GetExtensionOrAppByURL( 174 extension_registry->enabled_extensions().GetExtensionOrAppByURL(
165 requesting_frame_origin); 175 requesting_frame_origin);
166 if (IsExtensionWithPermissionOrSuggestInConsole(APIPermission::kGeolocation, 176 if (IsExtensionWithPermissionOrSuggestInConsole(APIPermission::kGeolocation,
167 extension, 177 extension,
168 profile_)) { 178 profile_)) {
169 // Make sure the extension is in the calling process. 179 // Make sure the extension is in the calling process.
(...skipping 29 matching lines...) Expand all
199 209
200 DecidePermission(web_contents, id, requesting_frame_origin, user_gesture, 210 DecidePermission(web_contents, id, requesting_frame_origin, user_gesture,
201 embedder, "", callback); 211 embedder, "", callback);
202 } 212 }
203 213
204 void ChromeGeolocationPermissionContext::CancelGeolocationPermissionRequest( 214 void ChromeGeolocationPermissionContext::CancelGeolocationPermissionRequest(
205 int render_process_id, 215 int render_process_id,
206 int render_view_id, 216 int render_view_id,
207 int bridge_id, 217 int bridge_id,
208 const GURL& requesting_frame) { 218 const GURL& requesting_frame) {
219 content::WebContents* web_contents =
220 tab_util::GetWebContentsByID(render_process_id, render_view_id);
221 WebViewGuest* guest =
222 web_contents ? WebViewGuest::FromWebContents(web_contents) : NULL;
223 if (guest) {
224 guest->CancelGeolocationPermissionRequest(bridge_id);
225 return;
226 }
209 // TODO(gbillock): cancel permission bubble request. 227 // TODO(gbillock): cancel permission bubble request.
210 CancelPendingInfobarRequest(PermissionRequestID( 228 CancelPendingInfobarRequest(PermissionRequestID(
211 render_process_id, render_view_id, bridge_id, 0)); 229 render_process_id, render_view_id, bridge_id, 0));
212 } 230 }
213 231
214 void ChromeGeolocationPermissionContext::DecidePermission( 232 void ChromeGeolocationPermissionContext::DecidePermission(
215 content::WebContents* web_contents, 233 content::WebContents* web_contents,
216 const PermissionRequestID& id, 234 const PermissionRequestID& id,
217 const GURL& requesting_frame, 235 const GURL& requesting_frame,
218 bool user_gesture, 236 bool user_gesture,
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 this, id)); 340 this, id));
323 return; 341 return;
324 } 342 }
325 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 343 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
326 if (shutting_down_) 344 if (shutting_down_)
327 return; 345 return;
328 346
329 // TODO(gbillock): handle permission bubble cancellation. 347 // TODO(gbillock): handle permission bubble cancellation.
330 QueueController()->CancelInfoBarRequest(id); 348 QueueController()->CancelInfoBarRequest(id);
331 } 349 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/guestview/guestview_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698