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" | |
8 #include "chrome/browser/content_settings/permission_queue_controller.h" | |
9 #include "chrome/browser/infobars/infobar_service.h" | 7 #include "chrome/browser/infobars/infobar_service.h" |
10 #include "chrome/grit/generated_resources.h" | 8 #include "chrome/grit/generated_resources.h" |
11 #include "chrome/grit/locale_settings.h" | |
12 #include "components/google/core/browser/google_util.h" | |
13 #include "components/infobars/core/infobar.h" | 9 #include "components/infobars/core/infobar.h" |
14 #include "content/public/browser/navigation_details.h" | |
15 #include "content/public/browser/navigation_entry.h" | |
16 #include "content/public/browser/web_contents.h" | |
17 #include "grit/generated_resources.h" | 10 #include "grit/generated_resources.h" |
18 #include "grit/locale_settings.h" | |
19 #include "grit/theme_resources.h" | 11 #include "grit/theme_resources.h" |
20 #include "net/base/net_util.h" | 12 #include "net/base/net_util.h" |
21 #include "ui/base/l10n/l10n_util.h" | 13 #include "ui/base/l10n/l10n_util.h" |
22 | 14 |
23 | 15 |
24 // static | 16 // static |
25 infobars::InfoBar* GeolocationInfoBarDelegate::Create( | 17 infobars::InfoBar* GeolocationInfoBarDelegate::Create( |
26 InfoBarService* infobar_service, | 18 InfoBarService* infobar_service, |
27 PermissionQueueController* controller, | 19 PermissionQueueController* controller, |
28 const PermissionRequestID& id, | 20 const PermissionRequestID& id, |
29 const GURL& requesting_frame, | 21 const GURL& requesting_frame, |
30 const std::string& display_languages) { | 22 const std::string& display_languages) { |
31 const content::NavigationEntry* committed_entry = | |
32 infobar_service->web_contents()->GetController().GetLastCommittedEntry(); | |
33 GeolocationInfoBarDelegate* const delegate = new GeolocationInfoBarDelegate( | |
34 controller, id, requesting_frame, | |
35 committed_entry ? committed_entry->GetUniqueID() : 0, | |
36 display_languages); | |
37 | |
38 return infobar_service->AddInfoBar(infobar_service->CreateConfirmInfoBar( | 23 return infobar_service->AddInfoBar(infobar_service->CreateConfirmInfoBar( |
39 scoped_ptr<ConfirmInfoBarDelegate>(delegate))); | 24 scoped_ptr<ConfirmInfoBarDelegate>(new GeolocationInfoBarDelegate( |
25 controller, id, requesting_frame, display_languages)))); | |
40 } | 26 } |
41 | 27 |
42 GeolocationInfoBarDelegate::GeolocationInfoBarDelegate( | 28 GeolocationInfoBarDelegate::GeolocationInfoBarDelegate( |
43 PermissionQueueController* controller, | 29 PermissionQueueController* controller, |
44 const PermissionRequestID& id, | 30 const PermissionRequestID& id, |
45 const GURL& requesting_frame, | 31 const GURL& requesting_frame, |
46 int contents_unique_id, | |
timvolodine
2015/05/20 11:44:01
wow looks like this was not used at all?..
Peter Kasting
2015/05/20 18:22:00
Correct :(
| |
47 const std::string& display_languages) | 32 const std::string& display_languages) |
48 : PermissionInfobarDelegate(controller, id, requesting_frame, | 33 : PermissionInfobarDelegate(controller, id, requesting_frame, |
49 CONTENT_SETTINGS_TYPE_GEOLOCATION), | 34 CONTENT_SETTINGS_TYPE_GEOLOCATION), |
50 requesting_frame_(requesting_frame), | 35 requesting_frame_(requesting_frame), |
51 display_languages_(display_languages) { | 36 display_languages_(display_languages) { |
52 } | 37 } |
53 | 38 |
54 GeolocationInfoBarDelegate::~GeolocationInfoBarDelegate() { | 39 GeolocationInfoBarDelegate::~GeolocationInfoBarDelegate() { |
55 } | 40 } |
56 | 41 |
57 int GeolocationInfoBarDelegate::GetIconID() const { | 42 int GeolocationInfoBarDelegate::GetIconID() const { |
58 return IDR_INFOBAR_GEOLOCATION; | 43 return IDR_INFOBAR_GEOLOCATION; |
59 } | 44 } |
60 | 45 |
61 base::string16 GeolocationInfoBarDelegate::GetMessageText() const { | 46 base::string16 GeolocationInfoBarDelegate::GetMessageText() const { |
62 return l10n_util::GetStringFUTF16(IDS_GEOLOCATION_INFOBAR_QUESTION, | 47 return l10n_util::GetStringFUTF16(IDS_GEOLOCATION_INFOBAR_QUESTION, |
63 net::FormatUrl(requesting_frame_, display_languages_, | 48 net::FormatUrl(requesting_frame_, display_languages_, |
64 net::kFormatUrlOmitUsernamePassword | | 49 net::kFormatUrlOmitUsernamePassword | |
65 net::kFormatUrlOmitTrailingSlashOnBareHostname, | 50 net::kFormatUrlOmitTrailingSlashOnBareHostname, |
66 net::UnescapeRule::SPACES, NULL, NULL, NULL)); | 51 net::UnescapeRule::SPACES, NULL, NULL, NULL)); |
67 } | 52 } |
OLD | NEW |