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

Side by Side Diff: content/browser/browser_plugin/browser_plugin_guest.cc

Issue 185813004: [Geolocation] Attach user gesture indicator to permission request call. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Patch android Created 6 years, 8 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 | Annotate | Revision Log
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 "content/browser/browser_plugin/browser_plugin_guest.h" 5 #include "content/browser/browser_plugin/browser_plugin_guest.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 105
106 private: 106 private:
107 virtual ~DownloadRequest() {} 107 virtual ~DownloadRequest() {}
108 base::Callback<void(bool)> callback_; 108 base::Callback<void(bool)> callback_;
109 }; 109 };
110 110
111 class BrowserPluginGuest::GeolocationRequest : public PermissionRequest { 111 class BrowserPluginGuest::GeolocationRequest : public PermissionRequest {
112 public: 112 public:
113 GeolocationRequest(const base::WeakPtr<BrowserPluginGuest>& guest, 113 GeolocationRequest(const base::WeakPtr<BrowserPluginGuest>& guest,
114 GeolocationCallback callback, 114 GeolocationCallback callback,
115 int bridge_id) 115 int bridge_id,
116 bool user_gesture)
116 : PermissionRequest(guest), 117 : PermissionRequest(guest),
117 callback_(callback), 118 callback_(callback),
118 bridge_id_(bridge_id) { 119 bridge_id_(bridge_id),
120 user_gesture_(user_gesture) {
119 RecordAction( 121 RecordAction(
120 base::UserMetricsAction("BrowserPlugin.Guest.PermissionRequest.Geolocati on")); 122 base::UserMetricsAction("BrowserPlugin.Guest.PermissionRequest.Geolocati on"));
121 } 123 }
122 124
123 virtual void RespondImpl(bool should_allow, 125 virtual void RespondImpl(bool should_allow,
124 const std::string& user_input) OVERRIDE { 126 const std::string& user_input) OVERRIDE {
125 WebContents* web_contents = guest_->embedder_web_contents(); 127 WebContents* web_contents = guest_->embedder_web_contents();
126 if (should_allow && web_contents) { 128 if (should_allow && web_contents) {
127 // If renderer side embedder decides to allow gelocation, we need to check 129 // If renderer side embedder decides to allow gelocation, we need to check
128 // if the app/embedder itself has geolocation access. 130 // if the app/embedder itself has geolocation access.
129 BrowserContext* browser_context = web_contents->GetBrowserContext(); 131 BrowserContext* browser_context = web_contents->GetBrowserContext();
130 if (browser_context) { 132 if (browser_context) {
131 GeolocationPermissionContext* geolocation_context = 133 GeolocationPermissionContext* geolocation_context =
132 browser_context->GetGeolocationPermissionContext(); 134 browser_context->GetGeolocationPermissionContext();
133 if (geolocation_context) { 135 if (geolocation_context) {
134 base::Callback<void(bool)> geolocation_callback = base::Bind( 136 base::Callback<void(bool)> geolocation_callback = base::Bind(
135 &BrowserPluginGuest::SetGeolocationPermission, 137 &BrowserPluginGuest::SetGeolocationPermission,
136 guest_, 138 guest_,
137 callback_, 139 callback_,
138 bridge_id_); 140 bridge_id_);
139 geolocation_context->RequestGeolocationPermission( 141 geolocation_context->RequestGeolocationPermission(
140 web_contents->GetRenderProcessHost()->GetID(), 142 web_contents->GetRenderProcessHost()->GetID(),
141 web_contents->GetRoutingID(), 143 web_contents->GetRoutingID(),
142 // The geolocation permission request here is not initiated 144 // The geolocation permission request here is not initiated
143 // through WebGeolocationPermissionRequest. We are only interested 145 // through WebGeolocationPermissionRequest. We are only interested
144 // in the fact whether the embedder/app has geolocation 146 // in the fact whether the embedder/app has geolocation
145 // permission. Therefore we use an invalid |bridge_id|. 147 // permission. Therefore we use an invalid |bridge_id|.
146 -1 /* bridge_id */, 148 -1 /* bridge_id */,
147 web_contents->GetLastCommittedURL(), 149 web_contents->GetLastCommittedURL(),
150 user_gesture_,
148 geolocation_callback); 151 geolocation_callback);
149 return; 152 return;
150 } 153 }
151 } 154 }
152 } 155 }
153 guest_->SetGeolocationPermission(callback_, bridge_id_, false); 156 guest_->SetGeolocationPermission(callback_, bridge_id_, false);
154 } 157 }
155 158
156 private: 159 private:
157 virtual ~GeolocationRequest() {} 160 virtual ~GeolocationRequest() {}
158 base::Callback<void(bool)> callback_; 161 base::Callback<void(bool)> callback_;
159 int bridge_id_; 162 int bridge_id_;
163 bool user_gesture_;
160 }; 164 };
161 165
162 class BrowserPluginGuest::MediaRequest : public PermissionRequest { 166 class BrowserPluginGuest::MediaRequest : public PermissionRequest {
163 public: 167 public:
164 MediaRequest(const base::WeakPtr<BrowserPluginGuest>& guest, 168 MediaRequest(const base::WeakPtr<BrowserPluginGuest>& guest,
165 const MediaStreamRequest& request, 169 const MediaStreamRequest& request,
166 const MediaResponseCallback& callback) 170 const MediaResponseCallback& callback)
167 : PermissionRequest(guest), 171 : PermissionRequest(guest),
168 request_(request), 172 request_(request),
169 callback_(callback) { 173 callback_(callback) {
(...skipping 880 matching lines...) Expand 10 before | Expand all | Expand 10 after
1050 } 1054 }
1051 1055
1052 void BrowserPluginGuest::SetDelegate(BrowserPluginGuestDelegate* delegate) { 1056 void BrowserPluginGuest::SetDelegate(BrowserPluginGuestDelegate* delegate) {
1053 DCHECK(!delegate_); 1057 DCHECK(!delegate_);
1054 delegate_.reset(delegate); 1058 delegate_.reset(delegate);
1055 } 1059 }
1056 1060
1057 void BrowserPluginGuest::AskEmbedderForGeolocationPermission( 1061 void BrowserPluginGuest::AskEmbedderForGeolocationPermission(
1058 int bridge_id, 1062 int bridge_id,
1059 const GURL& requesting_frame, 1063 const GURL& requesting_frame,
1064 bool user_gesture,
1060 const GeolocationCallback& callback) { 1065 const GeolocationCallback& callback) {
1061 base::DictionaryValue request_info; 1066 base::DictionaryValue request_info;
1062 request_info.Set(browser_plugin::kURL, 1067 request_info.Set(browser_plugin::kURL,
1063 base::Value::CreateStringValue(requesting_frame.spec())); 1068 base::Value::CreateStringValue(requesting_frame.spec()));
1064 1069
1065 int request_id = 1070 int request_id =
1066 RequestPermission(BROWSER_PLUGIN_PERMISSION_TYPE_GEOLOCATION, 1071 RequestPermission(BROWSER_PLUGIN_PERMISSION_TYPE_GEOLOCATION,
1067 new GeolocationRequest(weak_ptr_factory_.GetWeakPtr(), 1072 new GeolocationRequest(weak_ptr_factory_.GetWeakPtr(),
1068 callback, 1073 callback,
1069 bridge_id), 1074 bridge_id,
1075 user_gesture),
1070 request_info); 1076 request_info);
1071 1077
1072 DCHECK(bridge_id_to_request_id_map_.find(bridge_id) == 1078 DCHECK(bridge_id_to_request_id_map_.find(bridge_id) ==
1073 bridge_id_to_request_id_map_.end()); 1079 bridge_id_to_request_id_map_.end());
1074 bridge_id_to_request_id_map_[bridge_id] = request_id; 1080 bridge_id_to_request_id_map_[bridge_id] = request_id;
1075 } 1081 }
1076 1082
1077 int BrowserPluginGuest::RemoveBridgeID(int bridge_id) { 1083 int BrowserPluginGuest::RemoveBridgeID(int bridge_id) {
1078 std::map<int, int>::iterator bridge_itr = 1084 std::map<int, int>::iterator bridge_itr =
1079 bridge_id_to_request_id_map_.find(bridge_id); 1085 bridge_id_to_request_id_map_.find(bridge_id);
(...skipping 846 matching lines...) Expand 10 before | Expand all | Expand 10 after
1926 base::Value::CreateStringValue(request_method)); 1932 base::Value::CreateStringValue(request_method));
1927 request_info.Set(browser_plugin::kURL, base::Value::CreateStringValue(url)); 1933 request_info.Set(browser_plugin::kURL, base::Value::CreateStringValue(url));
1928 1934
1929 RequestPermission(BROWSER_PLUGIN_PERMISSION_TYPE_DOWNLOAD, 1935 RequestPermission(BROWSER_PLUGIN_PERMISSION_TYPE_DOWNLOAD,
1930 new DownloadRequest(weak_ptr_factory_.GetWeakPtr(), 1936 new DownloadRequest(weak_ptr_factory_.GetWeakPtr(),
1931 callback), 1937 callback),
1932 request_info); 1938 request_info);
1933 } 1939 }
1934 1940
1935 } // namespace content 1941 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/browser_plugin/browser_plugin_guest.h ('k') | content/browser/geolocation/geolocation_dispatcher_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698