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/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "chrome/browser/android/google_location_settings_helper.h" | 9 #include "chrome/browser/android/google_location_settings_helper.h" |
10 #include "grit/generated_resources.h" | 10 #include "grit/generated_resources.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 UMA_HISTOGRAM_ENUMERATION("Geolocation.InfoBarDelegateAndroid.Event", | 32 UMA_HISTOGRAM_ENUMERATION("Geolocation.InfoBarDelegateAndroid.Event", |
33 event, GEOLOCATION_INFO_BAR_DELEGATE_ANDROID_EVENT_COUNT); | 33 event, GEOLOCATION_INFO_BAR_DELEGATE_ANDROID_EVENT_COUNT); |
34 } | 34 } |
35 } // namespace | 35 } // namespace |
36 | 36 |
37 GeolocationInfoBarDelegateAndroid::GeolocationInfoBarDelegateAndroid( | 37 GeolocationInfoBarDelegateAndroid::GeolocationInfoBarDelegateAndroid( |
38 PermissionQueueController* controller, | 38 PermissionQueueController* controller, |
39 const PermissionRequestID& id, | 39 const PermissionRequestID& id, |
40 const GURL& requesting_frame_url, | 40 const GURL& requesting_frame_url, |
41 int contents_unique_id, | 41 int contents_unique_id, |
42 const std::string& display_languages) | 42 const std::string& display_languages, |
| 43 const std::string accept_button_label) |
43 : GeolocationInfoBarDelegate(controller, id, requesting_frame_url, | 44 : GeolocationInfoBarDelegate(controller, id, requesting_frame_url, |
44 contents_unique_id, display_languages), | 45 contents_unique_id, display_languages), |
45 google_location_settings_helper_( | 46 google_location_settings_helper_( |
46 GoogleLocationSettingsHelper::Create()) { | 47 GoogleLocationSettingsHelper::Create()), |
| 48 accept_button_label_(accept_button_label) { |
47 } | 49 } |
48 | 50 |
49 GeolocationInfoBarDelegateAndroid::~GeolocationInfoBarDelegateAndroid() { | 51 GeolocationInfoBarDelegateAndroid::~GeolocationInfoBarDelegateAndroid() { |
50 } | 52 } |
51 | 53 |
52 bool GeolocationInfoBarDelegateAndroid::Accept() { | 54 bool GeolocationInfoBarDelegateAndroid::Accept() { |
53 set_user_has_interacted(); | 55 set_user_has_interacted(); |
54 | 56 |
55 // Accept button text could be either 'Allow' or 'Google Location Settings'. | 57 // Accept button text could be either 'Allow' or 'Google Location Settings'. |
56 // If 'Allow' we follow the regular flow. | 58 // If 'Allow' we follow the regular flow. |
57 if (google_location_settings_helper_->IsGoogleAppsLocationSettingEnabled()) { | 59 if (google_location_settings_helper_->IsGoogleAppsLocationSettingEnabled()) { |
58 RecordUmaEvent(GEOLOCATION_INFO_BAR_DELEGATE_ANDROID_EVENT_ALLOW); | 60 RecordUmaEvent(GEOLOCATION_INFO_BAR_DELEGATE_ANDROID_EVENT_ALLOW); |
59 return GeolocationInfoBarDelegate::Accept(); | 61 return GeolocationInfoBarDelegate::Accept(); |
60 } | 62 } |
61 | 63 |
62 // If 'Google Location Settings', we need to open the system Google Location | 64 // If 'Google Location Settings', we need to open the system Google Location |
63 // Settings activity. | 65 // Settings activity. |
64 RecordUmaEvent(GEOLOCATION_INFO_BAR_DELEGATE_ANDROID_EVENT_SETTINGS); | 66 RecordUmaEvent(GEOLOCATION_INFO_BAR_DELEGATE_ANDROID_EVENT_SETTINGS); |
65 google_location_settings_helper_->ShowGoogleLocationSettings(); | 67 google_location_settings_helper_->ShowGoogleLocationSettings(); |
66 SetPermission(false, false); | 68 SetPermission(false, false); |
67 return true; | 69 return true; |
68 } | 70 } |
69 | 71 |
70 base::string16 GeolocationInfoBarDelegateAndroid::GetButtonLabel( | 72 base::string16 GeolocationInfoBarDelegateAndroid::GetButtonLabel( |
71 InfoBarButton button) const { | 73 InfoBarButton button) const { |
72 return (button == BUTTON_OK) ? | 74 return (button == BUTTON_OK) ? |
73 base::UTF8ToUTF16( | 75 base::UTF8ToUTF16(accept_button_label_ ) : |
74 google_location_settings_helper_->GetAcceptButtonLabel()) : | |
75 l10n_util::GetStringUTF16(IDS_GEOLOCATION_DENY_BUTTON); | 76 l10n_util::GetStringUTF16(IDS_GEOLOCATION_DENY_BUTTON); |
76 } | 77 } |
OLD | NEW |