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

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

Issue 2479593006: Move enable extensions define to a build flag. (Closed)
Patch Set: Merge Created 4 years, 1 month 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 #include "extensions/features/features.h"
8 9
9 #if defined(ENABLE_EXTENSIONS) 10 #if BUILDFLAG(ENABLE_EXTENSIONS)
10 #include "chrome/browser/permissions/permission_request_id.h" 11 #include "chrome/browser/permissions/permission_request_id.h"
11 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
12 #include "extensions/browser/extension_registry.h" 13 #include "extensions/browser/extension_registry.h"
13 #include "extensions/browser/guest_view/web_view/web_view_permission_helper.h" 14 #include "extensions/browser/guest_view/web_view/web_view_permission_helper.h"
14 #include "extensions/browser/process_map.h" 15 #include "extensions/browser/process_map.h"
15 #include "extensions/browser/suggest_permission_util.h" 16 #include "extensions/browser/suggest_permission_util.h"
16 #include "extensions/browser/view_type_utils.h" 17 #include "extensions/browser/view_type_utils.h"
17 #include "extensions/common/extension.h" 18 #include "extensions/common/extension.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 defined(ENABLE_EXTENSIONS) 26 #if BUILDFLAG(ENABLE_EXTENSIONS)
26 void CallbackContentSettingWrapper( 27 void CallbackContentSettingWrapper(
27 const base::Callback<void(ContentSetting)>& callback, 28 const base::Callback<void(ContentSetting)>& callback,
28 bool allowed) { 29 bool allowed) {
29 callback.Run(allowed ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK); 30 callback.Run(allowed ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK);
30 } 31 }
31 #endif // defined(ENABLE_EXTENSIONS) 32 #endif // BUILDFLAG(ENABLE_EXTENSIONS)
32 33
33 } // anonymous namespace 34 } // anonymous namespace
34 35
35 GeolocationPermissionContextExtensions::GeolocationPermissionContextExtensions( 36 GeolocationPermissionContextExtensions::GeolocationPermissionContextExtensions(
36 Profile* profile) 37 Profile* profile)
37 #if defined(ENABLE_EXTENSIONS) 38 #if BUILDFLAG(ENABLE_EXTENSIONS)
38 : profile_(profile) 39 : profile_(profile)
39 #endif 40 #endif
40 { 41 {
41 } 42 }
42 43
43 GeolocationPermissionContextExtensions:: 44 GeolocationPermissionContextExtensions::
44 ~GeolocationPermissionContextExtensions() { 45 ~GeolocationPermissionContextExtensions() {
45 } 46 }
46 47
47 bool GeolocationPermissionContextExtensions::DecidePermission( 48 bool GeolocationPermissionContextExtensions::DecidePermission(
48 content::WebContents* web_contents, 49 content::WebContents* web_contents,
49 const PermissionRequestID& request_id, 50 const PermissionRequestID& request_id,
50 int bridge_id, 51 int bridge_id,
51 const GURL& requesting_frame, 52 const GURL& requesting_frame,
52 bool user_gesture, 53 bool user_gesture,
53 const base::Callback<void(ContentSetting)>& callback, 54 const base::Callback<void(ContentSetting)>& callback,
54 bool* permission_set, 55 bool* permission_set,
55 bool* new_permission) { 56 bool* new_permission) {
56 #if defined(ENABLE_EXTENSIONS) 57 #if BUILDFLAG(ENABLE_EXTENSIONS)
57 GURL requesting_frame_origin = requesting_frame.GetOrigin(); 58 GURL requesting_frame_origin = requesting_frame.GetOrigin();
58 59
59 extensions::WebViewPermissionHelper* web_view_permission_helper = 60 extensions::WebViewPermissionHelper* web_view_permission_helper =
60 extensions::WebViewPermissionHelper::FromWebContents(web_contents); 61 extensions::WebViewPermissionHelper::FromWebContents(web_contents);
61 if (web_view_permission_helper) { 62 if (web_view_permission_helper) {
62 web_view_permission_helper->RequestGeolocationPermission( 63 web_view_permission_helper->RequestGeolocationPermission(
63 bridge_id, requesting_frame, user_gesture, 64 bridge_id, requesting_frame, user_gesture,
64 base::Bind(&CallbackContentSettingWrapper, callback)); 65 base::Bind(&CallbackContentSettingWrapper, callback));
65 *permission_set = false; 66 *permission_set = false;
66 *new_permission = false; 67 *new_permission = false;
(...skipping 24 matching lines...) Expand all
91 // TODO(mpcomplete): the request could be from a background page or 92 // TODO(mpcomplete): the request could be from a background page or
92 // extension popup (web_contents will have a different ViewType). But why do 93 // extension popup (web_contents will have a different ViewType). But why do
93 // we care? Shouldn't we still put an infobar up in the current tab? 94 // we care? Shouldn't we still put an infobar up in the current tab?
94 LOG(WARNING) << "Attempt to use geolocation tabless renderer: " 95 LOG(WARNING) << "Attempt to use geolocation tabless renderer: "
95 << request_id.ToString() 96 << request_id.ToString()
96 << " (can't prompt user without a visible tab)"; 97 << " (can't prompt user without a visible tab)";
97 *permission_set = true; 98 *permission_set = true;
98 *new_permission = false; 99 *new_permission = false;
99 return true; 100 return true;
100 } 101 }
101 #endif // defined(ENABLE_EXTENSIONS) 102 #endif // BUILDFLAG(ENABLE_EXTENSIONS)
102 return false; 103 return false;
103 } 104 }
104 105
105 bool GeolocationPermissionContextExtensions::CancelPermissionRequest( 106 bool GeolocationPermissionContextExtensions::CancelPermissionRequest(
106 content::WebContents* web_contents, 107 content::WebContents* web_contents,
107 int bridge_id) { 108 int bridge_id) {
108 #if defined(ENABLE_EXTENSIONS) 109 #if BUILDFLAG(ENABLE_EXTENSIONS)
109 extensions::WebViewPermissionHelper* web_view_permission_helper = 110 extensions::WebViewPermissionHelper* web_view_permission_helper =
110 web_contents ? 111 web_contents ?
111 extensions::WebViewPermissionHelper::FromWebContents(web_contents) 112 extensions::WebViewPermissionHelper::FromWebContents(web_contents)
112 : NULL; 113 : NULL;
113 if (web_view_permission_helper) { 114 if (web_view_permission_helper) {
114 web_view_permission_helper->CancelGeolocationPermissionRequest(bridge_id); 115 web_view_permission_helper->CancelGeolocationPermissionRequest(bridge_id);
115 return true; 116 return true;
116 } 117 }
117 #endif // defined(ENABLE_EXTENSIONS) 118 #endif // BUILDFLAG(ENABLE_EXTENSIONS)
118 return false; 119 return false;
119 } 120 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698