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/strings/string_split.h" | |
7 #include "chrome/browser/content_settings/permission_queue_controller.h" | 8 #include "chrome/browser/content_settings/permission_queue_controller.h" |
8 #include "chrome/browser/google/google_util.h" | 9 #include "chrome/browser/google/google_util.h" |
9 #include "chrome/browser/infobars/infobar_service.h" | 10 #include "chrome/browser/infobars/infobar_service.h" |
10 #include "content/public/browser/navigation_details.h" | 11 #include "content/public/browser/navigation_details.h" |
11 #include "content/public/browser/navigation_entry.h" | 12 #include "content/public/browser/navigation_entry.h" |
12 #include "content/public/browser/web_contents.h" | 13 #include "content/public/browser/web_contents.h" |
13 #include "grit/generated_resources.h" | 14 #include "grit/generated_resources.h" |
14 #include "grit/locale_settings.h" | 15 #include "grit/locale_settings.h" |
15 #include "grit/theme_resources.h" | 16 #include "grit/theme_resources.h" |
16 #include "net/base/net_util.h" | 17 #include "net/base/net_util.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
58 } | 59 } |
59 | 60 |
60 bool GeolocationInfoBarDelegate::Accept() { | 61 bool GeolocationInfoBarDelegate::Accept() { |
61 SetPermission(true, true); | 62 SetPermission(true, true); |
62 return true; | 63 return true; |
63 } | 64 } |
64 | 65 |
65 void GeolocationInfoBarDelegate::SetPermission(bool update_content_setting, | 66 void GeolocationInfoBarDelegate::SetPermission(bool update_content_setting, |
66 bool allowed) { | 67 bool allowed) { |
67 if (web_contents()) { | 68 if (web_contents()) { |
68 controller_->OnPermissionSet(id_, requesting_frame_, | 69 GURL embedder = web_contents()->GetLastCommittedURL(); |
69 web_contents()->GetURL(), | 70 if (embedder.has_ref()) { |
71 // The ref (the hash) is not important here, and including it may cause a | |
72 // comparison failure later because it can change. | |
73 std::vector<std::string> parts; | |
74 base::SplitString(embedder.spec(), '#', &parts); | |
75 embedder = GURL(parts[0]); | |
joth
2013/09/12 16:43:13
rather than grepping for # I think you can use thi
Michael van Ouwerkerk
2013/09/12 16:50:41
Done.
| |
76 } | |
77 | |
78 controller_->OnPermissionSet(id_, requesting_frame_, embedder, | |
bulach
2013/09/12 16:28:41
probably best to have just the controller and cont
Michael van Ouwerkerk
2013/09/12 16:50:41
Done.
| |
70 update_content_setting, allowed); | 79 update_content_setting, allowed); |
71 } | 80 } |
72 } | 81 } |
73 | 82 |
74 void GeolocationInfoBarDelegate::InfoBarDismissed() { | 83 void GeolocationInfoBarDelegate::InfoBarDismissed() { |
75 SetPermission(false, false); | 84 SetPermission(false, false); |
76 } | 85 } |
77 | 86 |
78 int GeolocationInfoBarDelegate::GetIconID() const { | 87 int GeolocationInfoBarDelegate::GetIconID() const { |
79 return IDR_GEOLOCATION_INFOBAR_ICON; | 88 return IDR_GEOLOCATION_INFOBAR_ICON; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
123 "https://www.google.com/support/chrome/bin/answer.py?answer=142065"; | 132 "https://www.google.com/support/chrome/bin/answer.py?answer=142065"; |
124 #endif | 133 #endif |
125 | 134 |
126 web_contents()->OpenURL(content::OpenURLParams( | 135 web_contents()->OpenURL(content::OpenURLParams( |
127 google_util::AppendGoogleLocaleParam(GURL(kGeolocationLearnMoreUrl)), | 136 google_util::AppendGoogleLocaleParam(GURL(kGeolocationLearnMoreUrl)), |
128 content::Referrer(), | 137 content::Referrer(), |
129 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, | 138 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, |
130 content::PAGE_TRANSITION_LINK, false)); | 139 content::PAGE_TRANSITION_LINK, false)); |
131 return false; // Do not dismiss the info bar. | 140 return false; // Do not dismiss the info bar. |
132 } | 141 } |
OLD | NEW |