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

Side by Side Diff: chrome/browser/content_settings/permission_context_base.cc

Issue 459953002: Migrate geolocation permissions to the new common permission class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 2 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/content_settings/permission_context_base.h" 5 #include "chrome/browser/content_settings/permission_context_base.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/prefs/pref_service.h" 8 #include "base/prefs/pref_service.h"
9 #include "chrome/browser/content_settings/host_content_settings_map.h" 9 #include "chrome/browser/content_settings/host_content_settings_map.h"
10 #include "chrome/browser/content_settings/permission_bubble_request_impl.h" 10 #include "chrome/browser/content_settings/permission_bubble_request_impl.h"
(...skipping 11 matching lines...) Expand all
22 Profile* profile, 22 Profile* profile,
23 const ContentSettingsType permission_type) 23 const ContentSettingsType permission_type)
24 : profile_(profile), 24 : profile_(profile),
25 permission_type_(permission_type), 25 permission_type_(permission_type),
26 weak_factory_(this) { 26 weak_factory_(this) {
27 permission_queue_controller_.reset( 27 permission_queue_controller_.reset(
28 new PermissionQueueController(profile_, permission_type_)); 28 new PermissionQueueController(profile_, permission_type_));
29 } 29 }
30 30
31 PermissionContextBase::~PermissionContextBase() { 31 PermissionContextBase::~PermissionContextBase() {
32 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 32 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
33 } 33 }
34 34
35 void PermissionContextBase::RequestPermission( 35 void PermissionContextBase::RequestPermission(
36 content::WebContents* web_contents, 36 content::WebContents* web_contents,
37 const PermissionRequestID& id, 37 const PermissionRequestID& id,
38 const GURL& requesting_frame, 38 const GURL& requesting_frame,
39 bool user_gesture, 39 bool user_gesture,
40 const BrowserPermissionCallback& callback) { 40 const BrowserPermissionCallback& callback) {
41 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 41 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
42 42
43 DecidePermission(web_contents, 43 DecidePermission(web_contents,
44 id, 44 id,
45 requesting_frame.GetOrigin(), 45 requesting_frame.GetOrigin(),
46 web_contents->GetLastCommittedURL().GetOrigin(), 46 web_contents->GetLastCommittedURL().GetOrigin(),
47 user_gesture, 47 user_gesture,
48 callback); 48 callback);
49 } 49 }
50 50
51 void PermissionContextBase::CancelPermissionRequest(
52 content::WebContents* web_contents,
53 const PermissionRequestID& id) {
54 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
55
56 if (PermissionBubbleManager::Enabled()) {
57 PermissionBubbleRequest* cancelling =
58 pending_bubbles_.get(id.ToString());
59 if (cancelling != NULL && web_contents != NULL &&
60 PermissionBubbleManager::FromWebContents(web_contents) != NULL) {
61 PermissionBubbleManager::FromWebContents(web_contents)->
62 CancelRequest(cancelling);
63 }
64 return;
65 }
66
67 GetQueueController()->CancelInfoBarRequest(id);
68 }
69
51 void PermissionContextBase::DecidePermission( 70 void PermissionContextBase::DecidePermission(
52 content::WebContents* web_contents, 71 content::WebContents* web_contents,
53 const PermissionRequestID& id, 72 const PermissionRequestID& id,
54 const GURL& requesting_origin, 73 const GURL& requesting_origin,
55 const GURL& embedder_origin, 74 const GURL& embedder_origin,
56 bool user_gesture, 75 bool user_gesture,
57 const BrowserPermissionCallback& callback) { 76 const BrowserPermissionCallback& callback) {
58 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 77 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
59 78
60 ContentSetting content_setting = 79 ContentSetting content_setting =
61 profile_->GetHostContentSettingsMap()->GetContentSetting( 80 profile_->GetHostContentSettingsMap()
81 ->GetContentSettingAndMaybeUpdateLastUsage(
62 requesting_origin, embedder_origin, permission_type_, std::string()); 82 requesting_origin, embedder_origin, permission_type_, std::string());
63 switch (content_setting) { 83 switch (content_setting) {
64 case CONTENT_SETTING_BLOCK: 84 case CONTENT_SETTING_BLOCK:
65 NotifyPermissionSet(id, requesting_origin, embedder_origin, 85 NotifyPermissionSet(id, requesting_origin, embedder_origin,
66 callback, false /* persist */, false /* granted */); 86 callback, false /* persist */, false /* granted */);
67 return; 87 return;
68 case CONTENT_SETTING_ALLOW: 88 case CONTENT_SETTING_ALLOW:
69 NotifyPermissionSet(id, requesting_origin, embedder_origin, 89 NotifyPermissionSet(id, requesting_origin, embedder_origin,
70 callback, false /* persist */, true /* granted */); 90 callback, false /* persist */, true /* granted */);
71 return; 91 return;
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 DCHECK_EQ(embedder_origin, embedder_origin.GetOrigin()); 196 DCHECK_EQ(embedder_origin, embedder_origin.GetOrigin());
177 ContentSetting content_setting = 197 ContentSetting content_setting =
178 allowed ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK; 198 allowed ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK;
179 profile_->GetHostContentSettingsMap()->SetContentSetting( 199 profile_->GetHostContentSettingsMap()->SetContentSetting(
180 ContentSettingsPattern::FromURLNoWildcard(requesting_origin), 200 ContentSettingsPattern::FromURLNoWildcard(requesting_origin),
181 ContentSettingsPattern::FromURLNoWildcard(embedder_origin), 201 ContentSettingsPattern::FromURLNoWildcard(embedder_origin),
182 permission_type_, 202 permission_type_,
183 std::string(), 203 std::string(),
184 content_setting); 204 content_setting);
185 } 205 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698