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

Side by Side Diff: chrome/browser/download/trusted_sources_manager_win.cc

Issue 2943763002: Add a new group policy to disable safe browsing for files downloaded from trusted sources. (Closed)
Patch Set: Rebase Created 3 years, 6 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
(Empty)
1 // Copyright (c) 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/download/trusted_sources_manager.h"
6
7 #include <urlmon.h>
8
9 #include "base/logging.h"
10 #include "base/strings/string_util.h"
11 #include "base/strings/utf_string_conversions.h"
12 #include "base/win/scoped_comptr.h"
13 #include "url/gurl.h"
14
15 class TrustedSourcesManagerWin : public TrustedSourcesManager {
David Trainor- moved to gerrit 2017/06/23 07:32:47 Put this and all methods in an anonymous namespace
MAD 2017/06/29 14:44:53 Done.
16 public:
17 TrustedSourcesManagerWin();
18 ~TrustedSourcesManagerWin() override;
19
20 // TrustedSourcesManager methods:
21 bool IsFromTrustedSource(const GURL& url) const override;
22 };
23
24 TrustedSourcesManagerWin::TrustedSourcesManagerWin() {}
David Trainor- moved to gerrit 2017/06/23 07:32:47 = default on constructor/destructor
MAD 2017/06/29 14:44:53 Done.
25 TrustedSourcesManagerWin::~TrustedSourcesManagerWin() {}
26
27 bool TrustedSourcesManagerWin::IsFromTrustedSource(const GURL& url) const {
28 if (TrustedSourcesManager::IsFromTrustedSource(url))
29 return true;
30
31 base::win::ScopedComPtr<IInternetSecurityManager> security_manager;
32 HRESULT hr = ::CoInternetCreateSecurityManager(
33 NULL, security_manager.GetAddressOf(), NULL);
34 // URLZONE_LOCAL_MACHINE 0
35 // URLZONE_INTRANET 1
36 // URLZONE_TRUSTED 2
37 // URLZONE_INTERNET 3
38 // URLZONE_UNTRUSTED 4
39 DWORD zone = 0;
40 base::string16 url16 = base::ASCIIToUTF16(url.spec());
41 hr = security_manager->MapUrlToZone(url16.c_str(), &zone, 0);
42 if (FAILED(hr)) {
43 LOG(ERROR) << "security_manager->MapUrlToZone failed with hr: " << std::hex
44 << hr;
45 return false;
46 }
47 return zone <= static_cast<DWORD>(URLZONE_TRUSTED);
48 }
49
50 // static
51 TrustedSourcesManager* TrustedSourcesManager::Create() {
52 return new TrustedSourcesManagerWin;
53 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698