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

Side by Side Diff: net/http/url_security_manager_win.cc

Issue 266243004: Clang format slam. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "net/http/url_security_manager.h" 5 #include "net/http/url_security_manager.h"
6 6
7 #include <urlmon.h> 7 #include <urlmon.h>
8 #pragma comment(lib, "urlmon.lib") 8 #pragma comment(lib, "urlmon.lib")
9 9
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 const GURL& auth_origin) const { 52 const GURL& auth_origin) const {
53 if (!const_cast<URLSecurityManagerWin*>(this)->EnsureSystemSecurityManager()) 53 if (!const_cast<URLSecurityManagerWin*>(this)->EnsureSystemSecurityManager())
54 return false; 54 return false;
55 55
56 std::wstring url_w = base::ASCIIToWide(auth_origin.spec()); 56 std::wstring url_w = base::ASCIIToWide(auth_origin.spec());
57 DWORD policy = 0; 57 DWORD policy = 0;
58 HRESULT hr; 58 HRESULT hr;
59 hr = security_manager_->ProcessUrlAction(url_w.c_str(), 59 hr = security_manager_->ProcessUrlAction(url_w.c_str(),
60 URLACTION_CREDENTIALS_USE, 60 URLACTION_CREDENTIALS_USE,
61 reinterpret_cast<BYTE*>(&policy), 61 reinterpret_cast<BYTE*>(&policy),
62 sizeof(policy), NULL, 0, 62 sizeof(policy),
63 PUAF_NOUI, 0); 63 NULL,
64 0,
65 PUAF_NOUI,
66 0);
64 if (FAILED(hr)) { 67 if (FAILED(hr)) {
65 LOG(ERROR) << "IInternetSecurityManager::ProcessUrlAction failed: " << hr; 68 LOG(ERROR) << "IInternetSecurityManager::ProcessUrlAction failed: " << hr;
66 return false; 69 return false;
67 } 70 }
68 71
69 // Four possible policies for URLACTION_CREDENTIALS_USE. See the MSDN page 72 // Four possible policies for URLACTION_CREDENTIALS_USE. See the MSDN page
70 // "About URL Security Zones" at 73 // "About URL Security Zones" at
71 // http://msdn.microsoft.com/en-us/library/ms537183(VS.85).aspx 74 // http://msdn.microsoft.com/en-us/library/ms537183(VS.85).aspx
72 switch (policy) { 75 switch (policy) {
73 case URLPOLICY_CREDENTIALS_SILENT_LOGON_OK: 76 case URLPOLICY_CREDENTIALS_SILENT_LOGON_OK:
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 bool URLSecurityManagerWin::CanDelegate(const GURL& auth_origin) const { 108 bool URLSecurityManagerWin::CanDelegate(const GURL& auth_origin) const {
106 // TODO(cbentzel): Could this just use the security zone as well? Apparently 109 // TODO(cbentzel): Could this just use the security zone as well? Apparently
107 // this is what IE does as well. 110 // this is what IE does as well.
108 if (whitelist_delegate_.get()) 111 if (whitelist_delegate_.get())
109 return whitelist_delegate_->IsValid(auth_origin, HttpAuth::AUTH_SERVER); 112 return whitelist_delegate_->IsValid(auth_origin, HttpAuth::AUTH_SERVER);
110 return false; 113 return false;
111 } 114 }
112 115
113 bool URLSecurityManagerWin::EnsureSystemSecurityManager() { 116 bool URLSecurityManagerWin::EnsureSystemSecurityManager() {
114 if (!security_manager_) { 117 if (!security_manager_) {
115 HRESULT hr = CoInternetCreateSecurityManager(NULL, 118 HRESULT hr = CoInternetCreateSecurityManager(
116 security_manager_.Receive(), 119 NULL, security_manager_.Receive(), NULL);
117 NULL);
118 if (FAILED(hr) || !security_manager_) { 120 if (FAILED(hr) || !security_manager_) {
119 LOG(ERROR) << "Unable to create the Windows Security Manager instance"; 121 LOG(ERROR) << "Unable to create the Windows Security Manager instance";
120 return false; 122 return false;
121 } 123 }
122 } 124 }
123 return true; 125 return true;
124 } 126 }
125 127
126 // static 128 // static
127 URLSecurityManager* URLSecurityManager::Create( 129 URLSecurityManager* URLSecurityManager::Create(
128 const HttpAuthFilter* whitelist_default, 130 const HttpAuthFilter* whitelist_default,
129 const HttpAuthFilter* whitelist_delegate) { 131 const HttpAuthFilter* whitelist_delegate) {
130 // If we have a whitelist, just use that. 132 // If we have a whitelist, just use that.
131 if (whitelist_default) 133 if (whitelist_default)
132 return new URLSecurityManagerWhitelist(whitelist_default, 134 return new URLSecurityManagerWhitelist(whitelist_default,
133 whitelist_delegate); 135 whitelist_delegate);
134 return new URLSecurityManagerWin(whitelist_delegate); 136 return new URLSecurityManagerWin(whitelist_delegate);
135 } 137 }
136 138
137 } // namespace net 139 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698