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

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

Issue 1143002: Adds GeolocationContentSettings on TabContents. (Closed)
Patch Set: Tests for tabcontents for extensions. Created 10 years, 9 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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_permission_context.h" 5 #include "chrome/browser/geolocation/geolocation_permission_context.h"
6 6
7 #include "app/l10n_util.h" 7 #include "app/l10n_util.h"
8 #include "app/resource_bundle.h" 8 #include "app/resource_bundle.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "chrome/browser/browser.h" 10 #include "chrome/browser/browser.h"
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 int render_process_id, int render_view_id, int bridge_id, 117 int render_process_id, int render_view_id, int bridge_id,
118 const GURL& requesting_frame) { 118 const GURL& requesting_frame) {
119 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); 119 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO));
120 RequestPermissionFromUI(render_process_id, render_view_id, bridge_id, 120 RequestPermissionFromUI(render_process_id, render_view_id, bridge_id,
121 requesting_frame); 121 requesting_frame);
122 } 122 }
123 123
124 void GeolocationPermissionContext::SetPermission( 124 void GeolocationPermissionContext::SetPermission(
125 int render_process_id, int render_view_id, int bridge_id, 125 int render_process_id, int render_view_id, int bridge_id,
126 const GURL& requesting_frame, bool allowed) { 126 const GURL& requesting_frame, bool allowed) {
127 NotifyPermissionSet(render_process_id, render_view_id, bridge_id, allowed); 127 NotifyPermissionSet(render_process_id, render_view_id, bridge_id,
128 requesting_frame, allowed);
128 } 129 }
129 130
130 void GeolocationPermissionContext::RequestPermissionFromUI( 131 void GeolocationPermissionContext::RequestPermissionFromUI(
131 int render_process_id, int render_view_id, int bridge_id, 132 int render_process_id, int render_view_id, int bridge_id,
132 const GURL& requesting_frame) { 133 const GURL& requesting_frame) {
133 if (!ChromeThread::CurrentlyOn(ChromeThread::UI)) { 134 if (!ChromeThread::CurrentlyOn(ChromeThread::UI)) {
134 ChromeThread::PostTask( 135 ChromeThread::PostTask(
135 ChromeThread::UI, FROM_HERE, 136 ChromeThread::UI, FROM_HERE,
136 NewRunnableMethod(this, 137 NewRunnableMethod(this,
137 &GeolocationPermissionContext::RequestPermissionFromUI, 138 &GeolocationPermissionContext::RequestPermissionFromUI,
138 render_process_id, render_view_id, bridge_id, requesting_frame)); 139 render_process_id, render_view_id, bridge_id, requesting_frame));
139 return; 140 return;
140 } 141 }
141 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); 142 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
142 143
143 TabContents* tab_contents = 144 TabContents* tab_contents =
144 tab_util::GetTabContentsByID(render_process_id, render_view_id); 145 tab_util::GetTabContentsByID(render_process_id, render_view_id);
145 if (!tab_contents) { 146 if (!tab_contents) {
146 // The tab may have gone away, or the request may not be from a tab at all. 147 // The tab may have gone away, or the request may not be from a tab at all.
147 LOG(WARNING) << "Attempt to use geolocaiton tabless renderer: " 148 LOG(WARNING) << "Attempt to use geolocation tabless renderer: "
148 << render_process_id << "," << render_view_id << "," << bridge_id 149 << render_process_id << "," << render_view_id << "," << bridge_id
149 << " (geolocation is not supported in extensions)"; 150 << " (geolocation is not supported in extensions)";
150 NotifyPermissionSet(render_process_id, render_view_id, bridge_id, false); 151 NotifyPermissionSet(render_process_id, render_view_id, bridge_id,
152 requesting_frame, false);
151 return; 153 return;
152 } 154 }
153 tab_contents->AddInfoBar(new GeolocationConfirmInfoBarDelegate(tab_contents, 155 tab_contents->AddInfoBar(new GeolocationConfirmInfoBarDelegate(tab_contents,
154 this, render_process_id, render_view_id, bridge_id, requesting_frame)); 156 this, render_process_id, render_view_id, bridge_id, requesting_frame));
155 } 157 }
156 158
157 void GeolocationPermissionContext::NotifyPermissionSet( 159 void GeolocationPermissionContext::NotifyPermissionSet(
158 int render_process_id, int render_view_id, int bridge_id, bool allowed) { 160 int render_process_id, int render_view_id, int bridge_id,
161 const GURL& requesting_frame, bool allowed) {
159 if (!ChromeThread::CurrentlyOn(ChromeThread::UI)) { 162 if (!ChromeThread::CurrentlyOn(ChromeThread::UI)) {
160 ChromeThread::PostTask( 163 ChromeThread::PostTask(
161 ChromeThread::UI, FROM_HERE, 164 ChromeThread::UI, FROM_HERE,
162 NewRunnableMethod(this, 165 NewRunnableMethod(this,
163 &GeolocationPermissionContext::NotifyPermissionSet, 166 &GeolocationPermissionContext::NotifyPermissionSet,
164 render_process_id, render_view_id, bridge_id, allowed)); 167 render_process_id, render_view_id, bridge_id, requesting_frame,
168 allowed));
165 return; 169 return;
166 } 170 }
171 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
167 172
168 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); 173 RenderViewHostDelegate::Resource* resource =
174 tab_util::GetTabContentsByID(render_process_id, render_view_id);
175 // TabContents may have gone away (or not exists for extension).
176 if (resource)
177 resource->OnGeolocationPermissionSet(requesting_frame, allowed);
178
169 CallRenderViewHost( 179 CallRenderViewHost(
170 render_process_id, render_view_id, 180 render_process_id, render_view_id,
171 &RenderViewHost::Send, 181 &RenderViewHost::Send,
172 new ViewMsg_Geolocation_PermissionSet(render_view_id, bridge_id, 182 new ViewMsg_Geolocation_PermissionSet(render_view_id, bridge_id,
173 allowed)); 183 allowed));
174 } 184 }
OLDNEW
« no previous file with comments | « chrome/browser/geolocation/geolocation_permission_context.h ('k') | chrome/browser/renderer_host/render_view_host_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698