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

Side by Side Diff: chrome/browser/chrome_quota_permission_context.cc

Issue 2558673003: Move RequestQuotaPermission from RenderView to RenderFrame. (Closed)
Patch Set: Created 4 years 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 | content/child/quota_dispatcher.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/chrome_quota_permission_context.h" 5 #include "chrome/browser/chrome_quota_permission_context.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <string> 9 #include <string>
10 10
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 } 247 }
248 248
249 if (!content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)) { 249 if (!content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)) {
250 content::BrowserThread::PostTask( 250 content::BrowserThread::PostTask(
251 content::BrowserThread::UI, FROM_HERE, 251 content::BrowserThread::UI, FROM_HERE,
252 base::Bind(&ChromeQuotaPermissionContext::RequestQuotaPermission, this, 252 base::Bind(&ChromeQuotaPermissionContext::RequestQuotaPermission, this,
253 params, render_process_id, callback)); 253 params, render_process_id, callback));
254 return; 254 return;
255 } 255 }
256 256
257 content::WebContents* web_contents = 257 content::WebContents* web_contents = tab_util::GetWebContentsByFrameID(
258 tab_util::GetWebContentsByID(render_process_id, 258 render_process_id, params.render_frame_id);
259 params.render_view_id);
260 if (!web_contents) { 259 if (!web_contents) {
261 // The tab may have gone away or the request may not be from a tab. 260 // The tab may have gone away or the request may not be from a tab.
262 LOG(WARNING) << "Attempt to request quota tabless renderer: " 261 LOG(WARNING) << "Attempt to request quota tabless renderer: "
263 << render_process_id << "," << params.render_view_id; 262 << render_process_id << "," << params.render_frame_id;
264 DispatchCallbackOnIOThread(callback, QUOTA_PERMISSION_RESPONSE_CANCELLED); 263 DispatchCallbackOnIOThread(callback, QUOTA_PERMISSION_RESPONSE_CANCELLED);
265 return; 264 return;
266 } 265 }
267 266
268 #if defined(OS_ANDROID) 267 #if defined(OS_ANDROID)
269 InfoBarService* infobar_service = 268 InfoBarService* infobar_service =
270 InfoBarService::FromWebContents(web_contents); 269 InfoBarService::FromWebContents(web_contents);
271 if (infobar_service) { 270 if (infobar_service) {
272 RequestQuotaInfoBarDelegate::Create( 271 RequestQuotaInfoBarDelegate::Create(
273 infobar_service, this, params.origin_url, params.requested_size, 272 infobar_service, this, params.origin_url, params.requested_size,
274 callback); 273 callback);
275 return; 274 return;
276 } 275 }
277 #else 276 #else
278 PermissionRequestManager* permission_request_manager = 277 PermissionRequestManager* permission_request_manager =
279 PermissionRequestManager::FromWebContents(web_contents); 278 PermissionRequestManager::FromWebContents(web_contents);
280 if (permission_request_manager) { 279 if (permission_request_manager) {
281 permission_request_manager->AddRequest( 280 permission_request_manager->AddRequest(
282 new QuotaPermissionRequest(this, params.origin_url, callback)); 281 new QuotaPermissionRequest(this, params.origin_url, callback));
283 return; 282 return;
284 } 283 }
285 #endif 284 #endif
286 285
287 // The tab has no UI service for presenting the permissions request. 286 // The tab has no UI service for presenting the permissions request.
288 LOG(WARNING) << "Attempt to request quota from a background page: " 287 LOG(WARNING) << "Attempt to request quota from a background page: "
289 << render_process_id << "," << params.render_view_id; 288 << render_process_id << "," << params.render_frame_id;
290 DispatchCallbackOnIOThread(callback, QUOTA_PERMISSION_RESPONSE_CANCELLED); 289 DispatchCallbackOnIOThread(callback, QUOTA_PERMISSION_RESPONSE_CANCELLED);
291 } 290 }
292 291
293 void ChromeQuotaPermissionContext::DispatchCallbackOnIOThread( 292 void ChromeQuotaPermissionContext::DispatchCallbackOnIOThread(
294 const PermissionCallback& callback, 293 const PermissionCallback& callback,
295 QuotaPermissionResponse response) { 294 QuotaPermissionResponse response) {
296 DCHECK_EQ(false, callback.is_null()); 295 DCHECK_EQ(false, callback.is_null());
297 296
298 if (!content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)) { 297 if (!content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)) {
299 content::BrowserThread::PostTask( 298 content::BrowserThread::PostTask(
300 content::BrowserThread::IO, FROM_HERE, 299 content::BrowserThread::IO, FROM_HERE,
301 base::Bind(&ChromeQuotaPermissionContext::DispatchCallbackOnIOThread, 300 base::Bind(&ChromeQuotaPermissionContext::DispatchCallbackOnIOThread,
302 this, callback, response)); 301 this, callback, response));
303 return; 302 return;
304 } 303 }
305 304
306 callback.Run(response); 305 callback.Run(response);
307 } 306 }
308 307
309 ChromeQuotaPermissionContext::~ChromeQuotaPermissionContext() {} 308 ChromeQuotaPermissionContext::~ChromeQuotaPermissionContext() {}
OLDNEW
« no previous file with comments | « no previous file | content/child/quota_dispatcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698