| Index: chrome/browser/geolocation/chrome_geolocation_permission_context.cc
|
| ===================================================================
|
| --- chrome/browser/geolocation/chrome_geolocation_permission_context.cc (revision 163741)
|
| +++ chrome/browser/geolocation/chrome_geolocation_permission_context.cc (working copy)
|
| @@ -14,6 +14,7 @@
|
| #include "chrome/browser/content_settings/tab_specific_content_settings.h"
|
| #include "chrome/browser/extensions/extension_service.h"
|
| #include "chrome/browser/geolocation/geolocation_infobar_queue_controller.h"
|
| +#include "chrome/browser/geolocation/geolocation_permission_request_id.h"
|
| #include "chrome/browser/profiles/profile.h"
|
| #include "chrome/browser/tab_contents/tab_util.h"
|
| #include "chrome/browser/view_type_utils.h"
|
| @@ -24,12 +25,7 @@
|
| #include "third_party/WebKit/Source/Platform/chromium/public/WebString.h"
|
| #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h"
|
|
|
| -using WebKit::WebSecurityOrigin;
|
| -using content::BrowserThread;
|
| -using content::WebContents;
|
|
|
| -// GeolocationPermissionContext -----------------------------------------------
|
| -
|
| ChromeGeolocationPermissionContext::ChromeGeolocationPermissionContext(
|
| Profile* profile)
|
| : profile_(profile) {
|
| @@ -39,11 +35,14 @@
|
| }
|
|
|
| void ChromeGeolocationPermissionContext::RequestGeolocationPermission(
|
| - int render_process_id, int render_view_id, int bridge_id,
|
| - const GURL& requesting_frame, base::Callback<void(bool)> callback) {
|
| - if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
|
| - BrowserThread::PostTask(
|
| - BrowserThread::UI, FROM_HERE,
|
| + int render_process_id,
|
| + int render_view_id,
|
| + int bridge_id,
|
| + const GURL& requesting_frame,
|
| + base::Callback<void(bool)> callback) {
|
| + if (!content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)) {
|
| + content::BrowserThread::PostTask(
|
| + content::BrowserThread::UI, FROM_HERE,
|
| base::Bind(
|
| &ChromeGeolocationPermissionContext::RequestGeolocationPermission,
|
| this, render_process_id, render_view_id, bridge_id,
|
| @@ -51,19 +50,20 @@
|
| return;
|
| }
|
|
|
| - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| - WebContents* web_contents =
|
| + DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
|
| + content::WebContents* web_contents =
|
| tab_util::GetWebContentsByID(render_process_id, render_view_id);
|
| + const GeolocationPermissionRequestID id(render_process_id, render_view_id,
|
| + bridge_id);
|
| if (chrome::GetViewType(web_contents) != chrome::VIEW_TYPE_TAB_CONTENTS) {
|
| // The tab may have gone away, or the request may not be from a tab at all.
|
| // TODO(mpcomplete): the request could be from a background page or
|
| // extension popup (tab_contents will have a different ViewType). But why do
|
| // we care? Shouldn't we still put an infobar up in the current tab?
|
| LOG(WARNING) << "Attempt to use geolocation tabless renderer: "
|
| - << render_process_id << "," << render_view_id << ","
|
| - << bridge_id << " (can't prompt user without a visible tab)";
|
| - NotifyPermissionSet(render_process_id, render_view_id, bridge_id,
|
| - requesting_frame, callback, false);
|
| + << id.ToString()
|
| + << " (can't prompt user without a visible tab)";
|
| + NotifyPermissionSet(id, requesting_frame, callback, false);
|
| return;
|
| }
|
|
|
| @@ -72,13 +72,12 @@
|
| LOG(WARNING) << "Attempt to use geolocation from an invalid URL: "
|
| << requesting_frame << "," << embedder
|
| << " (geolocation is not supported in popups)";
|
| - NotifyPermissionSet(render_process_id, render_view_id, bridge_id,
|
| - requesting_frame, callback, false);
|
| + NotifyPermissionSet(id, requesting_frame, callback, false);
|
| return;
|
| }
|
|
|
| - DecidePermission(render_process_id, render_view_id, bridge_id,
|
| - requesting_frame, embedder, callback);
|
| + DecidePermission(id, requesting_frame, embedder, callback);
|
| +
|
| }
|
|
|
| void ChromeGeolocationPermissionContext::CancelGeolocationPermissionRequest(
|
| @@ -86,30 +85,30 @@
|
| int render_view_id,
|
| int bridge_id,
|
| const GURL& requesting_frame) {
|
| - CancelPendingInfoBarRequest(render_process_id, render_view_id, bridge_id);
|
| + CancelPendingInfoBarRequest(GeolocationPermissionRequestID(
|
| + render_process_id, render_view_id, bridge_id));
|
| }
|
|
|
| void ChromeGeolocationPermissionContext::DecidePermission(
|
| - int render_process_id, int render_view_id, int bridge_id,
|
| - const GURL& requesting_frame, const GURL& embedder,
|
| + const GeolocationPermissionRequestID& id,
|
| + const GURL& requesting_frame,
|
| + const GURL& embedder,
|
| base::Callback<void(bool)> callback) {
|
| - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| + DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
|
|
|
| ExtensionService* extension_service = profile_->GetExtensionService();
|
| if (extension_service) {
|
| const extensions::Extension* extension =
|
| extension_service->extensions()->GetExtensionOrAppByURL(
|
| - ExtensionURLInfo(
|
| - WebSecurityOrigin::createFromString(
|
| - UTF8ToUTF16(requesting_frame.spec())),
|
| - requesting_frame));
|
| + ExtensionURLInfo(WebKit::WebSecurityOrigin::createFromString(
|
| + UTF8ToUTF16(requesting_frame.spec())),
|
| + requesting_frame));
|
| if (extension &&
|
| extension->HasAPIPermission(extensions::APIPermission::kGeolocation)) {
|
| // Make sure the extension is in the calling process.
|
| - if (extension_service->process_map()->Contains(
|
| - extension->id(), render_process_id)) {
|
| - PermissionDecided(render_process_id, render_view_id, bridge_id,
|
| - requesting_frame, embedder, callback, true);
|
| + if (extension_service->process_map()->Contains(extension->id(),
|
| + id.render_process_id())) {
|
| + PermissionDecided(id, requesting_frame, embedder, callback, true);
|
| return;
|
| }
|
| }
|
| @@ -117,55 +116,44 @@
|
|
|
| ContentSetting content_setting =
|
| profile_->GetHostContentSettingsMap()->GetContentSetting(
|
| - requesting_frame,
|
| - embedder,
|
| - CONTENT_SETTINGS_TYPE_GEOLOCATION,
|
| + requesting_frame, embedder, CONTENT_SETTINGS_TYPE_GEOLOCATION,
|
| std::string());
|
| switch (content_setting) {
|
| case CONTENT_SETTING_BLOCK:
|
| - PermissionDecided(render_process_id, render_view_id, bridge_id,
|
| - requesting_frame, embedder, callback, false);
|
| + PermissionDecided(id, requesting_frame, embedder, callback, false);
|
| break;
|
| case CONTENT_SETTING_ALLOW:
|
| - PermissionDecided(render_process_id, render_view_id, bridge_id,
|
| - requesting_frame, embedder, callback, true);
|
| + PermissionDecided(id, requesting_frame, embedder, callback, true);
|
| break;
|
| default:
|
| // setting == ask. Prompt the user.
|
| QueueController()->CreateInfoBarRequest(
|
| - render_process_id, render_view_id, bridge_id, requesting_frame,
|
| - embedder, base::Bind(
|
| + id, requesting_frame, embedder, base::Bind(
|
| &ChromeGeolocationPermissionContext::NotifyPermissionSet,
|
| - base::Unretained(this),
|
| - render_process_id, render_view_id, bridge_id, requesting_frame,
|
| - callback));
|
| + base::Unretained(this), id, requesting_frame, callback));
|
| }
|
| }
|
|
|
| void ChromeGeolocationPermissionContext::PermissionDecided(
|
| - int render_process_id,
|
| - int render_view_id,
|
| - int bridge_id,
|
| + const GeolocationPermissionRequestID& id,
|
| const GURL& requesting_frame,
|
| const GURL& embedder,
|
| base::Callback<void(bool)> callback,
|
| bool allowed) {
|
| - NotifyPermissionSet(render_process_id, render_view_id, bridge_id,
|
| - requesting_frame, callback, allowed);
|
| + NotifyPermissionSet(id, requesting_frame, callback, allowed);
|
| }
|
|
|
| void ChromeGeolocationPermissionContext::NotifyPermissionSet(
|
| - int render_process_id,
|
| - int render_view_id,
|
| - int bridge_id,
|
| + const GeolocationPermissionRequestID& id,
|
| const GURL& requesting_frame,
|
| base::Callback<void(bool)> callback,
|
| bool allowed) {
|
| - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| + DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
|
|
|
| // WebContents may have gone away (or not exists for extension).
|
| TabSpecificContentSettings* content_settings =
|
| - TabSpecificContentSettings::Get(render_process_id, render_view_id);
|
| + TabSpecificContentSettings::Get(id.render_process_id(),
|
| + id.render_view_id());
|
| if (content_settings) {
|
| content_settings->OnGeolocationPermissionSet(requesting_frame.GetOrigin(),
|
| allowed);
|
| @@ -176,7 +164,7 @@
|
|
|
| GeolocationInfoBarQueueController*
|
| ChromeGeolocationPermissionContext::QueueController() {
|
| - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| + DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
|
| if (!geolocation_infobar_queue_controller_)
|
| geolocation_infobar_queue_controller_.reset(CreateQueueController());
|
| return geolocation_infobar_queue_controller_.get();
|
| @@ -184,25 +172,20 @@
|
|
|
| GeolocationInfoBarQueueController*
|
| ChromeGeolocationPermissionContext::CreateQueueController() {
|
| - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| + DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
|
| return new GeolocationInfoBarQueueController(profile());
|
| }
|
|
|
| void ChromeGeolocationPermissionContext::CancelPendingInfoBarRequest(
|
| - int render_process_id,
|
| - int render_view_id,
|
| - int bridge_id) {
|
| - if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
|
| - BrowserThread::PostTask(
|
| - BrowserThread::UI, FROM_HERE,
|
| + const GeolocationPermissionRequestID& id) {
|
| + if (!content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)) {
|
| + content::BrowserThread::PostTask(
|
| + content::BrowserThread::UI, FROM_HERE,
|
| base::Bind(
|
| &ChromeGeolocationPermissionContext::CancelPendingInfoBarRequest,
|
| - this, render_process_id, render_view_id, bridge_id));
|
| + this, id));
|
| return;
|
| }
|
| - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| - QueueController()->CancelInfoBarRequest(
|
| - render_process_id,
|
| - render_view_id,
|
| - bridge_id);
|
| + DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
|
| + QueueController()->CancelInfoBarRequest(id);
|
| }
|
|
|