OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "chrome/browser/geolocation/geolocation_infobar_delegate_android.h" | |
6 | |
7 #include "base/metrics/histogram.h" | |
8 #include "base/strings/utf_string_conversions.h" | |
9 #include "chrome/browser/android/google_location_settings_helper.h" | |
10 #include "grit/generated_resources.h" | |
11 #include "grit/locale_settings.h" | |
12 #include "grit/theme_resources.h" | |
13 #include "ui/base/l10n/l10n_util.h" | |
14 | |
15 namespace { | |
16 enum GeolocationInfoBarDelegateAndroidEvent { | |
17 // NOTE: Do not renumber these as that would confuse interpretation of | |
18 // previously logged data. When making changes, also update the enum list | |
19 // in tools/metrics/histograms/histograms.xml to keep it in sync. | |
20 | |
21 // User allowed the page to use geolocation. | |
22 GEOLOCATION_INFO_BAR_DELEGATE_ANDROID_EVENT_ALLOW = 0, | |
23 | |
24 // User opened geolocation settings. | |
25 GEOLOCATION_INFO_BAR_DELEGATE_ANDROID_EVENT_SETTINGS = 1, | |
26 | |
27 // NOTE: Add entries only immediately above this line. | |
28 GEOLOCATION_INFO_BAR_DELEGATE_ANDROID_EVENT_COUNT = 2 | |
29 }; | |
30 | |
31 void RecordUmaEvent(GeolocationInfoBarDelegateAndroidEvent event) { | |
32 UMA_HISTOGRAM_ENUMERATION("Geolocation.InfoBarDelegateAndroid.Event", | |
33 event, GEOLOCATION_INFO_BAR_DELEGATE_ANDROID_EVENT_COUNT); | |
34 } | |
35 } // namespace | |
36 | |
37 GeolocationInfoBarDelegateAndroid::GeolocationInfoBarDelegateAndroid( | |
38 PermissionQueueController* controller, | |
39 const PermissionRequestID& id, | |
40 const GURL& requesting_frame_url, | |
41 int contents_unique_id, | |
42 const std::string& display_languages, | |
43 const std::string& accept_button_label) | |
44 : GeolocationInfoBarDelegate(controller, id, requesting_frame_url, | |
45 contents_unique_id, display_languages, | |
46 accept_button_label_), | |
47 google_location_settings_helper_( | |
48 GoogleLocationSettingsHelper::Create()), | |
49 accept_button_label_(accept_button_label) { | |
50 } | |
51 | |
52 GeolocationInfoBarDelegateAndroid::~GeolocationInfoBarDelegateAndroid() { | |
53 } | |
54 | |
55 bool GeolocationInfoBarDelegateAndroid::Accept() { | |
56 set_user_has_interacted(); | |
57 | |
58 // Accept button text could be either 'Allow' or 'Google Location Settings'. | |
59 // If 'Allow' we follow the regular flow. | |
60 if (google_location_settings_helper_->IsGoogleAppsLocationSettingEnabled()) { | |
61 RecordUmaEvent(GEOLOCATION_INFO_BAR_DELEGATE_ANDROID_EVENT_ALLOW); | |
62 return GeolocationInfoBarDelegate::Accept(); | |
63 } | |
64 | |
65 // If 'Google Location Settings', we need to open the system Google Location | |
66 // Settings activity. | |
67 RecordUmaEvent(GEOLOCATION_INFO_BAR_DELEGATE_ANDROID_EVENT_SETTINGS); | |
68 google_location_settings_helper_->ShowGoogleLocationSettings(); | |
69 SetPermission(false, false); | |
70 return true; | |
71 } | |
72 | |
73 base::string16 GeolocationInfoBarDelegateAndroid::GetButtonLabel( | |
74 InfoBarButton button) const { | |
75 return (button == BUTTON_OK) ? | |
76 base::UTF8ToUTF16(accept_button_label_ ) : | |
77 l10n_util::GetStringUTF16(IDS_GEOLOCATION_DENY_BUTTON); | |
78 } | |
OLD | NEW |