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

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

Issue 1726323002: Have Permission{Manager,Service} use Origin. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 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
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 "chrome/browser/geolocation/geolocation_permission_context_extensions.h " 5 #include "chrome/browser/geolocation/geolocation_permission_context_extensions.h "
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 8
9 #if defined(ENABLE_EXTENSIONS) 9 #if defined(ENABLE_EXTENSIONS)
10 #include "chrome/browser/permissions/permission_request_id.h" 10 #include "chrome/browser/permissions/permission_request_id.h"
11 #include "chrome/browser/profiles/profile.h" 11 #include "chrome/browser/profiles/profile.h"
12 #include "extensions/browser/extension_registry.h" 12 #include "extensions/browser/extension_registry.h"
13 #include "extensions/browser/guest_view/web_view/web_view_permission_helper.h" 13 #include "extensions/browser/guest_view/web_view/web_view_permission_helper.h"
14 #include "extensions/browser/process_map.h" 14 #include "extensions/browser/process_map.h"
15 #include "extensions/browser/suggest_permission_util.h" 15 #include "extensions/browser/suggest_permission_util.h"
16 #include "extensions/browser/view_type_utils.h" 16 #include "extensions/browser/view_type_utils.h"
17 #include "extensions/common/extension.h" 17 #include "extensions/common/extension.h"
18 #include "url/origin.h"
18 19
19 using extensions::APIPermission; 20 using extensions::APIPermission;
20 using extensions::ExtensionRegistry; 21 using extensions::ExtensionRegistry;
21 #endif 22 #endif
22 23
23 namespace { 24 namespace {
24 25
25 #if ENABLE_EXTENSIONS 26 #if ENABLE_EXTENSIONS
26 void CallbackContentSettingWrapper( 27 void CallbackContentSettingWrapper(
27 const base::Callback<void(ContentSetting)>& callback, 28 const base::Callback<void(ContentSetting)>& callback,
(...skipping 10 matching lines...) Expand all
38 } 39 }
39 40
40 GeolocationPermissionContextExtensions:: 41 GeolocationPermissionContextExtensions::
41 ~GeolocationPermissionContextExtensions() { 42 ~GeolocationPermissionContextExtensions() {
42 } 43 }
43 44
44 bool GeolocationPermissionContextExtensions::DecidePermission( 45 bool GeolocationPermissionContextExtensions::DecidePermission(
45 content::WebContents* web_contents, 46 content::WebContents* web_contents,
46 const PermissionRequestID& request_id, 47 const PermissionRequestID& request_id,
47 int bridge_id, 48 int bridge_id,
48 const GURL& requesting_frame, 49 const url::Origin& requesting_frame,
49 const base::Callback<void(ContentSetting)>& callback, 50 const base::Callback<void(ContentSetting)>& callback,
50 bool* permission_set, 51 bool* permission_set,
51 bool* new_permission) { 52 bool* new_permission) {
52 #if defined(ENABLE_EXTENSIONS) 53 #if defined(ENABLE_EXTENSIONS)
53 GURL requesting_frame_origin = requesting_frame.GetOrigin(); 54 const GURL requesting_frame_url(requesting_frame.Serialize());
54 55
55 extensions::WebViewPermissionHelper* web_view_permission_helper = 56 extensions::WebViewPermissionHelper* web_view_permission_helper =
56 extensions::WebViewPermissionHelper::FromWebContents(web_contents); 57 extensions::WebViewPermissionHelper::FromWebContents(web_contents);
57 if (web_view_permission_helper) { 58 if (web_view_permission_helper) {
58 web_view_permission_helper->RequestGeolocationPermission( 59 web_view_permission_helper->RequestGeolocationPermission(
59 bridge_id, requesting_frame, 60 bridge_id, requesting_frame_url,
60 base::Bind(&CallbackContentSettingWrapper, callback)); 61 base::Bind(&CallbackContentSettingWrapper, callback));
61 *permission_set = false; 62 *permission_set = false;
62 *new_permission = false; 63 *new_permission = false;
63 return true; 64 return true;
64 } 65 }
65 66
66 ExtensionRegistry* extension_registry = ExtensionRegistry::Get(profile_); 67 ExtensionRegistry* extension_registry = ExtensionRegistry::Get(profile_);
67 if (extension_registry) { 68 if (extension_registry) {
68 const extensions::Extension* extension = 69 const extensions::Extension* extension =
69 extension_registry->enabled_extensions().GetExtensionOrAppByURL( 70 extension_registry->enabled_extensions().GetExtensionOrAppByURL(
70 requesting_frame_origin); 71 requesting_frame_url);
71 if (IsExtensionWithPermissionOrSuggestInConsole( 72 if (IsExtensionWithPermissionOrSuggestInConsole(
72 APIPermission::kGeolocation, extension, 73 APIPermission::kGeolocation, extension,
73 web_contents->GetMainFrame())) { 74 web_contents->GetMainFrame())) {
74 // Make sure the extension is in the calling process. 75 // Make sure the extension is in the calling process.
75 if (extensions::ProcessMap::Get(profile_)->Contains( 76 if (extensions::ProcessMap::Get(profile_)->Contains(
76 extension->id(), request_id.render_process_id())) { 77 extension->id(), request_id.render_process_id())) {
77 *permission_set = true; 78 *permission_set = true;
78 *new_permission = true; 79 *new_permission = true;
79 return true; 80 return true;
80 } 81 }
(...skipping 25 matching lines...) Expand all
106 web_contents ? 107 web_contents ?
107 extensions::WebViewPermissionHelper::FromWebContents(web_contents) 108 extensions::WebViewPermissionHelper::FromWebContents(web_contents)
108 : NULL; 109 : NULL;
109 if (web_view_permission_helper) { 110 if (web_view_permission_helper) {
110 web_view_permission_helper->CancelGeolocationPermissionRequest(bridge_id); 111 web_view_permission_helper->CancelGeolocationPermissionRequest(bridge_id);
111 return true; 112 return true;
112 } 113 }
113 #endif // defined(ENABLE_EXTENSIONS) 114 #endif // defined(ENABLE_EXTENSIONS)
114 return false; 115 return false;
115 } 116 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698