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

Side by Side Diff: remoting/host/host_attributes.cc

Issue 2936603003: [Chromoting] Implement host safe-mode
Patch Set: 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
« no previous file with comments | « remoting/host/desktop_environment_options.cc ('k') | remoting/host/safe_mode.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "remoting/host/host_attributes.h" 5 #include "remoting/host/host_attributes.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <D3DCommon.h> 8 #include <D3DCommon.h>
9 #endif 9 #endif
10 10
11 #include <type_traits> 11 #include <type_traits>
12 12
13 #include "base/atomicops.h" 13 #include "base/atomicops.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "build/build_config.h" 16 #include "build/build_config.h"
17 #include "remoting/host/safe_mode.h"
17 18
18 #if defined(OS_WIN) 19 #if defined(OS_WIN)
19 #include "third_party/webrtc/modules/desktop_capture/win/dxgi_duplicator_control ler.h" 20 #include "third_party/webrtc/modules/desktop_capture/win/dxgi_duplicator_control ler.h"
20 #include "third_party/webrtc/modules/desktop_capture/win/screen_capturer_win_dir ectx.h" 21 #include "third_party/webrtc/modules/desktop_capture/win/screen_capturer_win_dir ectx.h"
21 #endif 22 #endif
22 23
23 namespace remoting { 24 namespace remoting {
24 25
25 namespace { 26 namespace {
26 static constexpr char kSeparator[] = ","; 27 static constexpr char kSeparator[] = ",";
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 #else 59 #else
59 return false; 60 return false;
60 #endif 61 #endif
61 } 62 }
62 63
63 inline constexpr bool IsNonOfficialBuild() { 64 inline constexpr bool IsNonOfficialBuild() {
64 return !IsOfficialBuild(); 65 return !IsOfficialBuild();
65 } 66 }
66 67
67 #if defined(OS_WIN) 68 #if defined(OS_WIN)
69 inline bool IsDirectxCapturerSupported() {
70 if (ExecuteHostInSafeMode()) {
71 return false;
72 }
73
74 return webrtc::ScreenCapturerWinDirectx::IsSupported();
75 }
76
68 inline bool MinD3DFeatureLevelGreatThan10() { 77 inline bool MinD3DFeatureLevelGreatThan10() {
78 if (ExecuteHostInSafeMode()) {
79 return false;
80 }
81
69 webrtc::DxgiDuplicatorController::D3dInfo info; 82 webrtc::DxgiDuplicatorController::D3dInfo info;
70 if (webrtc::DxgiDuplicatorController::Instance()->RetrieveD3dInfo(&info)) { 83 if (webrtc::DxgiDuplicatorController::Instance()->RetrieveD3dInfo(&info)) {
71 return info.min_feature_level >= D3D_FEATURE_LEVEL_10_0; 84 return info.min_feature_level >= D3D_FEATURE_LEVEL_10_0;
72 } 85 }
73 return false; 86 return false;
74 } 87 }
75 88
76 inline bool MinD3DFeatureLevelGreatThan11() { 89 inline bool MinD3DFeatureLevelGreatThan11() {
90 if (ExecuteHostInSafeMode()) {
91 return false;
92 }
93
77 webrtc::DxgiDuplicatorController::D3dInfo info; 94 webrtc::DxgiDuplicatorController::D3dInfo info;
78 if (webrtc::DxgiDuplicatorController::Instance()->RetrieveD3dInfo(&info)) { 95 if (webrtc::DxgiDuplicatorController::Instance()->RetrieveD3dInfo(&info)) {
79 return info.min_feature_level >= D3D_FEATURE_LEVEL_11_0; 96 return info.min_feature_level >= D3D_FEATURE_LEVEL_11_0;
80 } 97 }
81 return false; 98 return false;
82 } 99 }
83 100
84 inline bool MinD3DFeatureLevelGreatThan12() { 101 inline bool MinD3DFeatureLevelGreatThan12() {
102 if (ExecuteHostInSafeMode()) {
103 return false;
104 }
105
85 webrtc::DxgiDuplicatorController::D3dInfo info; 106 webrtc::DxgiDuplicatorController::D3dInfo info;
86 if (webrtc::DxgiDuplicatorController::Instance()->RetrieveD3dInfo(&info)) { 107 if (webrtc::DxgiDuplicatorController::Instance()->RetrieveD3dInfo(&info)) {
87 return info.min_feature_level >= D3D_FEATURE_LEVEL_12_0; 108 return info.min_feature_level >= D3D_FEATURE_LEVEL_12_0;
88 } 109 }
89 return false; 110 return false;
90 } 111 }
91 #endif 112 #endif
92 113
93 // By using arraysize() macro in base/macros.h, it's illegal to have empty 114 // By using arraysize() macro in base/macros.h, it's illegal to have empty
94 // arrays. 115 // arrays.
95 // 116 //
96 // error: no matching function for call to 'ArraySizeHelper' 117 // error: no matching function for call to 'ArraySizeHelper'
97 // note: candidate template ignored: substitution failure 118 // note: candidate template ignored: substitution failure
98 // [with T = const remoting::StaticAttribute, N = 0]: 119 // [with T = const remoting::StaticAttribute, N = 0]:
99 // zero-length arrays are not permitted in C++. 120 // zero-length arrays are not permitted in C++.
100 // 121 //
101 // So we need IsDebug() function, and "Debug-Build" Attribute. 122 // So we need IsDebug() function, and "Debug-Build" Attribute.
102 123
103 static constexpr Attribute kAttributes[] = { 124 static constexpr Attribute kAttributes[] = {
104 { "Debug-Build", &IsDebug }, 125 { "Debug-Build", &IsDebug },
105 { "ChromeBrand", &IsChromeBranded }, 126 { "ChromeBrand", &IsChromeBranded },
106 { "ChromiumBrand", &IsChromiumBranded }, 127 { "ChromiumBrand", &IsChromiumBranded },
107 { "OfficialBuild", &IsOfficialBuild }, 128 { "OfficialBuild", &IsOfficialBuild },
108 { "NonOfficialBuild", &IsNonOfficialBuild }, 129 { "NonOfficialBuild", &IsNonOfficialBuild },
130 { "Safe-Mode", &ExecuteHostInSafeMode },
109 #if defined(OS_WIN) 131 #if defined(OS_WIN)
110 { "DirectX-Capturer", &webrtc::ScreenCapturerWinDirectx::IsSupported }, 132 { "DirectX-Capturer", &IsDirectxCapturerSupported },
111 { "MinD3DGT10", &MinD3DFeatureLevelGreatThan10 }, 133 { "MinD3DGT10", &MinD3DFeatureLevelGreatThan10 },
112 { "MinD3DGT11", &MinD3DFeatureLevelGreatThan11 }, 134 { "MinD3DGT11", &MinD3DFeatureLevelGreatThan11 },
113 { "MinD3DGT12", &MinD3DFeatureLevelGreatThan12 }, 135 { "MinD3DGT12", &MinD3DFeatureLevelGreatThan12 },
114 #endif 136 #endif
115 }; 137 };
116 138
117 } // namespace 139 } // namespace
118 140
119 static_assert(std::is_pod<Attribute>::value, "Attribute should be POD."); 141 static_assert(std::is_pod<Attribute>::value, "Attribute should be POD.");
120 142
(...skipping 10 matching lines...) Expand all
131 result.append(kSeparator); 153 result.append(kSeparator);
132 } 154 }
133 result.append(attribute.name); 155 result.append(attribute.name);
134 } 156 }
135 } 157 }
136 158
137 return result; 159 return result;
138 } 160 }
139 161
140 } // namespace remoting 162 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/desktop_environment_options.cc ('k') | remoting/host/safe_mode.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698