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" | 10 #include "chrome/browser/infobars/infobar.h" |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 InfoBar* GeolocationInfoBarDelegate::Create( | 65 InfoBar* GeolocationInfoBarDelegate::Create( |
66 InfoBarService* infobar_service, | 66 InfoBarService* infobar_service, |
67 PermissionQueueController* controller, | 67 PermissionQueueController* controller, |
68 const PermissionRequestID& id, | 68 const PermissionRequestID& id, |
69 const GURL& requesting_frame, | 69 const GURL& requesting_frame, |
70 const std::string& display_languages, | 70 const std::string& display_languages, |
71 const std::string& accept_button_label) { | 71 const std::string& accept_button_label) { |
72 RecordUmaEvent(GEOLOCATION_INFO_BAR_DELEGATE_EVENT_CREATE); | 72 RecordUmaEvent(GEOLOCATION_INFO_BAR_DELEGATE_EVENT_CREATE); |
73 const content::NavigationEntry* committed_entry = | 73 const content::NavigationEntry* committed_entry = |
74 infobar_service->web_contents()->GetController().GetLastCommittedEntry(); | 74 infobar_service->web_contents()->GetController().GetLastCommittedEntry(); |
75 GeolocationInfoBarDelegate* const delegate = new DelegateType( | 75 GeolocationInfoBarDelegate* const delegate = |
76 controller, id, requesting_frame, | 76 new DelegateType(infobar_service->web_contents(), |
77 committed_entry ? committed_entry->GetUniqueID() : 0, | 77 controller, |
78 display_languages, accept_button_label); | 78 id, |
| 79 requesting_frame, |
| 80 committed_entry ? committed_entry->GetUniqueID() : 0, |
| 81 display_languages, |
| 82 accept_button_label); |
79 | 83 |
80 InfoBar* infobar = ConfirmInfoBarDelegate::CreateInfoBar( | 84 InfoBar* infobar = ConfirmInfoBarDelegate::CreateInfoBar( |
81 scoped_ptr<ConfirmInfoBarDelegate>(delegate)).release(); | 85 scoped_ptr<ConfirmInfoBarDelegate>(delegate)).release(); |
82 return infobar_service->AddInfoBar(scoped_ptr<InfoBar>(infobar)); | 86 return infobar_service->AddInfoBar(scoped_ptr<InfoBar>(infobar)); |
83 } | 87 } |
84 | 88 |
85 GeolocationInfoBarDelegate::GeolocationInfoBarDelegate( | 89 GeolocationInfoBarDelegate::GeolocationInfoBarDelegate( |
| 90 content::WebContents* web_contents, |
86 PermissionQueueController* controller, | 91 PermissionQueueController* controller, |
87 const PermissionRequestID& id, | 92 const PermissionRequestID& id, |
88 const GURL& requesting_frame, | 93 const GURL& requesting_frame, |
89 int contents_unique_id, | 94 int contents_unique_id, |
90 const std::string& display_languages, | 95 const std::string& display_languages, |
91 const std::string& accept_button_label) | 96 const std::string& accept_button_label) |
92 : ConfirmInfoBarDelegate(), | 97 : ContentConfirmInfoBarDelegate(web_contents), |
93 controller_(controller), | 98 controller_(controller), |
94 id_(id), | 99 id_(id), |
95 requesting_frame_(requesting_frame.GetOrigin()), | 100 requesting_frame_(requesting_frame.GetOrigin()), |
96 contents_unique_id_(contents_unique_id), | 101 contents_unique_id_(contents_unique_id), |
97 display_languages_(display_languages), | 102 display_languages_(display_languages), |
98 user_has_interacted_(false) { | 103 user_has_interacted_(false) {} |
99 } | |
100 | 104 |
101 GeolocationInfoBarDelegate::~GeolocationInfoBarDelegate() { | 105 GeolocationInfoBarDelegate::~GeolocationInfoBarDelegate() { |
102 if (!user_has_interacted_) | 106 if (!user_has_interacted_) |
103 RecordUmaEvent(GEOLOCATION_INFO_BAR_DELEGATE_EVENT_IGNORED); | 107 RecordUmaEvent(GEOLOCATION_INFO_BAR_DELEGATE_EVENT_IGNORED); |
104 } | 108 } |
105 | 109 |
106 bool GeolocationInfoBarDelegate::Accept() { | 110 bool GeolocationInfoBarDelegate::Accept() { |
107 RecordUmaEvent(GEOLOCATION_INFO_BAR_DELEGATE_EVENT_ALLOW); | 111 RecordUmaEvent(GEOLOCATION_INFO_BAR_DELEGATE_EVENT_ALLOW); |
108 set_user_has_interacted(); | 112 set_user_has_interacted(); |
109 SetPermission(true, true); | 113 SetPermission(true, true); |
(...skipping 16 matching lines...) Expand all Loading... |
126 | 130 |
127 int GeolocationInfoBarDelegate::GetIconID() const { | 131 int GeolocationInfoBarDelegate::GetIconID() const { |
128 return IDR_GEOLOCATION_INFOBAR_ICON; | 132 return IDR_GEOLOCATION_INFOBAR_ICON; |
129 } | 133 } |
130 | 134 |
131 InfoBarDelegate::Type GeolocationInfoBarDelegate::GetInfoBarType() const { | 135 InfoBarDelegate::Type GeolocationInfoBarDelegate::GetInfoBarType() const { |
132 return PAGE_ACTION_TYPE; | 136 return PAGE_ACTION_TYPE; |
133 } | 137 } |
134 | 138 |
135 bool GeolocationInfoBarDelegate::ShouldExpireInternal( | 139 bool GeolocationInfoBarDelegate::ShouldExpireInternal( |
136 const content::LoadCommittedDetails& details) const { | 140 const NavigationDetails& details) const { |
137 // This implementation matches InfoBarDelegate::ShouldExpireInternal(), but | 141 // This implementation matches InfoBarDelegate::ShouldExpireInternal(), but |
138 // uses the unique ID we set in the constructor instead of that stored in the | 142 // uses the unique ID we set in the constructor instead of that stored in the |
139 // base class. | 143 // base class. |
140 return (contents_unique_id_ != details.entry->GetUniqueID()) || | 144 return (contents_unique_id_ != details.entry_id) || details.is_reload; |
141 (content::PageTransitionStripQualifier( | |
142 details.entry->GetTransitionType()) == | |
143 content::PAGE_TRANSITION_RELOAD); | |
144 } | 145 } |
145 | 146 |
146 base::string16 GeolocationInfoBarDelegate::GetMessageText() const { | 147 base::string16 GeolocationInfoBarDelegate::GetMessageText() const { |
147 return l10n_util::GetStringFUTF16(IDS_GEOLOCATION_INFOBAR_QUESTION, | 148 return l10n_util::GetStringFUTF16(IDS_GEOLOCATION_INFOBAR_QUESTION, |
148 net::FormatUrl(requesting_frame_, display_languages_)); | 149 net::FormatUrl(requesting_frame_, display_languages_)); |
149 } | 150 } |
150 | 151 |
151 base::string16 GeolocationInfoBarDelegate::GetButtonLabel( | 152 base::string16 GeolocationInfoBarDelegate::GetButtonLabel( |
152 InfoBarButton button) const { | 153 InfoBarButton button) const { |
153 return l10n_util::GetStringUTF16((button == BUTTON_OK) ? | 154 return l10n_util::GetStringUTF16((button == BUTTON_OK) ? |
(...skipping 23 matching lines...) Expand all Loading... |
177 "https://www.google.com/support/chrome/bin/answer.py?answer=142065"; | 178 "https://www.google.com/support/chrome/bin/answer.py?answer=142065"; |
178 #endif | 179 #endif |
179 | 180 |
180 web_contents()->OpenURL(content::OpenURLParams( | 181 web_contents()->OpenURL(content::OpenURLParams( |
181 google_util::AppendGoogleLocaleParam(GURL(kGeolocationLearnMoreUrl)), | 182 google_util::AppendGoogleLocaleParam(GURL(kGeolocationLearnMoreUrl)), |
182 content::Referrer(), | 183 content::Referrer(), |
183 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, | 184 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, |
184 content::PAGE_TRANSITION_LINK, false)); | 185 content::PAGE_TRANSITION_LINK, false)); |
185 return false; // Do not dismiss the info bar. | 186 return false; // Do not dismiss the info bar. |
186 } | 187 } |
OLD | NEW |