Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(992)

Side by Side Diff: chrome/browser/geolocation/chrome_geolocation_permission_context.cc

Issue 23440030: GeolocationPermissionContext: only use origin from embedder url. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Retry upload. Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/chrome_geolocation_permission_context.h" 5 #include "chrome/browser/geolocation/chrome_geolocation_permission_context.h"
6 6
7 #include <functional> 7 #include <functional>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/strings/string_split.h"
12 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
13 #include "chrome/browser/content_settings/host_content_settings_map.h" 14 #include "chrome/browser/content_settings/host_content_settings_map.h"
14 #include "chrome/browser/content_settings/permission_request_id.h" 15 #include "chrome/browser/content_settings/permission_request_id.h"
15 #include "chrome/browser/content_settings/tab_specific_content_settings.h" 16 #include "chrome/browser/content_settings/tab_specific_content_settings.h"
16 #include "chrome/browser/extensions/extension_service.h" 17 #include "chrome/browser/extensions/extension_service.h"
17 #include "chrome/browser/extensions/extension_system.h" 18 #include "chrome/browser/extensions/extension_system.h"
18 #include "chrome/browser/extensions/suggest_permission_util.h" 19 #include "chrome/browser/extensions/suggest_permission_util.h"
19 #include "chrome/browser/profiles/profile.h" 20 #include "chrome/browser/profiles/profile.h"
20 #include "chrome/browser/tab_contents/tab_util.h" 21 #include "chrome/browser/tab_contents/tab_util.h"
21 #include "chrome/common/extensions/extension.h" 22 #include "chrome/common/extensions/extension.h"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 // TODO(mpcomplete): the request could be from a background page or 88 // TODO(mpcomplete): the request could be from a background page or
88 // extension popup (web_contents will have a different ViewType). But why do 89 // extension popup (web_contents will have a different ViewType). But why do
89 // we care? Shouldn't we still put an infobar up in the current tab? 90 // we care? Shouldn't we still put an infobar up in the current tab?
90 LOG(WARNING) << "Attempt to use geolocation tabless renderer: " 91 LOG(WARNING) << "Attempt to use geolocation tabless renderer: "
91 << id.ToString() 92 << id.ToString()
92 << " (can't prompt user without a visible tab)"; 93 << " (can't prompt user without a visible tab)";
93 NotifyPermissionSet(id, requesting_frame, callback, false); 94 NotifyPermissionSet(id, requesting_frame, callback, false);
94 return; 95 return;
95 } 96 }
96 97
97 GURL embedder = web_contents->GetURL(); 98 GURL embedder = web_contents->GetLastCommittedURL();
bulach 2013/09/12 16:28:41 .GetOrigin() ?
Michael van Ouwerkerk 2013/09/12 16:50:41 Much nicer. Done.
98 if (!requesting_frame.is_valid() || !embedder.is_valid()) { 99 if (!requesting_frame.is_valid() || !embedder.is_valid()) {
99 LOG(WARNING) << "Attempt to use geolocation from an invalid URL: " 100 LOG(WARNING) << "Attempt to use geolocation from an invalid URL: "
100 << requesting_frame << "," << embedder 101 << requesting_frame << "," << embedder
101 << " (geolocation is not supported in popups)"; 102 << " (geolocation is not supported in popups)";
102 NotifyPermissionSet(id, requesting_frame, callback, false); 103 NotifyPermissionSet(id, requesting_frame, callback, false);
103 return; 104 return;
104 } 105 }
105 106
107 if (embedder.has_ref()) {
108 // The ref (the hash) is not important here, and including it may cause a
109 // comparison failure later because it can change.
110 std::vector<std::string> parts;
111 base::SplitString(embedder.spec(), '#', &parts);
112 embedder = GURL(parts[0]);
113 }
bulach 2013/09/12 16:28:41 see above, I think we should just use .GetOrigin()
Michael van Ouwerkerk 2013/09/12 16:50:41 Done.
114
106 DecidePermission(id, requesting_frame, embedder, callback); 115 DecidePermission(id, requesting_frame, embedder, callback);
107 } 116 }
108 117
109 void ChromeGeolocationPermissionContext::CancelGeolocationPermissionRequest( 118 void ChromeGeolocationPermissionContext::CancelGeolocationPermissionRequest(
110 int render_process_id, 119 int render_process_id,
111 int render_view_id, 120 int render_view_id,
112 int bridge_id, 121 int bridge_id,
113 const GURL& requesting_frame) { 122 const GURL& requesting_frame) {
114 CancelPendingInfoBarRequest(PermissionRequestID( 123 CancelPendingInfoBarRequest(PermissionRequestID(
115 render_process_id, render_view_id, bridge_id)); 124 render_process_id, render_view_id, bridge_id));
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 base::Bind( 209 base::Bind(
201 &ChromeGeolocationPermissionContext::CancelPendingInfoBarRequest, 210 &ChromeGeolocationPermissionContext::CancelPendingInfoBarRequest,
202 this, id)); 211 this, id));
203 return; 212 return;
204 } 213 }
205 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 214 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
206 if (shutting_down_) 215 if (shutting_down_)
207 return; 216 return;
208 QueueController()->CancelInfoBarRequest(id); 217 QueueController()->CancelInfoBarRequest(id);
209 } 218 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698