This source file includes following definitions.
- google_location_settings_helper_
- ChromeGeolocationPermissionContextAndroid
- ProceedDecidePermission
- CheckMasterLocation
- DecidePermission
- PermissionDecided
#include "chrome/browser/geolocation/chrome_geolocation_permission_context_android.h"
#include "base/prefs/pref_service.h"
#include "chrome/browser/android/google_location_settings_helper.h"
#include "chrome/browser/content_settings/permission_request_id.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/pref_names.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/web_contents.h"
ChromeGeolocationPermissionContextAndroid::
ChromeGeolocationPermissionContextAndroid(Profile* profile)
: ChromeGeolocationPermissionContext(profile),
google_location_settings_helper_(
GoogleLocationSettingsHelper::Create()) {
}
ChromeGeolocationPermissionContextAndroid::
~ChromeGeolocationPermissionContextAndroid() {
}
void ChromeGeolocationPermissionContextAndroid::ProceedDecidePermission(
content::WebContents* web_contents,
const PermissionRequestID& id,
const GURL& requesting_frame,
const GURL& embedder,
const std::string& accept_button_label,
base::Callback<void(bool)> callback) {
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
ChromeGeolocationPermissionContext::DecidePermission(
web_contents, id, requesting_frame, embedder,
accept_button_label, callback);
}
void ChromeGeolocationPermissionContextAndroid::CheckMasterLocation(
content::WebContents* web_contents,
const PermissionRequestID& id,
const GURL& requesting_frame,
const GURL& embedder,
base::Callback<void(bool)> callback) {
bool enabled =
google_location_settings_helper_->IsMasterLocationSettingEnabled();
base::Closure ui_closure;
if (enabled) {
bool allow_label = google_location_settings_helper_->IsAllowLabel();
std::string accept_button_label =
google_location_settings_helper_->GetAcceptButtonLabel(allow_label);
ui_closure = base::Bind(
&ChromeGeolocationPermissionContextAndroid::ProceedDecidePermission,
this, web_contents, id, requesting_frame, embedder,
accept_button_label, callback);
} else {
ui_closure = base::Bind(
&ChromeGeolocationPermissionContextAndroid::PermissionDecided,
this, id, requesting_frame, embedder, callback, false);
}
content::BrowserThread::PostTask(
content::BrowserThread::UI, FROM_HERE, ui_closure);
}
void ChromeGeolocationPermissionContextAndroid::DecidePermission(
content::WebContents* web_contents,
const PermissionRequestID& id,
const GURL& requesting_frame,
const GURL& embedder,
const std::string& accept_button_label,
base::Callback<void(bool)> callback) {
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
content::BrowserThread::PostBlockingPoolTask(FROM_HERE,
base::Bind(
&ChromeGeolocationPermissionContextAndroid::CheckMasterLocation,
this, web_contents, id, requesting_frame, embedder, callback));
}
void ChromeGeolocationPermissionContextAndroid::PermissionDecided(
const PermissionRequestID& id,
const GURL& requesting_frame,
const GURL& embedder,
base::Callback<void(bool)> callback,
bool allowed) {
if (allowed &&
!google_location_settings_helper_->IsGoogleAppsLocationSettingEnabled()) {
QueueController()->CreateInfoBarRequest(id, requesting_frame, embedder, "",
callback);
return;
}
ChromeGeolocationPermissionContext::PermissionDecided(
id, requesting_frame, embedder, callback, allowed);
}