OLD | NEW |
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/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
13 #include "chrome/browser/content_settings/host_content_settings_map.h" | 13 #include "chrome/browser/content_settings/host_content_settings_map.h" |
14 #include "chrome/browser/content_settings/permission_request_id.h" | 14 #include "chrome/browser/content_settings/permission_request_id.h" |
15 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 15 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
16 #include "chrome/browser/extensions/extension_service.h" | |
17 #include "chrome/browser/extensions/extension_system.h" | |
18 #include "chrome/browser/extensions/suggest_permission_util.h" | 16 #include "chrome/browser/extensions/suggest_permission_util.h" |
19 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
20 #include "chrome/browser/tab_contents/tab_util.h" | 18 #include "chrome/browser/tab_contents/tab_util.h" |
21 #include "content/public/browser/browser_thread.h" | 19 #include "content/public/browser/browser_thread.h" |
22 #include "content/public/browser/render_view_host.h" | 20 #include "content/public/browser/render_view_host.h" |
23 #include "content/public/browser/web_contents.h" | 21 #include "content/public/browser/web_contents.h" |
| 22 #include "extensions/browser/extension_registry.h" |
| 23 #include "extensions/browser/process_map.h" |
24 #include "extensions/browser/view_type_utils.h" | 24 #include "extensions/browser/view_type_utils.h" |
25 #include "extensions/common/extension.h" | 25 #include "extensions/common/extension.h" |
26 | 26 |
27 using extensions::APIPermission; | 27 using extensions::APIPermission; |
| 28 using extensions::ExtensionRegistry; |
28 | 29 |
29 ChromeGeolocationPermissionContext::ChromeGeolocationPermissionContext( | 30 ChromeGeolocationPermissionContext::ChromeGeolocationPermissionContext( |
30 Profile* profile) | 31 Profile* profile) |
31 : profile_(profile), | 32 : profile_(profile), |
32 shutting_down_(false) { | 33 shutting_down_(false) { |
33 } | 34 } |
34 | 35 |
35 ChromeGeolocationPermissionContext::~ChromeGeolocationPermissionContext() { | 36 ChromeGeolocationPermissionContext::~ChromeGeolocationPermissionContext() { |
36 // ChromeGeolocationPermissionContext may be destroyed on either the UI thread | 37 // ChromeGeolocationPermissionContext may be destroyed on either the UI thread |
37 // or the IO thread, but the PermissionQueueController must have been | 38 // or the IO thread, but the PermissionQueueController must have been |
(...skipping 18 matching lines...) Expand all Loading... |
56 return; | 57 return; |
57 } | 58 } |
58 | 59 |
59 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 60 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
60 if (shutting_down_) | 61 if (shutting_down_) |
61 return; | 62 return; |
62 | 63 |
63 content::WebContents* web_contents = | 64 content::WebContents* web_contents = |
64 tab_util::GetWebContentsByID(render_process_id, render_view_id); | 65 tab_util::GetWebContentsByID(render_process_id, render_view_id); |
65 const PermissionRequestID id(render_process_id, render_view_id, bridge_id, 0); | 66 const PermissionRequestID id(render_process_id, render_view_id, bridge_id, 0); |
66 ExtensionService* extension_service = | 67 ExtensionRegistry* extension_registry = ExtensionRegistry::Get(profile_); |
67 extensions::ExtensionSystem::Get(profile_)->extension_service(); | 68 if (extension_registry) { |
68 if (extension_service) { | |
69 const extensions::Extension* extension = | 69 const extensions::Extension* extension = |
70 extension_service->extensions()->GetExtensionOrAppByURL( | 70 extension_registry->enabled_extensions().GetExtensionOrAppByURL( |
71 requesting_frame_origin); | 71 requesting_frame_origin); |
72 if (IsExtensionWithPermissionOrSuggestInConsole(APIPermission::kGeolocation, | 72 if (IsExtensionWithPermissionOrSuggestInConsole(APIPermission::kGeolocation, |
73 extension, | 73 extension, |
74 profile_)) { | 74 profile_)) { |
75 // Make sure the extension is in the calling process. | 75 // Make sure the extension is in the calling process. |
76 if (extension_service->process_map()->Contains(extension->id(), | 76 if (extensions::ProcessMap::Get(profile_) |
77 id.render_process_id())) { | 77 ->Contains(extension->id(), id.render_process_id())) { |
78 NotifyPermissionSet(id, requesting_frame_origin, callback, true); | 78 NotifyPermissionSet(id, requesting_frame_origin, callback, true); |
79 return; | 79 return; |
80 } | 80 } |
81 } | 81 } |
82 } | 82 } |
83 | 83 |
84 if (extensions::GetViewType(web_contents) != | 84 if (extensions::GetViewType(web_contents) != |
85 extensions::VIEW_TYPE_TAB_CONTENTS) { | 85 extensions::VIEW_TYPE_TAB_CONTENTS) { |
86 // The tab may have gone away, or the request may not be from a tab at all. | 86 // The tab may have gone away, or the request may not be from a tab at all. |
87 // TODO(mpcomplete): the request could be from a background page or | 87 // TODO(mpcomplete): the request could be from a background page or |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 base::Bind( | 200 base::Bind( |
201 &ChromeGeolocationPermissionContext::CancelPendingInfobarRequest, | 201 &ChromeGeolocationPermissionContext::CancelPendingInfobarRequest, |
202 this, id)); | 202 this, id)); |
203 return; | 203 return; |
204 } | 204 } |
205 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 205 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
206 if (shutting_down_) | 206 if (shutting_down_) |
207 return; | 207 return; |
208 QueueController()->CancelInfoBarRequest(id); | 208 QueueController()->CancelInfoBarRequest(id); |
209 } | 209 } |
OLD | NEW |