| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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/infobars/infobar_service.h" | 9 #include "chrome/browser/infobars/infobar_service.h" |
| 10 #include "chrome/grit/generated_resources.h" | 10 #include "chrome/grit/generated_resources.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 const PermissionRequestID& id, | 28 const PermissionRequestID& id, |
| 29 const GURL& requesting_frame, | 29 const GURL& requesting_frame, |
| 30 const std::string& display_languages) { | 30 const std::string& display_languages) { |
| 31 const content::NavigationEntry* committed_entry = | 31 const content::NavigationEntry* committed_entry = |
| 32 infobar_service->web_contents()->GetController().GetLastCommittedEntry(); | 32 infobar_service->web_contents()->GetController().GetLastCommittedEntry(); |
| 33 GeolocationInfoBarDelegate* const delegate = new GeolocationInfoBarDelegate( | 33 GeolocationInfoBarDelegate* const delegate = new GeolocationInfoBarDelegate( |
| 34 controller, id, requesting_frame, | 34 controller, id, requesting_frame, |
| 35 committed_entry ? committed_entry->GetUniqueID() : 0, | 35 committed_entry ? committed_entry->GetUniqueID() : 0, |
| 36 display_languages); | 36 display_languages); |
| 37 | 37 |
| 38 infobars::InfoBar* infobar = ConfirmInfoBarDelegate::CreateInfoBar( | 38 scoped_ptr<infobars::InfoBar> infobar(ConfirmInfoBarDelegate::CreateInfoBar( |
| 39 scoped_ptr<ConfirmInfoBarDelegate>(delegate)).release(); | 39 infobar_service, scoped_ptr<ConfirmInfoBarDelegate>(delegate))); |
| 40 return infobar_service->AddInfoBar(scoped_ptr<infobars::InfoBar>(infobar)); | 40 return infobar_service->AddInfoBar(infobar.Pass()); |
| 41 } | 41 } |
| 42 | 42 |
| 43 GeolocationInfoBarDelegate::GeolocationInfoBarDelegate( | 43 GeolocationInfoBarDelegate::GeolocationInfoBarDelegate( |
| 44 PermissionQueueController* controller, | 44 PermissionQueueController* controller, |
| 45 const PermissionRequestID& id, | 45 const PermissionRequestID& id, |
| 46 const GURL& requesting_frame, | 46 const GURL& requesting_frame, |
| 47 int contents_unique_id, | 47 int contents_unique_id, |
| 48 const std::string& display_languages) | 48 const std::string& display_languages) |
| 49 : PermissionInfobarDelegate(controller, id, requesting_frame, | 49 : PermissionInfobarDelegate(controller, id, requesting_frame, |
| 50 CONTENT_SETTINGS_TYPE_GEOLOCATION), | 50 CONTENT_SETTINGS_TYPE_GEOLOCATION), |
| 51 requesting_frame_(requesting_frame), | 51 requesting_frame_(requesting_frame), |
| 52 display_languages_(display_languages) { | 52 display_languages_(display_languages) { |
| 53 } | 53 } |
| 54 | 54 |
| 55 GeolocationInfoBarDelegate::~GeolocationInfoBarDelegate() { | 55 GeolocationInfoBarDelegate::~GeolocationInfoBarDelegate() { |
| 56 } | 56 } |
| 57 | 57 |
| 58 int GeolocationInfoBarDelegate::GetIconID() const { | 58 int GeolocationInfoBarDelegate::GetIconID() const { |
| 59 return IDR_INFOBAR_GEOLOCATION; | 59 return IDR_INFOBAR_GEOLOCATION; |
| 60 } | 60 } |
| 61 | 61 |
| 62 base::string16 GeolocationInfoBarDelegate::GetMessageText() const { | 62 base::string16 GeolocationInfoBarDelegate::GetMessageText() const { |
| 63 return l10n_util::GetStringFUTF16(IDS_GEOLOCATION_INFOBAR_QUESTION, | 63 return l10n_util::GetStringFUTF16(IDS_GEOLOCATION_INFOBAR_QUESTION, |
| 64 net::FormatUrl(requesting_frame_, display_languages_, | 64 net::FormatUrl(requesting_frame_, display_languages_, |
| 65 net::kFormatUrlOmitUsernamePassword | | 65 net::kFormatUrlOmitUsernamePassword | |
| 66 net::kFormatUrlOmitTrailingSlashOnBareHostname, | 66 net::kFormatUrlOmitTrailingSlashOnBareHostname, |
| 67 net::UnescapeRule::SPACES, NULL, NULL, NULL)); | 67 net::UnescapeRule::SPACES, NULL, NULL, NULL)); |
| 68 } | 68 } |
| OLD | NEW |