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

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

Issue 360773003: [Geolocation] Enable content settings write using permissions bubbles. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Param order Created 6 years, 5 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
« no previous file with comments | « chrome/browser/content_settings/permission_queue_controller.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/geolocation_permission_context.h" 5 #include "chrome/browser/geolocation/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
(...skipping 15 matching lines...) Expand all
26 #include "grit/generated_resources.h" 26 #include "grit/generated_resources.h"
27 #include "grit/theme_resources.h" 27 #include "grit/theme_resources.h"
28 #include "net/base/net_util.h" 28 #include "net/base/net_util.h"
29 #include "ui/base/l10n/l10n_util.h" 29 #include "ui/base/l10n/l10n_util.h"
30 30
31 class GeolocationPermissionRequest : public PermissionBubbleRequest { 31 class GeolocationPermissionRequest : public PermissionBubbleRequest {
32 public: 32 public:
33 GeolocationPermissionRequest(GeolocationPermissionContext* context, 33 GeolocationPermissionRequest(GeolocationPermissionContext* context,
34 const PermissionRequestID& id, 34 const PermissionRequestID& id,
35 const GURL& requesting_frame, 35 const GURL& requesting_frame,
36 const GURL& embedder,
36 bool user_gesture, 37 bool user_gesture,
37 base::Callback<void(bool)> callback, 38 base::Callback<void(bool)> callback,
38 const std::string& display_languages); 39 const std::string& display_languages);
39 virtual ~GeolocationPermissionRequest(); 40 virtual ~GeolocationPermissionRequest();
40 41
41 // PermissionBubbleDelegate: 42 // PermissionBubbleDelegate:
42 virtual int GetIconID() const OVERRIDE; 43 virtual int GetIconID() const OVERRIDE;
43 virtual base::string16 GetMessageText() const OVERRIDE; 44 virtual base::string16 GetMessageText() const OVERRIDE;
44 virtual base::string16 GetMessageTextFragment() const OVERRIDE; 45 virtual base::string16 GetMessageTextFragment() const OVERRIDE;
45 virtual bool HasUserGesture() const OVERRIDE; 46 virtual bool HasUserGesture() const OVERRIDE;
46 virtual GURL GetRequestingHostname() const OVERRIDE; 47 virtual GURL GetRequestingHostname() const OVERRIDE;
47 virtual void PermissionGranted() OVERRIDE; 48 virtual void PermissionGranted() OVERRIDE;
48 virtual void PermissionDenied() OVERRIDE; 49 virtual void PermissionDenied() OVERRIDE;
49 virtual void Cancelled() OVERRIDE; 50 virtual void Cancelled() OVERRIDE;
50 virtual void RequestFinished() OVERRIDE; 51 virtual void RequestFinished() OVERRIDE;
51 52
52 private: 53 private:
53 GeolocationPermissionContext* context_; 54 GeolocationPermissionContext* context_;
54 PermissionRequestID id_; 55 PermissionRequestID id_;
55 GURL requesting_frame_; 56 GURL requesting_frame_;
57 GURL embedder_;
56 bool user_gesture_; 58 bool user_gesture_;
57 base::Callback<void(bool)> callback_; 59 base::Callback<void(bool)> callback_;
58 std::string display_languages_; 60 std::string display_languages_;
59 }; 61 };
60 62
61 GeolocationPermissionRequest::GeolocationPermissionRequest( 63 GeolocationPermissionRequest::GeolocationPermissionRequest(
62 GeolocationPermissionContext* context, 64 GeolocationPermissionContext* context,
63 const PermissionRequestID& id, 65 const PermissionRequestID& id,
64 const GURL& requesting_frame, 66 const GURL& requesting_frame,
67 const GURL& embedder,
65 bool user_gesture, 68 bool user_gesture,
66 base::Callback<void(bool)> callback, 69 base::Callback<void(bool)> callback,
67 const std::string& display_languages) 70 const std::string& display_languages)
68 : context_(context), 71 : context_(context),
69 id_(id), 72 id_(id),
70 requesting_frame_(requesting_frame), 73 requesting_frame_(requesting_frame),
74 embedder_(embedder),
71 user_gesture_(user_gesture), 75 user_gesture_(user_gesture),
72 callback_(callback), 76 callback_(callback),
73 display_languages_(display_languages) {} 77 display_languages_(display_languages) {}
74 78
75 GeolocationPermissionRequest::~GeolocationPermissionRequest() {} 79 GeolocationPermissionRequest::~GeolocationPermissionRequest() {}
76 80
77 int GeolocationPermissionRequest::GetIconID() const { 81 int GeolocationPermissionRequest::GetIconID() const {
78 return IDR_INFOBAR_GEOLOCATION; 82 return IDR_INFOBAR_GEOLOCATION;
79 } 83 }
80 84
81 base::string16 GeolocationPermissionRequest::GetMessageText() const { 85 base::string16 GeolocationPermissionRequest::GetMessageText() const {
82 return l10n_util::GetStringFUTF16(IDS_GEOLOCATION_INFOBAR_QUESTION, 86 return l10n_util::GetStringFUTF16(IDS_GEOLOCATION_INFOBAR_QUESTION,
83 net::FormatUrl(requesting_frame_, display_languages_)); 87 net::FormatUrl(requesting_frame_, display_languages_));
84 } 88 }
85 89
86 base::string16 GeolocationPermissionRequest::GetMessageTextFragment() const { 90 base::string16 GeolocationPermissionRequest::GetMessageTextFragment() const {
87 return l10n_util::GetStringUTF16(IDS_GEOLOCATION_INFOBAR_PERMISSION_FRAGMENT); 91 return l10n_util::GetStringUTF16(IDS_GEOLOCATION_INFOBAR_PERMISSION_FRAGMENT);
88 } 92 }
89 93
90 bool GeolocationPermissionRequest::HasUserGesture() const { 94 bool GeolocationPermissionRequest::HasUserGesture() const {
91 return user_gesture_; 95 return user_gesture_;
92 } 96 }
93 97
94 GURL GeolocationPermissionRequest::GetRequestingHostname() const { 98 GURL GeolocationPermissionRequest::GetRequestingHostname() const {
95 return requesting_frame_; 99 return requesting_frame_;
96 } 100 }
97 101
98 void GeolocationPermissionRequest::PermissionGranted() { 102 void GeolocationPermissionRequest::PermissionGranted() {
103 context_->QueueController()->UpdateContentSetting(
104 requesting_frame_, embedder_, true);
99 context_->NotifyPermissionSet(id_, requesting_frame_, callback_, true); 105 context_->NotifyPermissionSet(id_, requesting_frame_, callback_, true);
100 } 106 }
101 107
102 void GeolocationPermissionRequest::PermissionDenied() { 108 void GeolocationPermissionRequest::PermissionDenied() {
109 context_->QueueController()->UpdateContentSetting(
110 requesting_frame_, embedder_, false);
103 context_->NotifyPermissionSet(id_, requesting_frame_, callback_, false); 111 context_->NotifyPermissionSet(id_, requesting_frame_, callback_, false);
104 } 112 }
105 113
106 void GeolocationPermissionRequest::Cancelled() { 114 void GeolocationPermissionRequest::Cancelled() {
107 } 115 }
108 116
109 void GeolocationPermissionRequest::RequestFinished() { 117 void GeolocationPermissionRequest::RequestFinished() {
110 // Deletes 'this'. 118 // Deletes 'this'.
111 context_->RequestFinished(this); 119 context_->RequestFinished(this);
112 } 120 }
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 case CONTENT_SETTING_ALLOW: 215 case CONTENT_SETTING_ALLOW:
208 PermissionDecided(id, requesting_frame, embedder, callback, true); 216 PermissionDecided(id, requesting_frame, embedder, callback, true);
209 break; 217 break;
210 default: 218 default:
211 if (PermissionBubbleManager::Enabled()) { 219 if (PermissionBubbleManager::Enabled()) {
212 PermissionBubbleManager* mgr = 220 PermissionBubbleManager* mgr =
213 PermissionBubbleManager::FromWebContents(web_contents); 221 PermissionBubbleManager::FromWebContents(web_contents);
214 if (mgr) { 222 if (mgr) {
215 scoped_ptr<GeolocationPermissionRequest> request_ptr( 223 scoped_ptr<GeolocationPermissionRequest> request_ptr(
216 new GeolocationPermissionRequest( 224 new GeolocationPermissionRequest(
217 this, id, requesting_frame, user_gesture, callback, 225 this, id, requesting_frame, embedder, user_gesture, callback,
218 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages))); 226 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages)));
219 GeolocationPermissionRequest* request = request_ptr.get(); 227 GeolocationPermissionRequest* request = request_ptr.get();
220 pending_requests_.add(id.ToString(), request_ptr.Pass()); 228 pending_requests_.add(id.ToString(), request_ptr.Pass());
221 mgr->AddRequest(request); 229 mgr->AddRequest(request);
222 } 230 }
223 } else { 231 } else {
224 // setting == ask. Prompt the user. 232 // setting == ask. Prompt the user.
225 QueueController()->CreateInfoBarRequest( 233 QueueController()->CreateInfoBarRequest(
226 id, requesting_frame, embedder, accept_button_label, 234 id, requesting_frame, embedder, accept_button_label,
227 base::Bind( 235 base::Bind(
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 if (cancelling != NULL && web_contents != NULL && 328 if (cancelling != NULL && web_contents != NULL &&
321 PermissionBubbleManager::FromWebContents(web_contents) != NULL) { 329 PermissionBubbleManager::FromWebContents(web_contents) != NULL) {
322 PermissionBubbleManager::FromWebContents(web_contents)-> 330 PermissionBubbleManager::FromWebContents(web_contents)->
323 CancelRequest(cancelling); 331 CancelRequest(cancelling);
324 } 332 }
325 return; 333 return;
326 } 334 }
327 335
328 QueueController()->CancelInfoBarRequest(id); 336 QueueController()->CancelInfoBarRequest(id);
329 } 337 }
OLDNEW
« no previous file with comments | « chrome/browser/content_settings/permission_queue_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698