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.h" | 5 #include "chrome/browser/geolocation/geolocation_infobar_delegate.h" |
6 | 6 |
7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
8 #include "chrome/browser/content_settings/permission_queue_controller.h" | 8 #include "chrome/browser/content_settings/permission_queue_controller.h" |
9 #include "chrome/browser/google/google_util.h" | 9 #include "chrome/browser/google/google_util.h" |
10 #include "chrome/browser/infobars/infobar.h" | |
11 #include "chrome/browser/infobars/infobar_service.h" | 10 #include "chrome/browser/infobars/infobar_service.h" |
12 #include "content/public/browser/navigation_details.h" | 11 #include "content/public/browser/navigation_details.h" |
13 #include "content/public/browser/navigation_entry.h" | 12 #include "content/public/browser/navigation_entry.h" |
14 #include "content/public/browser/web_contents.h" | 13 #include "content/public/browser/web_contents.h" |
15 #include "grit/generated_resources.h" | 14 #include "grit/generated_resources.h" |
16 #include "grit/locale_settings.h" | 15 #include "grit/locale_settings.h" |
17 #include "grit/theme_resources.h" | 16 #include "grit/theme_resources.h" |
18 #include "net/base/net_util.h" | 17 #include "net/base/net_util.h" |
19 #include "ui/base/l10n/l10n_util.h" | 18 #include "ui/base/l10n/l10n_util.h" |
20 | 19 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 }; | 54 }; |
56 | 55 |
57 void RecordUmaEvent(GeolocationInfoBarDelegateEvent event) { | 56 void RecordUmaEvent(GeolocationInfoBarDelegateEvent event) { |
58 UMA_HISTOGRAM_ENUMERATION("Geolocation.InfoBarDelegate.Event", | 57 UMA_HISTOGRAM_ENUMERATION("Geolocation.InfoBarDelegate.Event", |
59 event, GEOLOCATION_INFO_BAR_DELEGATE_EVENT_COUNT); | 58 event, GEOLOCATION_INFO_BAR_DELEGATE_EVENT_COUNT); |
60 } | 59 } |
61 | 60 |
62 } // namespace | 61 } // namespace |
63 | 62 |
64 // static | 63 // static |
65 InfoBar* GeolocationInfoBarDelegate::Create( | 64 InfoBarDelegate* GeolocationInfoBarDelegate::Create( |
66 InfoBarService* infobar_service, | 65 InfoBarService* infobar_service, |
67 PermissionQueueController* controller, | 66 PermissionQueueController* controller, |
68 const PermissionRequestID& id, | 67 const PermissionRequestID& id, |
69 const GURL& requesting_frame, | 68 const GURL& requesting_frame, |
70 const std::string& display_languages) { | 69 const std::string& display_languages) { |
71 RecordUmaEvent(GEOLOCATION_INFO_BAR_DELEGATE_EVENT_CREATE); | 70 RecordUmaEvent(GEOLOCATION_INFO_BAR_DELEGATE_EVENT_CREATE); |
72 const content::NavigationEntry* committed_entry = | 71 const content::NavigationEntry* committed_entry = |
73 infobar_service->web_contents()->GetController().GetLastCommittedEntry(); | 72 infobar_service->web_contents()->GetController().GetLastCommittedEntry(); |
74 return infobar_service->AddInfoBar(ConfirmInfoBarDelegate::CreateInfoBar( | 73 return infobar_service->AddInfoBar(scoped_ptr<InfoBarDelegate>( |
75 scoped_ptr<ConfirmInfoBarDelegate>(new DelegateType( | 74 new DelegateType(infobar_service, controller, id, requesting_frame, |
76 controller, id, requesting_frame, | 75 committed_entry ? committed_entry->GetUniqueID() : 0, |
77 committed_entry ? committed_entry->GetUniqueID() : 0, | 76 display_languages))); |
78 display_languages)))); | |
79 } | 77 } |
80 | 78 |
81 GeolocationInfoBarDelegate::GeolocationInfoBarDelegate( | 79 GeolocationInfoBarDelegate::GeolocationInfoBarDelegate( |
| 80 InfoBarService* infobar_service, |
82 PermissionQueueController* controller, | 81 PermissionQueueController* controller, |
83 const PermissionRequestID& id, | 82 const PermissionRequestID& id, |
84 const GURL& requesting_frame, | 83 const GURL& requesting_frame, |
85 int contents_unique_id, | 84 int contents_unique_id, |
86 const std::string& display_languages) | 85 const std::string& display_languages) |
87 : ConfirmInfoBarDelegate(), | 86 : ConfirmInfoBarDelegate(infobar_service), |
88 controller_(controller), | 87 controller_(controller), |
89 id_(id), | 88 id_(id), |
90 requesting_frame_(requesting_frame.GetOrigin()), | 89 requesting_frame_(requesting_frame.GetOrigin()), |
91 contents_unique_id_(contents_unique_id), | 90 contents_unique_id_(contents_unique_id), |
92 display_languages_(display_languages), | 91 display_languages_(display_languages), |
93 user_has_interacted_(false) { | 92 user_has_interacted_(false) { |
94 } | 93 } |
95 | 94 |
96 GeolocationInfoBarDelegate::~GeolocationInfoBarDelegate() { | 95 GeolocationInfoBarDelegate::~GeolocationInfoBarDelegate() { |
97 if (!user_has_interacted_) | 96 if (!user_has_interacted_) |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 "https://www.google.com/support/chrome/bin/answer.py?answer=142065"; | 171 "https://www.google.com/support/chrome/bin/answer.py?answer=142065"; |
173 #endif | 172 #endif |
174 | 173 |
175 web_contents()->OpenURL(content::OpenURLParams( | 174 web_contents()->OpenURL(content::OpenURLParams( |
176 google_util::AppendGoogleLocaleParam(GURL(kGeolocationLearnMoreUrl)), | 175 google_util::AppendGoogleLocaleParam(GURL(kGeolocationLearnMoreUrl)), |
177 content::Referrer(), | 176 content::Referrer(), |
178 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, | 177 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, |
179 content::PAGE_TRANSITION_LINK, false)); | 178 content::PAGE_TRANSITION_LINK, false)); |
180 return false; // Do not dismiss the info bar. | 179 return false; // Do not dismiss the info bar. |
181 } | 180 } |
OLD | NEW |