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 "base/threading/worker_pool.h" | |
13 #include "chrome/browser/content_settings/host_content_settings_map.h" | 14 #include "chrome/browser/content_settings/host_content_settings_map.h" |
14 #include "chrome/browser/content_settings/permission_request_id.h" | 15 #include "chrome/browser/content_settings/permission_request_id.h" |
15 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 16 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
16 #include "chrome/browser/extensions/extension_service.h" | 17 #include "chrome/browser/extensions/extension_service.h" |
17 #include "chrome/browser/extensions/extension_system.h" | 18 #include "chrome/browser/extensions/extension_system.h" |
18 #include "chrome/browser/extensions/suggest_permission_util.h" | 19 #include "chrome/browser/extensions/suggest_permission_util.h" |
19 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
20 #include "chrome/browser/tab_contents/tab_util.h" | 21 #include "chrome/browser/tab_contents/tab_util.h" |
21 #include "chrome/common/extensions/extension.h" | 22 #include "chrome/common/extensions/extension.h" |
22 #include "content/public/browser/browser_thread.h" | 23 #include "content/public/browser/browser_thread.h" |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
127 requesting_frame, embedder, CONTENT_SETTINGS_TYPE_GEOLOCATION, | 128 requesting_frame, embedder, CONTENT_SETTINGS_TYPE_GEOLOCATION, |
128 std::string()); | 129 std::string()); |
129 switch (content_setting) { | 130 switch (content_setting) { |
130 case CONTENT_SETTING_BLOCK: | 131 case CONTENT_SETTING_BLOCK: |
131 PermissionDecided(id, requesting_frame, embedder, callback, false); | 132 PermissionDecided(id, requesting_frame, embedder, callback, false); |
132 break; | 133 break; |
133 case CONTENT_SETTING_ALLOW: | 134 case CONTENT_SETTING_ALLOW: |
134 PermissionDecided(id, requesting_frame, embedder, callback, true); | 135 PermissionDecided(id, requesting_frame, embedder, callback, true); |
135 break; | 136 break; |
136 default: | 137 default: |
137 // setting == ask. Prompt the user. | 138 // setting == ask. Prompt the user in the UI thread now. |
bulach
2013/09/04 18:48:53
hmm, isn't this already on the UI thread as per 12
acleung1
2013/09/05 21:50:16
Good point. Done.
| |
139 content::BrowserThread::PostTask( | |
140 content::BrowserThread::UI, FROM_HERE, | |
141 base::Bind( | |
142 &ChromeGeolocationPermissionContext::CreateInfoBarRequest, | |
143 base::Unretained(this), id, requesting_frame, embedder,callback)); | |
144 } | |
145 } | |
146 | |
147 void ChromeGeolocationPermissionContext::CreateInfoBarRequest( | |
148 const PermissionRequestID& id, | |
149 const GURL& requesting_frame, | |
150 const GURL& embedder, | |
151 base::Callback<void(bool)> callback) { | |
138 QueueController()->CreateInfoBarRequest( | 152 QueueController()->CreateInfoBarRequest( |
bulach
2013/09/04 18:48:53
nit: indentation
acleung1
2013/09/05 21:50:16
Done.
| |
139 id, requesting_frame, embedder, base::Bind( | 153 id, requesting_frame, embedder, base::Bind( |
140 &ChromeGeolocationPermissionContext::NotifyPermissionSet, | 154 &ChromeGeolocationPermissionContext::NotifyPermissionSet, |
141 base::Unretained(this), id, requesting_frame, callback)); | 155 base::Unretained(this), id, requesting_frame, callback)); |
142 } | |
143 } | 156 } |
144 | 157 |
145 void ChromeGeolocationPermissionContext::ShutdownOnUIThread() { | 158 void ChromeGeolocationPermissionContext::ShutdownOnUIThread() { |
146 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 159 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
147 permission_queue_controller_.reset(); | 160 permission_queue_controller_.reset(); |
148 shutting_down_ = true; | 161 shutting_down_ = true; |
149 } | 162 } |
150 | 163 |
151 void ChromeGeolocationPermissionContext::PermissionDecided( | 164 void ChromeGeolocationPermissionContext::PermissionDecided( |
152 const PermissionRequestID& id, | 165 const PermissionRequestID& id, |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
200 base::Bind( | 213 base::Bind( |
201 &ChromeGeolocationPermissionContext::CancelPendingInfoBarRequest, | 214 &ChromeGeolocationPermissionContext::CancelPendingInfoBarRequest, |
202 this, id)); | 215 this, id)); |
203 return; | 216 return; |
204 } | 217 } |
205 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 218 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
206 if (shutting_down_) | 219 if (shutting_down_) |
207 return; | 220 return; |
208 QueueController()->CancelInfoBarRequest(id); | 221 QueueController()->CancelInfoBarRequest(id); |
209 } | 222 } |
OLD | NEW |