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 "chrome/browser/content_settings/permission_queue_controller.h" | 7 #include "chrome/browser/content_settings/permission_queue_controller.h" |
8 #include "chrome/browser/google/google_util.h" | 8 #include "chrome/browser/google/google_util.h" |
9 #include "chrome/browser/infobars/infobar_service.h" | 9 #include "chrome/browser/infobars/infobar_service.h" |
10 #include "content/public/browser/navigation_details.h" | 10 #include "content/public/browser/navigation_details.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 GeolocationInfoBarDelegate::GeolocationInfoBarDelegate( | 42 GeolocationInfoBarDelegate::GeolocationInfoBarDelegate( |
43 InfoBarService* infobar_service, | 43 InfoBarService* infobar_service, |
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 : ConfirmInfoBarDelegate(infobar_service), | 49 : ConfirmInfoBarDelegate(infobar_service), |
50 controller_(controller), | 50 controller_(controller), |
51 id_(id), | 51 id_(id), |
52 requesting_frame_(requesting_frame), | 52 requesting_frame_(requesting_frame.GetOrigin()), |
53 contents_unique_id_(contents_unique_id), | 53 contents_unique_id_(contents_unique_id), |
54 display_languages_(display_languages) { | 54 display_languages_(display_languages) { |
55 } | 55 } |
56 | 56 |
57 GeolocationInfoBarDelegate::~GeolocationInfoBarDelegate() { | 57 GeolocationInfoBarDelegate::~GeolocationInfoBarDelegate() { |
58 } | 58 } |
59 | 59 |
60 bool GeolocationInfoBarDelegate::Accept() { | 60 bool GeolocationInfoBarDelegate::Accept() { |
61 SetPermission(true, true); | 61 SetPermission(true, true); |
62 return true; | 62 return true; |
63 } | 63 } |
64 | 64 |
65 void GeolocationInfoBarDelegate::SetPermission(bool update_content_setting, | 65 void GeolocationInfoBarDelegate::SetPermission(bool update_content_setting, |
66 bool allowed) { | 66 bool allowed) { |
67 if (web_contents()) { | 67 if (web_contents()) { |
68 controller_->OnPermissionSet(id_, requesting_frame_, | 68 GURL embedder = web_contents()->GetLastCommittedURL().GetOrigin(); |
69 web_contents()->GetURL(), | 69 controller_->OnPermissionSet(id_, requesting_frame_, embedder, |
70 update_content_setting, allowed); | 70 update_content_setting, allowed); |
71 } | 71 } |
72 } | 72 } |
73 | 73 |
74 void GeolocationInfoBarDelegate::InfoBarDismissed() { | 74 void GeolocationInfoBarDelegate::InfoBarDismissed() { |
75 SetPermission(false, false); | 75 SetPermission(false, false); |
76 } | 76 } |
77 | 77 |
78 int GeolocationInfoBarDelegate::GetIconID() const { | 78 int GeolocationInfoBarDelegate::GetIconID() const { |
79 return IDR_GEOLOCATION_INFOBAR_ICON; | 79 return IDR_GEOLOCATION_INFOBAR_ICON; |
80 } | 80 } |
81 | 81 |
82 InfoBarDelegate::Type GeolocationInfoBarDelegate::GetInfoBarType() const { | 82 InfoBarDelegate::Type GeolocationInfoBarDelegate::GetInfoBarType() const { |
83 return PAGE_ACTION_TYPE; | 83 return PAGE_ACTION_TYPE; |
84 } | 84 } |
85 | 85 |
86 bool GeolocationInfoBarDelegate::ShouldExpireInternal( | 86 bool GeolocationInfoBarDelegate::ShouldExpireInternal( |
87 const content::LoadCommittedDetails& details) const { | 87 const content::LoadCommittedDetails& details) const { |
88 // This implementation matches InfoBarDelegate::ShouldExpireInternal(), but | 88 // This implementation matches InfoBarDelegate::ShouldExpireInternal(), but |
89 // uses the unique ID we set in the constructor instead of that stored in the | 89 // uses the unique ID we set in the constructor instead of that stored in the |
90 // base class. | 90 // base class. |
91 return (contents_unique_id_ != details.entry->GetUniqueID()) || | 91 return (contents_unique_id_ != details.entry->GetUniqueID()) || |
92 (content::PageTransitionStripQualifier( | 92 (content::PageTransitionStripQualifier( |
93 details.entry->GetTransitionType()) == | 93 details.entry->GetTransitionType()) == |
94 content::PAGE_TRANSITION_RELOAD); | 94 content::PAGE_TRANSITION_RELOAD); |
95 } | 95 } |
96 | 96 |
97 string16 GeolocationInfoBarDelegate::GetMessageText() const { | 97 string16 GeolocationInfoBarDelegate::GetMessageText() const { |
98 return l10n_util::GetStringFUTF16(IDS_GEOLOCATION_INFOBAR_QUESTION, | 98 return l10n_util::GetStringFUTF16(IDS_GEOLOCATION_INFOBAR_QUESTION, |
99 net::FormatUrl(requesting_frame_.GetOrigin(), display_languages_)); | 99 net::FormatUrl(requesting_frame_, display_languages_)); |
100 } | 100 } |
101 | 101 |
102 string16 GeolocationInfoBarDelegate::GetButtonLabel( | 102 string16 GeolocationInfoBarDelegate::GetButtonLabel( |
103 InfoBarButton button) const { | 103 InfoBarButton button) const { |
104 return l10n_util::GetStringUTF16((button == BUTTON_OK) ? | 104 return l10n_util::GetStringUTF16((button == BUTTON_OK) ? |
105 IDS_GEOLOCATION_ALLOW_BUTTON : IDS_GEOLOCATION_DENY_BUTTON); | 105 IDS_GEOLOCATION_ALLOW_BUTTON : IDS_GEOLOCATION_DENY_BUTTON); |
106 } | 106 } |
107 | 107 |
108 bool GeolocationInfoBarDelegate::Cancel() { | 108 bool GeolocationInfoBarDelegate::Cancel() { |
109 SetPermission(true, false); | 109 SetPermission(true, false); |
(...skipping 13 matching lines...) Expand all Loading... |
123 "https://www.google.com/support/chrome/bin/answer.py?answer=142065"; | 123 "https://www.google.com/support/chrome/bin/answer.py?answer=142065"; |
124 #endif | 124 #endif |
125 | 125 |
126 web_contents()->OpenURL(content::OpenURLParams( | 126 web_contents()->OpenURL(content::OpenURLParams( |
127 google_util::AppendGoogleLocaleParam(GURL(kGeolocationLearnMoreUrl)), | 127 google_util::AppendGoogleLocaleParam(GURL(kGeolocationLearnMoreUrl)), |
128 content::Referrer(), | 128 content::Referrer(), |
129 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, | 129 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, |
130 content::PAGE_TRANSITION_LINK, false)); | 130 content::PAGE_TRANSITION_LINK, false)); |
131 return false; // Do not dismiss the info bar. | 131 return false; // Do not dismiss the info bar. |
132 } | 132 } |
OLD | NEW |