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

Unified Diff: third_party/WebKit/Source/modules/battery/NavigatorBattery.cpp

Issue 2937553005: Revert of [Battery] Allow usage from SecureContext or top-level browsing context only. (Closed)
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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/LayoutTests/external/wpt/battery-status/battery-insecure-context-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/modules/battery/NavigatorBattery.cpp
diff --git a/third_party/WebKit/Source/modules/battery/NavigatorBattery.cpp b/third_party/WebKit/Source/modules/battery/NavigatorBattery.cpp
index a6c7351d00ee32c2c5a555e8ef586002598b334f..5f6423f1c51a6e9bbb419a0c4de6c0893311d7d1 100644
--- a/third_party/WebKit/Source/modules/battery/NavigatorBattery.cpp
+++ b/third_party/WebKit/Source/modules/battery/NavigatorBattery.cpp
@@ -4,10 +4,8 @@
#include "modules/battery/NavigatorBattery.h"
-#include "core/dom/DOMException.h"
-#include "core/dom/Document.h"
-#include "core/dom/ExceptionCode.h"
-#include "core/frame/LocalDOMWindow.h"
+#include "core/dom/ExecutionContext.h"
+#include "core/frame/LocalFrame.h"
#include "modules/battery/BatteryManager.h"
namespace blink {
@@ -21,26 +19,10 @@
}
ScriptPromise NavigatorBattery::getBattery(ScriptState* script_state) {
- ExecutionContext* execution_context = ExecutionContext::From(script_state);
-
- // Check secure context.
- String error_message;
- if (!execution_context->IsSecureContext(error_message)) {
- return ScriptPromise::RejectWithDOMException(
- script_state, DOMException::Create(kSecurityError, error_message));
+ if (!battery_manager_) {
+ battery_manager_ =
+ BatteryManager::Create(ExecutionContext::From(script_state));
}
-
- // Check top-level browsing context.
- if (!ToDocument(execution_context)->domWindow()->GetFrame() ||
- !ToDocument(execution_context)->GetFrame()->IsMainFrame()) {
- return ScriptPromise::RejectWithDOMException(
- script_state, DOMException::Create(
- kSecurityError, "Not a top-level browsing context."));
- }
-
- if (!battery_manager_)
- battery_manager_ = BatteryManager::Create(execution_context);
-
return battery_manager_->StartRequest(script_state);
}
« no previous file with comments | « third_party/WebKit/LayoutTests/external/wpt/battery-status/battery-insecure-context-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698