OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "config.h" | 5 #include "config.h" |
6 #include "core/experiments/Experiments.h" | 6 #include "core/experiments/Experiments.h" |
7 | 7 |
8 #include "core/dom/ElementTraversal.h" | 8 #include "core/dom/ElementTraversal.h" |
9 #include "core/dom/ExceptionCode.h" | 9 #include "core/dom/ExceptionCode.h" |
10 #include "core/html/HTMLHeadElement.h" | 10 #include "core/html/HTMLHeadElement.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 } else { | 50 } else { |
51 errorMessage = getDisabledMessage(apiName); | 51 errorMessage = getDisabledMessage(apiName); |
52 } | 52 } |
53 return false; | 53 return false; |
54 } | 54 } |
55 | 55 |
56 } // namespace | 56 } // namespace |
57 | 57 |
58 bool Experiments::isApiEnabled(ExecutionContext* executionContext, const String&
apiName, String& errorMessage) | 58 bool Experiments::isApiEnabled(ExecutionContext* executionContext, const String&
apiName, String& errorMessage) |
59 { | 59 { |
| 60 return isApiEnabledInternal(executionContext, apiName, errorMessage); |
| 61 } |
| 62 |
| 63 bool Experiments::isApiEnabled(ExecutionContext* executionContext, const String&
apiName) |
| 64 { |
| 65 String errorMessage; |
| 66 return isApiEnabledInternal(executionContext, apiName, errorMessage); |
| 67 } |
| 68 |
| 69 bool Experiments::isApiEnabledInternal(ExecutionContext* executionContext, const
String& apiName, String& errorMessage) |
| 70 { |
60 if (!RuntimeEnabledFeatures::experimentalFrameworkEnabled()) { | 71 if (!RuntimeEnabledFeatures::experimentalFrameworkEnabled()) { |
61 errorMessage = "Experimental Framework is not enabled."; | 72 errorMessage = "Experimental Framework is not enabled."; |
62 return false; | 73 return false; |
63 } | 74 } |
64 | 75 |
65 if (!executionContext) { | 76 if (!executionContext) { |
66 ASSERT_NOT_REACHED(); | 77 ASSERT_NOT_REACHED(); |
67 return false; | 78 return false; |
68 } | 79 } |
69 | 80 |
70 // Experiments are only enabled for secure origins | 81 // Experiments are only enabled for secure origins |
71 if (!executionContext->isSecureContext(errorMessage)) { | 82 if (!executionContext->isSecureContext(errorMessage)) { |
72 return false; | 83 return false; |
73 } | 84 } |
74 | 85 |
75 return hasValidAPIKey(executionContext, apiName, errorMessage); | 86 return hasValidAPIKey(executionContext, apiName, errorMessage); |
76 } | 87 } |
77 | 88 |
78 DOMException* Experiments::createApiDisabledException(const String& apiName) | 89 DOMException* Experiments::createApiDisabledException(const String& apiName) |
79 { | 90 { |
80 return DOMException::create(NotSupportedError, getDisabledMessage(apiName)); | 91 return DOMException::create(NotSupportedError, getDisabledMessage(apiName)); |
81 } | 92 } |
82 | 93 |
83 } // namespace blink | 94 } // namespace blink |
OLD | NEW |