Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/geolocation/geolocation_infobar_delegate_android.h" | 5 #include "chrome/browser/geolocation/geolocation_infobar_delegate_android.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | |
| 8 #include "base/bind_helpers.h" | |
| 9 #include "base/callback.h" | |
| 10 #include "base/location.h" | |
| 7 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 12 #include "base/threading/worker_pool.h" | |
| 8 #include "chrome/browser/android/google_location_settings_helper.h" | 13 #include "chrome/browser/android/google_location_settings_helper.h" |
| 14 #include "content/public/browser/browser_thread.h" | |
| 9 #include "grit/generated_resources.h" | 15 #include "grit/generated_resources.h" |
| 10 #include "grit/locale_settings.h" | 16 #include "grit/locale_settings.h" |
| 11 #include "grit/theme_resources.h" | 17 #include "grit/theme_resources.h" |
| 12 #include "ui/base/l10n/l10n_util.h" | 18 #include "ui/base/l10n/l10n_util.h" |
| 13 | 19 |
| 14 GeolocationInfoBarDelegateAndroid::GeolocationInfoBarDelegateAndroid( | 20 GeolocationInfoBarDelegateAndroid::GeolocationInfoBarDelegateAndroid( |
| 15 InfoBarService* infobar_service, | 21 InfoBarService* infobar_service, |
| 16 PermissionQueueController* controller, | 22 PermissionQueueController* controller, |
| 17 const PermissionRequestID& id, | 23 const PermissionRequestID& id, |
| 18 const GURL& requesting_frame_url, | 24 const GURL& requesting_frame_url, |
| 19 int contents_unique_id, | 25 int contents_unique_id, |
| 20 const std::string& display_languages) | 26 const std::string& display_languages) |
| 21 : GeolocationInfoBarDelegate(infobar_service, controller, id, | 27 : GeolocationInfoBarDelegate(infobar_service, controller, id, |
| 22 requesting_frame_url, contents_unique_id, | 28 requesting_frame_url, contents_unique_id, |
| 23 display_languages), | 29 display_languages), |
| 24 google_location_settings_helper_( | 30 google_location_settings_helper_( |
| 25 GoogleLocationSettingsHelper::Create()) { | 31 GoogleLocationSettingsHelper::Create()), |
| 32 is_allow_label_(false) { | |
| 26 } | 33 } |
| 27 | 34 |
| 28 GeolocationInfoBarDelegateAndroid::~GeolocationInfoBarDelegateAndroid() { | 35 GeolocationInfoBarDelegateAndroid::~GeolocationInfoBarDelegateAndroid() { |
| 29 } | 36 } |
| 30 | 37 |
| 38 void GeolocationInfoBarDelegateAndroid::Show( | |
| 39 InfoBarService* infobar_service) { | |
| 40 base::WorkerPool::PostTask(FROM_HERE, | |
| 41 base::Bind(&GeolocationInfoBarDelegateAndroid::CheckLocationSettings, | |
| 42 base::Unretained(this), | |
|
bulach
2013/09/12 09:18:29
this won't work... :(
the infobar could be deleted
acleung1
2013/09/17 00:08:45
Hmm I understood the concern but I don't really fo
bulach
2013/10/16 10:47:11
see above..
| |
| 43 infobar_service), true); | |
| 44 } | |
| 45 | |
| 46 void GeolocationInfoBarDelegateAndroid::CallParentShow( | |
| 47 InfoBarService* infobar_service) { | |
| 48 GeolocationInfoBarDelegate::Show(infobar_service); | |
| 49 } | |
| 50 | |
| 51 void GeolocationInfoBarDelegateAndroid::CheckLocationSettings( | |
| 52 InfoBarService* infobar_service) { | |
| 53 is_allow_label_ = google_location_settings_helper_->IsAllowLabel(); | |
| 54 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, | |
| 55 base::Bind(&GeolocationInfoBarDelegateAndroid::CallParentShow, | |
| 56 base::Unretained(this), infobar_service)); | |
| 57 } | |
| 58 | |
| 31 bool GeolocationInfoBarDelegateAndroid::Accept() { | 59 bool GeolocationInfoBarDelegateAndroid::Accept() { |
| 32 // Accept button text could be either 'Allow' or 'Google Location Settings'. | 60 // Accept button text could be either 'Allow' or 'Google Location Settings'. |
| 33 // If 'Allow' we follow the regular flow. | 61 // If 'Allow' we follow the regular flow. |
| 34 if (google_location_settings_helper_->IsGoogleAppsLocationSettingEnabled()) | 62 if (google_location_settings_helper_->IsGoogleAppsLocationSettingEnabled()) |
| 35 return GeolocationInfoBarDelegate::Accept(); | 63 return GeolocationInfoBarDelegate::Accept(); |
| 36 | 64 |
| 37 // If 'Google Location Settings', we need to open the system Google Location | 65 // If 'Google Location Settings', we need to open the system Google Location |
| 38 // Settings activity. | 66 // Settings activity. |
| 39 google_location_settings_helper_->ShowGoogleLocationSettings(); | 67 google_location_settings_helper_->ShowGoogleLocationSettings(); |
| 40 SetPermission(false, false); | 68 SetPermission(false, false); |
| 41 return true; | 69 return true; |
| 42 } | 70 } |
| 43 | 71 |
| 44 string16 GeolocationInfoBarDelegateAndroid::GetButtonLabel( | 72 string16 GeolocationInfoBarDelegateAndroid::GetButtonLabel( |
| 45 InfoBarButton button) const { | 73 InfoBarButton button) const { |
| 46 return (button == BUTTON_OK) ? | 74 return (button == BUTTON_OK) ? UTF8ToUTF16( |
| 47 UTF8ToUTF16(google_location_settings_helper_->GetAcceptButtonLabel()) : | 75 google_location_settings_helper_->GetAcceptButtonLabel(is_allow_label_)) : |
| 48 l10n_util::GetStringUTF16(IDS_GEOLOCATION_DENY_BUTTON); | 76 l10n_util::GetStringUTF16(IDS_GEOLOCATION_DENY_BUTTON); |
| 49 } | 77 } |
| OLD | NEW |