diff options
19 files changed, 236 insertions, 235 deletions
diff --git a/base/android/jni_generator/class_list.jni b/base/android/jni_generator/class_list.jni index 0c4f6fa..3395a3d 100644 --- a/base/android/jni_generator/class_list.jni +++ b/base/android/jni_generator/class_list.jni @@ -47,7 +47,4 @@ Lorg/chromium/media/MediaPlayerListener Lorg/chromium/net/NetworkChangeNotifier Lorg/chromium/net/ProxyChangeListener Lorg/chromium/ui/gfx/NativeWindow -Lorg/chromium/ui/SelectFileDialog -Lcom/google/android/apps/chrome/GoogleLocationSettingsHelperImpl -Lorg/chromium/chrome/browser/GoogleLocationSettingsHelper -Lorg/chromium/chrome/browser/GoogleLocationSettingsHelperStub +Lorg/chromium/ui/SelectFileDialog
\ No newline at end of file diff --git a/chrome/android/java/src/org/chromium/chrome/browser/GoogleLocationSettingsHelper.java b/chrome/android/java/src/org/chromium/chrome/browser/GoogleLocationSettingsHelper.java deleted file mode 100644 index b04eb4f..0000000 --- a/chrome/android/java/src/org/chromium/chrome/browser/GoogleLocationSettingsHelper.java +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -package org.chromium.chrome.browser; - -import org.chromium.base.CalledByNative; - -/** - * Helper interface to read the Google Apps location setting to update the infobar button label. - * Also, starts the Android Google Apps location settings activity upon request. - */ -public interface GoogleLocationSettingsHelper { - - @CalledByNative - public String getInfoBarAcceptLabel(); - - @CalledByNative - public boolean isMasterLocationSettingEnabled(); - - @CalledByNative - public boolean isGoogleAppsLocationSettingEnabled(); - - @CalledByNative - public void startGoogleLocationSettingsActivity(); -} diff --git a/chrome/android/java/src/org/chromium/chrome/browser/GoogleLocationSettingsHelperStub.java b/chrome/android/java/src/org/chromium/chrome/browser/GoogleLocationSettingsHelperStub.java deleted file mode 100644 index 0e2f56b..0000000 --- a/chrome/android/java/src/org/chromium/chrome/browser/GoogleLocationSettingsHelperStub.java +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -package org.chromium.chrome.browser; - -import android.content.Context; - -import org.chromium.base.CalledByNative; - -/** - * Stub implementation in Chrome for GoogleLocationSettingsHelper. - */ - -public class GoogleLocationSettingsHelperStub implements GoogleLocationSettingsHelper { - - public GoogleLocationSettingsHelperStub(Context context) { - } - - @Override - public String getInfoBarAcceptLabel() { - return "Allow"; - } - - @Override - public boolean isMasterLocationSettingEnabled() { - return true; - } - - @Override - public boolean isGoogleAppsLocationSettingEnabled() { - return true; - } - - @Override - public void startGoogleLocationSettingsActivity() { - } - - @CalledByNative - public static GoogleLocationSettingsHelper createInstance(Context context) { - return new GoogleLocationSettingsHelperStub(context); - } - -} diff --git a/chrome/android/testshell/testshell_google_location_settings_helper.cc b/chrome/android/testshell/testshell_google_location_settings_helper.cc new file mode 100644 index 0000000..fe34ec3 --- /dev/null +++ b/chrome/android/testshell/testshell_google_location_settings_helper.cc @@ -0,0 +1,34 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/android/testshell/testshell_google_location_settings_helper.h" + +// Factory function +GoogleLocationSettingsHelper* GoogleLocationSettingsHelper::Create() { + return new TestShellGoogleLocationSettingsHelper(); +} + +TestShellGoogleLocationSettingsHelper::TestShellGoogleLocationSettingsHelper() + : GoogleLocationSettingsHelper() { +} + +TestShellGoogleLocationSettingsHelper:: + ~TestShellGoogleLocationSettingsHelper() { +} + +std::string TestShellGoogleLocationSettingsHelper::GetAcceptButtonLabel() { + return "Allow"; +} + +void TestShellGoogleLocationSettingsHelper::ShowGoogleLocationSettings() { +} + +bool TestShellGoogleLocationSettingsHelper:: + IsGoogleAppsLocationSettingEnabled() { + return true; +} + +bool TestShellGoogleLocationSettingsHelper::IsMasterLocationSettingEnabled() { + return true; +} diff --git a/chrome/android/testshell/testshell_google_location_settings_helper.h b/chrome/android/testshell/testshell_google_location_settings_helper.h new file mode 100644 index 0000000..5b2cdcc --- /dev/null +++ b/chrome/android/testshell/testshell_google_location_settings_helper.h @@ -0,0 +1,30 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_ANDROID_TESTSHELL_TESTSHELL_GOOGLE_LOCATION_SETTINGS_HELPER_H_ +#define CHROME_ANDROID_TESTSHELL_TESTSHELL_GOOGLE_LOCATION_SETTINGS_HELPER_H_ + +#include "chrome/browser/android/google_location_settings_helper.h" + +// Stub implementation of GoogleLocationSettingsHelper for testshell. +class TestShellGoogleLocationSettingsHelper + : public GoogleLocationSettingsHelper { + public: + // GoogleLocationSettingsHelper implementation: + virtual std::string GetAcceptButtonLabel() OVERRIDE; + virtual void ShowGoogleLocationSettings() OVERRIDE; + virtual bool IsMasterLocationSettingEnabled() OVERRIDE; + virtual bool IsGoogleAppsLocationSettingEnabled() OVERRIDE; + + protected: + TestShellGoogleLocationSettingsHelper(); + virtual ~TestShellGoogleLocationSettingsHelper(); + + private: + friend class GoogleLocationSettingsHelper; + + DISALLOW_COPY_AND_ASSIGN(TestShellGoogleLocationSettingsHelper); +}; + +#endif // CHROME_ANDROID_TESTSHELL_TESTSHELL_GOOGLE_LOCATION_SETTINGS_HELPER_H_ diff --git a/chrome/browser/android/chrome_jni_registrar.cc b/chrome/browser/android/chrome_jni_registrar.cc index dbf80f0..b82c6cc 100644 --- a/chrome/browser/android/chrome_jni_registrar.cc +++ b/chrome/browser/android/chrome_jni_registrar.cc @@ -9,8 +9,6 @@ #include "chrome/browser/android/chrome_web_contents_delegate_android.h" #include "chrome/browser/android/content_view_util.h" #include "chrome/browser/android/dev_tools_server.h" -#include "chrome/browser/android/google_location_settings_helper.h" -#include "chrome/browser/android/google_location_settings_helper_factory.h" #include "chrome/browser/android/intent_helper.h" #include "chrome/browser/android/process_utils.h" #include "chrome/browser/android/provider/chrome_browser_provider.h" @@ -35,10 +33,6 @@ static base::android::RegistrationMethod kChromeRegisteredMethods[] = { RegisterChromeWebContentsDelegateAndroid }, { "ContentViewUtil", RegisterContentViewUtil }, { "DevToolsServer", RegisterDevToolsServer }, - { "GoogleLocationSettingsHelper", - GoogleLocationSettingsHelper::Register }, - { "GoogleLocationSettingsHelperFactory", - GoogleLocationSettingsHelperFactory::Register }, { "IntentHelper", RegisterIntentHelper }, { "JavascriptAppModalDialog", JavascriptAppModalDialogAndroid::RegisterJavascriptAppModalDialog }, diff --git a/chrome/browser/android/google_location_settings_helper.cc b/chrome/browser/android/google_location_settings_helper.cc deleted file mode 100644 index c9d3b4d..0000000 --- a/chrome/browser/android/google_location_settings_helper.cc +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/android/google_location_settings_helper.h" - -#include "base/android/jni_android.h" -#include "base/android/jni_string.h" -#include "jni/GoogleLocationSettingsHelper_jni.h" - -using base::android::AttachCurrentThread; -using base::android::CheckException; -using base::android::ScopedJavaLocalRef; - -GoogleLocationSettingsHelperFactory* - GoogleLocationSettingsHelper::helper_factory_ = NULL; - -GoogleLocationSettingsHelper::GoogleLocationSettingsHelper() { - JNIEnv* env = AttachCurrentThread(); - if (helper_factory_ == NULL) { - SetGoogleLocationSettingsHelperFactory( - new GoogleLocationSettingsHelperFactory()); - } - java_google_location_settings_helper_.Reset(env, - helper_factory_->GetHelperInstance().obj()); -} - -GoogleLocationSettingsHelper::~GoogleLocationSettingsHelper() { -} - -void GoogleLocationSettingsHelper::SetGoogleLocationSettingsHelperFactory( - GoogleLocationSettingsHelperFactory* factory) { - helper_factory_ = factory; -} - -std::string GoogleLocationSettingsHelper::GetAcceptButtonLabel() { - JNIEnv* env = AttachCurrentThread(); - ScopedJavaLocalRef<jstring> infobar_allow_text = - Java_GoogleLocationSettingsHelper_getInfoBarAcceptLabel( - env, java_google_location_settings_helper_.obj()); - return ConvertJavaStringToUTF8(infobar_allow_text); -} - -void GoogleLocationSettingsHelper::ShowGoogleLocationSettings() { - JNIEnv* env = AttachCurrentThread(); - Java_GoogleLocationSettingsHelper_startGoogleLocationSettingsActivity( - env, java_google_location_settings_helper_.obj()); -} - -bool GoogleLocationSettingsHelper::IsGoogleAppsLocationSettingEnabled() { - JNIEnv* env = AttachCurrentThread(); - return Java_GoogleLocationSettingsHelper_isGoogleAppsLocationSettingEnabled( - env, java_google_location_settings_helper_.obj()); -} - -bool GoogleLocationSettingsHelper::IsMasterLocationSettingEnabled() { - JNIEnv* env = AttachCurrentThread(); - return Java_GoogleLocationSettingsHelper_isMasterLocationSettingEnabled( - env, java_google_location_settings_helper_.obj()); -} - -// Register native methods - -bool GoogleLocationSettingsHelper::Register(JNIEnv* env) { - return RegisterNativesImpl(env); -} diff --git a/chrome/browser/android/google_location_settings_helper.h b/chrome/browser/android/google_location_settings_helper.h index e65b87a..6bf5853 100644 --- a/chrome/browser/android/google_location_settings_helper.h +++ b/chrome/browser/android/google_location_settings_helper.h @@ -5,12 +5,7 @@ #ifndef CHROME_BROWSER_ANDROID_GOOGLE_LOCATION_SETTINGS_HELPER_H_ #define CHROME_BROWSER_ANDROID_GOOGLE_LOCATION_SETTINGS_HELPER_H_ -#include "base/android/jni_helper.h" -#include "base/android/scoped_java_ref.h" -#include "base/logging.h" -#include "base/memory/scoped_ptr.h" #include "base/values.h" -#include "chrome/browser/android/google_location_settings_helper_factory.h" // This class is needed to fetch the current system location // setting and update the infobar button label based on that information i.e, @@ -18,21 +13,19 @@ // "Settings" with a link to open the system location settings activity. class GoogleLocationSettingsHelper { public: - GoogleLocationSettingsHelper(); - ~GoogleLocationSettingsHelper(); + virtual ~GoogleLocationSettingsHelper() {} - static void SetGoogleLocationSettingsHelperFactory( - GoogleLocationSettingsHelperFactory* factory); - std::string GetAcceptButtonLabel(); - void ShowGoogleLocationSettings(); - bool IsMasterLocationSettingEnabled(); - bool IsGoogleAppsLocationSettingEnabled(); - static bool Register(JNIEnv* env); + static GoogleLocationSettingsHelper* Create(); + + virtual std::string GetAcceptButtonLabel() = 0; + virtual void ShowGoogleLocationSettings() = 0; + virtual bool IsMasterLocationSettingEnabled() = 0; + virtual bool IsGoogleAppsLocationSettingEnabled() = 0; + + protected: + GoogleLocationSettingsHelper() {} private: - base::android::ScopedJavaGlobalRef<jobject> - java_google_location_settings_helper_; - static GoogleLocationSettingsHelperFactory* helper_factory_; DISALLOW_COPY_AND_ASSIGN(GoogleLocationSettingsHelper); }; diff --git a/chrome/browser/android/google_location_settings_helper_factory.cc b/chrome/browser/android/google_location_settings_helper_factory.cc deleted file mode 100644 index f782500..0000000 --- a/chrome/browser/android/google_location_settings_helper_factory.cc +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/android/google_location_settings_helper_factory.h" - -#include "base/logging.h" -#include "base/android/jni_android.h" -#include "base/android/jni_string.h" -#include "jni/GoogleLocationSettingsHelperStub_jni.h" - -GoogleLocationSettingsHelperFactory::GoogleLocationSettingsHelperFactory() { -} - -GoogleLocationSettingsHelperFactory::~GoogleLocationSettingsHelperFactory() { -} - -const base::android::ScopedJavaGlobalRef<jobject>& - GoogleLocationSettingsHelperFactory::GetHelperInstance() { - JNIEnv* env = base::android::AttachCurrentThread(); - java_google_location_settings_helper_.Reset( - Java_GoogleLocationSettingsHelperStub_createInstance(env, - base::android::GetApplicationContext())); - return java_google_location_settings_helper_; -} - -// Register native methods - -bool GoogleLocationSettingsHelperFactory::Register(JNIEnv* env) { - return RegisterNativesImpl(env); -} diff --git a/chrome/browser/android/google_location_settings_helper_factory.h b/chrome/browser/android/google_location_settings_helper_factory.h deleted file mode 100644 index 8bfaa50..0000000 --- a/chrome/browser/android/google_location_settings_helper_factory.h +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_ANDROID_GOOGLE_LOCATION_SETTINGS_HELPER_FACTORY_H_ -#define CHROME_BROWSER_ANDROID_GOOGLE_LOCATION_SETTINGS_HELPER_FACTORY_H_ - -#include "base/android/jni_helper.h" -#include "base/android/scoped_java_ref.h" -#include "base/values.h" - -/* - * Factory class on chrome side to create the chrome java - * GoogleLocationSettingsHelper object. - */ -class GoogleLocationSettingsHelperFactory { - - public: - GoogleLocationSettingsHelperFactory(); - ~GoogleLocationSettingsHelperFactory(); - virtual const base::android::ScopedJavaGlobalRef<jobject>& - GetHelperInstance(); - static bool Register(JNIEnv* env); - - private: - base::android::ScopedJavaGlobalRef<jobject> - java_google_location_settings_helper_; - - DISALLOW_COPY_AND_ASSIGN(GoogleLocationSettingsHelperFactory); -}; - -#endif // CHROME_BROWSER_ANDROID_GOOGLE_LOCATION_SETTINGS_HELPER_FACTORY_H_ diff --git a/chrome/browser/android/mock_google_location_settings_helper.cc b/chrome/browser/android/mock_google_location_settings_helper.cc new file mode 100644 index 0000000..7d5d97e --- /dev/null +++ b/chrome/browser/android/mock_google_location_settings_helper.cc @@ -0,0 +1,48 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/android/mock_google_location_settings_helper.h" + +bool MockGoogleLocationSettingsHelper::master_location_enabled = false; +bool MockGoogleLocationSettingsHelper::google_apps_location_enabled = false; +bool MockGoogleLocationSettingsHelper::was_google_location_settings_called + = false; + +// Factory function +GoogleLocationSettingsHelper* GoogleLocationSettingsHelper::Create() { + return new MockGoogleLocationSettingsHelper(); +} + +MockGoogleLocationSettingsHelper::MockGoogleLocationSettingsHelper() + : GoogleLocationSettingsHelper() { +} + +MockGoogleLocationSettingsHelper::~MockGoogleLocationSettingsHelper() { +} + +void MockGoogleLocationSettingsHelper::SetLocationStatus( + bool master, bool google_apps) { + master_location_enabled = master; + google_apps_location_enabled = google_apps; +} + +std::string MockGoogleLocationSettingsHelper::GetAcceptButtonLabel() { + return google_apps_location_enabled ? "Allow" : "Settings"; +} + +void MockGoogleLocationSettingsHelper::ShowGoogleLocationSettings() { + was_google_location_settings_called = true; +} + +bool MockGoogleLocationSettingsHelper::IsGoogleAppsLocationSettingEnabled() { + return google_apps_location_enabled; +} + +bool MockGoogleLocationSettingsHelper::IsMasterLocationSettingEnabled() { + return master_location_enabled; +} + +bool MockGoogleLocationSettingsHelper::WasGoogleLocationSettingsCalled() { + return was_google_location_settings_called; +} diff --git a/chrome/browser/android/mock_google_location_settings_helper.h b/chrome/browser/android/mock_google_location_settings_helper.h new file mode 100644 index 0000000..328f2a9 --- /dev/null +++ b/chrome/browser/android/mock_google_location_settings_helper.h @@ -0,0 +1,36 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_ANDROID_MOCK_GOOGLE_LOCATION_SETTINGS_HELPER_H_ +#define CHROME_BROWSER_ANDROID_MOCK_GOOGLE_LOCATION_SETTINGS_HELPER_H_ + +#include "chrome/browser/android/google_location_settings_helper.h" + +// Mock implementation of GoogleLocationSettingsHelper for unit tests. +class MockGoogleLocationSettingsHelper : public GoogleLocationSettingsHelper { + public: + static void SetLocationStatus(bool master, bool google_apps); + static bool WasGoogleLocationSettingsCalled(); + + // GoogleLocationSettingsHelper implementation: + virtual std::string GetAcceptButtonLabel() OVERRIDE; + virtual void ShowGoogleLocationSettings() OVERRIDE; + virtual bool IsMasterLocationSettingEnabled() OVERRIDE; + virtual bool IsGoogleAppsLocationSettingEnabled() OVERRIDE; + + protected: + MockGoogleLocationSettingsHelper(); + virtual ~MockGoogleLocationSettingsHelper(); + + private: + friend class GoogleLocationSettingsHelper; + + static bool master_location_enabled; + static bool google_apps_location_enabled; + static bool was_google_location_settings_called; + + DISALLOW_COPY_AND_ASSIGN(MockGoogleLocationSettingsHelper); +}; + +#endif // CHROME_BROWSER_ANDROID_MOCK_GOOGLE_LOCATION_SETTINGS_HELPER_H_ 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_ diff --git a/chrome/chrome_android.gypi b/chrome/chrome_android.gypi index 14475c5..a08f23c 100644 --- a/chrome/chrome_android.gypi +++ b/chrome/chrome_android.gypi @@ -22,6 +22,8 @@ 'android/testshell/tab_manager.cc', 'android/testshell/tab_manager.h', 'android/testshell/testshell_entry_point.cc', + "android/testshell/testshell_google_location_settings_helper.cc", + "android/testshell/testshell_google_location_settings_helper.h", 'android/testshell/testshell_stubs.cc', ], 'include_dirs': [ diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index 3fa7d77..2763565 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -90,10 +90,7 @@ 'browser/android/crash_dump_manager.h', 'browser/android/dev_tools_server.cc', 'browser/android/dev_tools_server.h', - 'browser/android/google_location_settings_helper.cc', 'browser/android/google_location_settings_helper.h', - 'browser/android/google_location_settings_helper_factory.cc', - 'browser/android/google_location_settings_helper_factory.h', 'browser/android/intent_helper.cc', 'browser/android/intent_helper.h', 'browser/android/process_utils.cc', @@ -2981,8 +2978,6 @@ 'android/java/src/org/chromium/chrome/browser/ChromeWebContentsDelegateAndroid.java', 'android/java/src/org/chromium/chrome/browser/ContentViewUtil.java', 'android/java/src/org/chromium/chrome/browser/DevToolsServer.java', - 'android/java/src/org/chromium/chrome/browser/GoogleLocationSettingsHelper.java', - 'android/java/src/org/chromium/chrome/browser/GoogleLocationSettingsHelperStub.java', 'android/java/src/org/chromium/chrome/browser/IntentHelper.java', 'android/java/src/org/chromium/chrome/browser/JavascriptAppModalDialog.java', 'android/java/src/org/chromium/chrome/browser/ProcessUtils.java', diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi index 5d0378c..b47f4ac 100644 --- a/chrome/chrome_tests.gypi +++ b/chrome/chrome_tests.gypi @@ -81,6 +81,8 @@ 'app/breakpad_mac_stubs.mm', 'app/chrome_main_delegate.cc', 'app/chrome_main_delegate.h', + 'browser/android/mock_google_location_settings_helper.cc', + 'browser/android/mock_google_location_settings_helper.h', 'browser/android/tab_android_test_stubs.cc', 'browser/autofill/autofill_common_test.cc', 'browser/autofill/autofill_common_test.h', |