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

Side by Side Diff: chrome/browser/permissions/permission_blacklist_client.cc

Issue 2675483002: Replace PermissionType in chrome/ with ContentSettingsType (Closed)
Patch Set: ready Created 3 years, 10 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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/permissions/permission_blacklist_client.h" 5 #include "chrome/browser/permissions/permission_blacklist_client.h"
6 6
7 #include <set> 7 #include <set>
8 #include <string> 8 #include <string>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/memory/ptr_util.h" 11 #include "base/memory/ptr_util.h"
12 #include "base/timer/timer.h" 12 #include "base/timer/timer.h"
13 #include "content/public/browser/browser_thread.h" 13 #include "content/public/browser/browser_thread.h"
14 #include "content/public/browser/web_contents.h" 14 #include "content/public/browser/web_contents.h"
15 #include "url/gurl.h" 15 #include "url/gurl.h"
16 16
17 // static 17 // static
18 void PermissionBlacklistClient::CheckSafeBrowsingBlacklist( 18 void PermissionBlacklistClient::CheckSafeBrowsingBlacklist(
19 scoped_refptr<safe_browsing::SafeBrowsingDatabaseManager> db_manager, 19 scoped_refptr<safe_browsing::SafeBrowsingDatabaseManager> db_manager,
20 content::PermissionType permission_type, 20 ContentSettingsType content_settings_type,
21 const GURL& request_origin, 21 const GURL& request_origin,
22 content::WebContents* web_contents, 22 content::WebContents* web_contents,
23 int timeout, 23 int timeout,
24 base::Callback<void(bool)> callback) { 24 base::Callback<void(bool)> callback) {
25 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 25 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
26 26
27 new PermissionBlacklistClient(db_manager, permission_type, request_origin, 27 new PermissionBlacklistClient(db_manager, content_settings_type,
28 web_contents, timeout, callback); 28 request_origin, web_contents, timeout,
29 callback);
29 } 30 }
30 31
31 PermissionBlacklistClient::PermissionBlacklistClient( 32 PermissionBlacklistClient::PermissionBlacklistClient(
32 scoped_refptr<safe_browsing::SafeBrowsingDatabaseManager> db_manager, 33 scoped_refptr<safe_browsing::SafeBrowsingDatabaseManager> db_manager,
33 content::PermissionType permission_type, 34 ContentSettingsType content_settings_type,
34 const GURL& request_origin, 35 const GURL& request_origin,
35 content::WebContents* web_contents, 36 content::WebContents* web_contents,
36 int timeout, 37 int timeout,
37 base::Callback<void(bool)> callback) 38 base::Callback<void(bool)> callback)
38 : content::WebContentsObserver(web_contents), 39 : content::WebContentsObserver(web_contents),
39 db_manager_(db_manager), 40 db_manager_(db_manager),
40 permission_type_(permission_type), 41 content_settings_type_(content_settings_type),
41 callback_(callback), 42 callback_(callback),
42 timeout_(timeout), 43 timeout_(timeout),
43 is_active_(true) { 44 is_active_(true) {
44 // Balanced by a call to Release() in OnCheckApiBlacklistUrlResult(). 45 // Balanced by a call to Release() in OnCheckApiBlacklistUrlResult().
45 AddRef(); 46 AddRef();
46 content::BrowserThread::PostTask( 47 content::BrowserThread::PostTask(
47 content::BrowserThread::IO, FROM_HERE, 48 content::BrowserThread::IO, FROM_HERE,
48 base::Bind(&PermissionBlacklistClient::StartCheck, this, request_origin)); 49 base::Bind(&PermissionBlacklistClient::StartCheck, this, request_origin));
49 } 50 }
50 51
(...skipping 19 matching lines...) Expand all
70 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); 71 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
71 72
72 if (timer_->IsRunning()) 73 if (timer_->IsRunning())
73 timer_->Stop(); 74 timer_->Stop();
74 else 75 else
75 db_manager_->CancelApiCheck(this); 76 db_manager_->CancelApiCheck(this);
76 timer_.reset(nullptr); 77 timer_.reset(nullptr);
77 78
78 bool permission_blocked = 79 bool permission_blocked =
79 metadata.api_permissions.find( 80 metadata.api_permissions.find(
80 PermissionUtil::ConvertPermissionTypeToSafeBrowsingName( 81 PermissionUtil::ConvertContentSettingsTypeToSafeBrowsingName(
81 permission_type_)) != metadata.api_permissions.end(); 82 content_settings_type_)) != metadata.api_permissions.end();
82 83
83 content::BrowserThread::PostTask( 84 content::BrowserThread::PostTask(
84 content::BrowserThread::UI, FROM_HERE, 85 content::BrowserThread::UI, FROM_HERE,
85 base::Bind(&PermissionBlacklistClient::EvaluateBlacklistResultOnUiThread, 86 base::Bind(&PermissionBlacklistClient::EvaluateBlacklistResultOnUiThread,
86 this, permission_blocked)); 87 this, permission_blocked));
87 } 88 }
88 89
89 void PermissionBlacklistClient::EvaluateBlacklistResultOnUiThread( 90 void PermissionBlacklistClient::EvaluateBlacklistResultOnUiThread(
90 bool permission_blocked) { 91 bool permission_blocked) {
91 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 92 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
92 93
93 if (is_active_) 94 if (is_active_)
94 callback_.Run(permission_blocked); 95 callback_.Run(permission_blocked);
95 Release(); 96 Release();
96 } 97 }
97 98
98 void PermissionBlacklistClient::WebContentsDestroyed() { 99 void PermissionBlacklistClient::WebContentsDestroyed() {
99 is_active_ = false; 100 is_active_ = false;
100 Observe(nullptr); 101 Observe(nullptr);
101 } 102 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698