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 return infobar_service->AddInfoBar(infobar_service->CreateConfirmInfoBar( |
39 scoped_ptr<ConfirmInfoBarDelegate>(delegate)).release(); | 39 scoped_ptr<ConfirmInfoBarDelegate>(delegate))); |
40 return infobar_service->AddInfoBar(scoped_ptr<infobars::InfoBar>(infobar)); | |
41 } | 40 } |
42 | 41 |
43 GeolocationInfoBarDelegate::GeolocationInfoBarDelegate( | 42 GeolocationInfoBarDelegate::GeolocationInfoBarDelegate( |
44 PermissionQueueController* controller, | 43 PermissionQueueController* controller, |
45 const PermissionRequestID& id, | 44 const PermissionRequestID& id, |
46 const GURL& requesting_frame, | 45 const GURL& requesting_frame, |
47 int contents_unique_id, | 46 int contents_unique_id, |
48 const std::string& display_languages) | 47 const std::string& display_languages) |
49 : PermissionInfobarDelegate(controller, id, requesting_frame, | 48 : PermissionInfobarDelegate(controller, id, requesting_frame, |
50 CONTENT_SETTINGS_TYPE_GEOLOCATION), | 49 CONTENT_SETTINGS_TYPE_GEOLOCATION), |
51 requesting_frame_(requesting_frame), | 50 requesting_frame_(requesting_frame), |
52 display_languages_(display_languages) { | 51 display_languages_(display_languages) { |
53 } | 52 } |
54 | 53 |
55 GeolocationInfoBarDelegate::~GeolocationInfoBarDelegate() { | 54 GeolocationInfoBarDelegate::~GeolocationInfoBarDelegate() { |
56 } | 55 } |
57 | 56 |
58 int GeolocationInfoBarDelegate::GetIconID() const { | 57 int GeolocationInfoBarDelegate::GetIconID() const { |
59 return IDR_INFOBAR_GEOLOCATION; | 58 return IDR_INFOBAR_GEOLOCATION; |
60 } | 59 } |
61 | 60 |
62 base::string16 GeolocationInfoBarDelegate::GetMessageText() const { | 61 base::string16 GeolocationInfoBarDelegate::GetMessageText() const { |
63 return l10n_util::GetStringFUTF16(IDS_GEOLOCATION_INFOBAR_QUESTION, | 62 return l10n_util::GetStringFUTF16(IDS_GEOLOCATION_INFOBAR_QUESTION, |
64 net::FormatUrl(requesting_frame_, display_languages_, | 63 net::FormatUrl(requesting_frame_, display_languages_, |
65 net::kFormatUrlOmitUsernamePassword | | 64 net::kFormatUrlOmitUsernamePassword | |
66 net::kFormatUrlOmitTrailingSlashOnBareHostname, | 65 net::kFormatUrlOmitTrailingSlashOnBareHostname, |
67 net::UnescapeRule::SPACES, NULL, NULL, NULL)); | 66 net::UnescapeRule::SPACES, NULL, NULL, NULL)); |
68 } | 67 } |
OLD | NEW |