summaryrefslogtreecommitdiffstats
path: root/chrome/browser/geolocation
diff options
context:
space:
mode:
authorcramya@chromium.org <cramya@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-07 04:35:52 +0000
committercramya@chromium.org <cramya@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-07 04:35:52 +0000
commit48f0cb0b8b0b76be6ccee823bb8aba7ceb2b1014 (patch)
tree102c5cda241fc53924aa7d93125ad9ca2ef3d241 /chrome/browser/geolocation
parentc9d365c0cc41b93bf8fc6e8dd99c5eefd47d8e6a (diff)
downloadchromium_src-48f0cb0b8b0b76be6ccee823bb8aba7ceb2b1014.zip
chromium_src-48f0cb0b8b0b76be6ccee823bb8aba7ceb2b1014.tar.gz
chromium_src-48f0cb0b8b0b76be6ccee823bb8aba7ceb2b1014.tar.bz2
Refactoring Geolocation Infobar part4
Changes in this CL. One google_location_settings_helper.h can be implemented separately for chrome and unit_tests. Removed google_location_settings_helper_factory.* Removed the java GoogleLocationSettingsHelper files Added 3 new unittests to test the new android infobar functionailty. BUG=152236 Review URL: https://chromiumcodereview.appspot.com/11369065 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@166343 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/geolocation')
-rw-r--r--chrome/browser/geolocation/chrome_geolocation_permission_context_android.cc3
-rw-r--r--chrome/browser/geolocation/chrome_geolocation_permission_context_unittest.cc70
-rw-r--r--chrome/browser/geolocation/geolocation_confirm_infobar_delegate_android.cc3
-rw-r--r--chrome/browser/geolocation/geolocation_confirm_infobar_delegate_android.h1
4 files changed, 73 insertions, 4 deletions
diff --git a/chrome/browser/geolocation/chrome_geolocation_permission_context_android.cc b/chrome/browser/geolocation/chrome_geolocation_permission_context_android.cc
index ba03aea..88253b8 100644
--- a/chrome/browser/geolocation/chrome_geolocation_permission_context_android.cc
+++ b/chrome/browser/geolocation/chrome_geolocation_permission_context_android.cc
@@ -13,7 +13,8 @@
ChromeGeolocationPermissionContextAndroid::
ChromeGeolocationPermissionContextAndroid(Profile* profile)
: ChromeGeolocationPermissionContext(profile),
- google_location_settings_helper_(new GoogleLocationSettingsHelper()) {
+ google_location_settings_helper_(
+ GoogleLocationSettingsHelper::Create()) {
}
ChromeGeolocationPermissionContextAndroid::
diff --git a/chrome/browser/geolocation/chrome_geolocation_permission_context_unittest.cc b/chrome/browser/geolocation/chrome_geolocation_permission_context_unittest.cc
index fd5bae0..a0ec58c 100644
--- a/chrome/browser/geolocation/chrome_geolocation_permission_context_unittest.cc
+++ b/chrome/browser/geolocation/chrome_geolocation_permission_context_unittest.cc
@@ -35,6 +35,7 @@
#if defined(OS_ANDROID)
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/common/pref_names.h"
+#include "chrome/browser/android/mock_google_location_settings_helper.h"
#endif
using content::MockRenderProcessHost;
@@ -259,7 +260,9 @@ void GeolocationPermissionContextTests::SetUp() {
chrome::SetViewType(web_contents(), chrome::VIEW_TYPE_TAB_CONTENTS);
InfoBarTabHelper::CreateForWebContents(web_contents());
TabSpecificContentSettings::CreateForWebContents(web_contents());
-
+#if defined(OS_ANDROID)
+ MockGoogleLocationSettingsHelper::SetLocationStatus(true, true);
+#endif
geolocation_permission_context_ =
ChromeGeolocationPermissionContextFactory::Create(profile());
}
@@ -277,7 +280,6 @@ void GeolocationPermissionContextTests::TearDown() {
db_thread_.Stop();
}
-
// Tests ----------------------------------------------------------------------
TEST_F(GeolocationPermissionContextTests, SinglePermission) {
@@ -295,6 +297,70 @@ TEST_F(GeolocationPermissionContextTests, SinglePermission) {
infobar_0->InfoBarClosed();
}
+#if defined(OS_ANDROID)
+TEST_F(GeolocationPermissionContextTests, GeolocationEnabledDisabled) {
+ GURL requesting_frame("http://www.example.com/geolocation");
+ NavigateAndCommit(requesting_frame);
+ MockGoogleLocationSettingsHelper::SetLocationStatus(true, true);
+ EXPECT_EQ(0U, infobar_tab_helper()->GetInfoBarCount());
+ RequestGeolocationPermission(RequestID(0), requesting_frame);
+ EXPECT_EQ(1U, infobar_tab_helper()->GetInfoBarCount());
+ ConfirmInfoBarDelegate* infobar_0 = infobar_tab_helper()->
+ GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate();
+ ASSERT_TRUE(infobar_0);
+ string16 text_0 = infobar_0->GetButtonLabel(
+ ConfirmInfoBarDelegate::BUTTON_OK);
+
+ NavigateAndCommit(requesting_frame);
+ MockGoogleLocationSettingsHelper::SetLocationStatus(true, false);
+ EXPECT_EQ(0U, infobar_tab_helper()->GetInfoBarCount());
+ RequestGeolocationPermission(RequestID(0), requesting_frame);
+ EXPECT_EQ(1U, infobar_tab_helper()->GetInfoBarCount());
+ ConfirmInfoBarDelegate* infobar_1 = infobar_tab_helper()->
+ GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate();
+ ASSERT_TRUE(infobar_1);
+ string16 text_1 = infobar_1->GetButtonLabel(
+ ConfirmInfoBarDelegate::BUTTON_OK);
+ EXPECT_NE(text_0, text_1);
+
+ NavigateAndCommit(requesting_frame);
+ MockGoogleLocationSettingsHelper::SetLocationStatus(false, false);
+ EXPECT_EQ(0U, infobar_tab_helper()->GetInfoBarCount());
+ RequestGeolocationPermission(RequestID(0), requesting_frame);
+ EXPECT_EQ(0U, infobar_tab_helper()->GetInfoBarCount());
+}
+
+TEST_F(GeolocationPermissionContextTests, MasterEnabledGoogleAppsEnabled) {
+ GURL requesting_frame("http://www.example.com/geolocation");
+ NavigateAndCommit(requesting_frame);
+ MockGoogleLocationSettingsHelper::SetLocationStatus(true, true);
+ EXPECT_EQ(0U, infobar_tab_helper()->GetInfoBarCount());
+ RequestGeolocationPermission(RequestID(0), requesting_frame);
+ EXPECT_EQ(1U, infobar_tab_helper()->GetInfoBarCount());
+ ConfirmInfoBarDelegate* infobar_0 = infobar_tab_helper()->
+ GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate();
+ ASSERT_TRUE(infobar_0);
+ infobar_0->Accept();
+ CheckTabContentsState(requesting_frame, CONTENT_SETTING_ALLOW);
+ CheckPermissionMessageSent(0, true);
+}
+
+TEST_F(GeolocationPermissionContextTests, MasterEnabledGoogleAppsDisabled) {
+ GURL requesting_frame("http://www.example.com/geolocation");
+ NavigateAndCommit(requesting_frame);
+ MockGoogleLocationSettingsHelper::SetLocationStatus(true, false);
+ EXPECT_EQ(0U, infobar_tab_helper()->GetInfoBarCount());
+ RequestGeolocationPermission(RequestID(0), requesting_frame);
+ EXPECT_EQ(1U, infobar_tab_helper()->GetInfoBarCount());
+ ConfirmInfoBarDelegate* infobar_0 = infobar_tab_helper()->
+ GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate();
+ ASSERT_TRUE(infobar_0);
+ infobar_0->Accept();
+ EXPECT_TRUE(
+ MockGoogleLocationSettingsHelper::WasGoogleLocationSettingsCalled());
+}
+#endif
+
TEST_F(GeolocationPermissionContextTests, QueuedPermission) {
GURL requesting_frame_0("http://www.example.com/geolocation");
GURL requesting_frame_1("http://www.example-2.com/geolocation");
diff --git a/chrome/browser/geolocation/geolocation_confirm_infobar_delegate_android.cc b/chrome/browser/geolocation/geolocation_confirm_infobar_delegate_android.cc
index f356966..86cbb54 100644
--- a/chrome/browser/geolocation/geolocation_confirm_infobar_delegate_android.cc
+++ b/chrome/browser/geolocation/geolocation_confirm_infobar_delegate_android.cc
@@ -21,7 +21,8 @@ GeolocationConfirmInfoBarDelegateAndroid::
: GeolocationConfirmInfoBarDelegate(infobar_helper, controller, id,
requesting_frame_url,
display_languages),
- google_location_settings_helper_(new GoogleLocationSettingsHelper()) {
+ google_location_settings_helper_(
+ GoogleLocationSettingsHelper::Create()) {
}
GeolocationConfirmInfoBarDelegateAndroid::
diff --git a/chrome/browser/geolocation/geolocation_confirm_infobar_delegate_android.h b/chrome/browser/geolocation/geolocation_confirm_infobar_delegate_android.h
index 6a62111..2068db1 100644
--- a/chrome/browser/geolocation/geolocation_confirm_infobar_delegate_android.h
+++ b/chrome/browser/geolocation/geolocation_confirm_infobar_delegate_android.h
@@ -27,6 +27,7 @@ class GeolocationConfirmInfoBarDelegateAndroid
virtual bool Accept() OVERRIDE;
scoped_ptr<GoogleLocationSettingsHelper> google_location_settings_helper_;
+
};
#endif // CHROME_BROWSER_GEOLOCATION_GEOLOCATION_CONFIRM_INFOBAR_DELEGATE_ANDROID_H_