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

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: plumb through Created 6 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 | 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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 104
105 private: 105 private:
106 virtual ~DownloadRequest() {} 106 virtual ~DownloadRequest() {}
107 base::Callback<void(bool)> callback_; 107 base::Callback<void(bool)> callback_;
108 }; 108 };
109 109
110 class BrowserPluginGuest::GeolocationRequest : public PermissionRequest { 110 class BrowserPluginGuest::GeolocationRequest : public PermissionRequest {
111 public: 111 public:
112 GeolocationRequest(const base::WeakPtr<BrowserPluginGuest>& guest, 112 GeolocationRequest(const base::WeakPtr<BrowserPluginGuest>& guest,
113 GeolocationCallback callback, 113 GeolocationCallback callback,
114 int bridge_id) 114 int bridge_id,
115 bool user_gesture)
115 : PermissionRequest(guest), 116 : PermissionRequest(guest),
116 callback_(callback), 117 callback_(callback),
117 bridge_id_(bridge_id) { 118 bridge_id_(bridge_id),
119 user_gesture_(user_gesture) {
118 RecordAction( 120 RecordAction(
119 base::UserMetricsAction("BrowserPlugin.Guest.PermissionRequest.Geolocati on")); 121 base::UserMetricsAction("BrowserPlugin.Guest.PermissionRequest.Geolocati on"));
120 } 122 }
121 123
122 virtual void RespondImpl(bool should_allow, 124 virtual void RespondImpl(bool should_allow,
123 const std::string& user_input) OVERRIDE { 125 const std::string& user_input) OVERRIDE {
124 WebContents* web_contents = guest_->embedder_web_contents(); 126 WebContents* web_contents = guest_->embedder_web_contents();
125 if (should_allow && web_contents) { 127 if (should_allow && web_contents) {
126 // If renderer side embedder decides to allow gelocation, we need to check 128 // If renderer side embedder decides to allow gelocation, we need to check
127 // if the app/embedder itself has geolocation access. 129 // if the app/embedder itself has geolocation access.
128 BrowserContext* browser_context = web_contents->GetBrowserContext(); 130 BrowserContext* browser_context = web_contents->GetBrowserContext();
129 if (browser_context) { 131 if (browser_context) {
130 GeolocationPermissionContext* geolocation_context = 132 GeolocationPermissionContext* geolocation_context =
131 browser_context->GetGeolocationPermissionContext(); 133 browser_context->GetGeolocationPermissionContext();
132 if (geolocation_context) { 134 if (geolocation_context) {
133 base::Callback<void(bool)> geolocation_callback = base::Bind( 135 base::Callback<void(bool)> geolocation_callback = base::Bind(
134 &BrowserPluginGuest::SetGeolocationPermission, 136 &BrowserPluginGuest::SetGeolocationPermission,
135 guest_, 137 guest_,
136 callback_, 138 callback_,
137 bridge_id_); 139 bridge_id_);
138 geolocation_context->RequestGeolocationPermission( 140 geolocation_context->RequestGeolocationPermission(
139 web_contents->GetRenderProcessHost()->GetID(), 141 web_contents->GetRenderProcessHost()->GetID(),
140 web_contents->GetRoutingID(), 142 web_contents->GetRoutingID(),
141 // The geolocation permission request here is not initiated 143 // The geolocation permission request here is not initiated
142 // through WebGeolocationPermissionRequest. We are only interested 144 // through WebGeolocationPermissionRequest. We are only interested
143 // in the fact whether the embedder/app has geolocation 145 // in the fact whether the embedder/app has geolocation
144 // permission. Therefore we use an invalid |bridge_id|. 146 // permission. Therefore we use an invalid |bridge_id|.
145 -1 /* bridge_id */, 147 -1 /* bridge_id */,
146 web_contents->GetLastCommittedURL(), 148 web_contents->GetLastCommittedURL(),
149 user_gesture_,
147 geolocation_callback); 150 geolocation_callback);
148 return; 151 return;
149 } 152 }
150 } 153 }
151 } 154 }
152 guest_->SetGeolocationPermission(callback_, bridge_id_, false); 155 guest_->SetGeolocationPermission(callback_, bridge_id_, false);
153 } 156 }
154 157
155 private: 158 private:
156 virtual ~GeolocationRequest() {} 159 virtual ~GeolocationRequest() {}
157 base::Callback<void(bool)> callback_; 160 base::Callback<void(bool)> callback_;
158 int bridge_id_; 161 int bridge_id_;
162 bool user_gesture_;
159 }; 163 };
160 164
161 class BrowserPluginGuest::MediaRequest : public PermissionRequest { 165 class BrowserPluginGuest::MediaRequest : public PermissionRequest {
162 public: 166 public:
163 MediaRequest(const base::WeakPtr<BrowserPluginGuest>& guest, 167 MediaRequest(const base::WeakPtr<BrowserPluginGuest>& guest,
164 const MediaStreamRequest& request, 168 const MediaStreamRequest& request,
165 const MediaResponseCallback& callback) 169 const MediaResponseCallback& callback)
166 : PermissionRequest(guest), 170 : PermissionRequest(guest),
167 request_(request), 171 request_(request),
168 callback_(callback) { 172 callback_(callback) {
(...skipping 876 matching lines...) Expand 10 before | Expand all | Expand 10 after
1045 } 1049 }
1046 1050
1047 void BrowserPluginGuest::SetDelegate(BrowserPluginGuestDelegate* delegate) { 1051 void BrowserPluginGuest::SetDelegate(BrowserPluginGuestDelegate* delegate) {
1048 DCHECK(!delegate_); 1052 DCHECK(!delegate_);
1049 delegate_.reset(delegate); 1053 delegate_.reset(delegate);
1050 } 1054 }
1051 1055
1052 void BrowserPluginGuest::AskEmbedderForGeolocationPermission( 1056 void BrowserPluginGuest::AskEmbedderForGeolocationPermission(
1053 int bridge_id, 1057 int bridge_id,
1054 const GURL& requesting_frame, 1058 const GURL& requesting_frame,
1059 bool user_gesture,
1055 const GeolocationCallback& callback) { 1060 const GeolocationCallback& callback) {
1056 base::DictionaryValue request_info; 1061 base::DictionaryValue request_info;
1057 request_info.Set(browser_plugin::kURL, 1062 request_info.Set(browser_plugin::kURL,
1058 base::Value::CreateStringValue(requesting_frame.spec())); 1063 base::Value::CreateStringValue(requesting_frame.spec()));
1059 1064
1060 int request_id = 1065 int request_id =
1061 RequestPermission(BROWSER_PLUGIN_PERMISSION_TYPE_GEOLOCATION, 1066 RequestPermission(BROWSER_PLUGIN_PERMISSION_TYPE_GEOLOCATION,
1062 new GeolocationRequest(weak_ptr_factory_.GetWeakPtr(), 1067 new GeolocationRequest(weak_ptr_factory_.GetWeakPtr(),
1063 callback, 1068 callback,
1064 bridge_id), 1069 bridge_id,
1070 user_gesture),
1065 request_info); 1071 request_info);
1066 1072
1067 DCHECK(bridge_id_to_request_id_map_.find(bridge_id) == 1073 DCHECK(bridge_id_to_request_id_map_.find(bridge_id) ==
1068 bridge_id_to_request_id_map_.end()); 1074 bridge_id_to_request_id_map_.end());
1069 bridge_id_to_request_id_map_[bridge_id] = request_id; 1075 bridge_id_to_request_id_map_[bridge_id] = request_id;
1070 } 1076 }
1071 1077
1072 int BrowserPluginGuest::RemoveBridgeID(int bridge_id) { 1078 int BrowserPluginGuest::RemoveBridgeID(int bridge_id) {
1073 std::map<int, int>::iterator bridge_itr = 1079 std::map<int, int>::iterator bridge_itr =
1074 bridge_id_to_request_id_map_.find(bridge_id); 1080 bridge_id_to_request_id_map_.find(bridge_id);
(...skipping 843 matching lines...) Expand 10 before | Expand all | Expand 10 after
1918 base::Value::CreateStringValue(request_method)); 1924 base::Value::CreateStringValue(request_method));
1919 request_info.Set(browser_plugin::kURL, base::Value::CreateStringValue(url)); 1925 request_info.Set(browser_plugin::kURL, base::Value::CreateStringValue(url));
1920 1926
1921 RequestPermission(BROWSER_PLUGIN_PERMISSION_TYPE_DOWNLOAD, 1927 RequestPermission(BROWSER_PLUGIN_PERMISSION_TYPE_DOWNLOAD,
1922 new DownloadRequest(weak_ptr_factory_.GetWeakPtr(), 1928 new DownloadRequest(weak_ptr_factory_.GetWeakPtr(),
1923 callback), 1929 callback),
1924 request_info); 1930 request_info);
1925 } 1931 }
1926 1932
1927 } // namespace content 1933 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698