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

Side by Side Diff: content/public/android/java/src/org/chromium/content/browser/PowerSaveBlocker.java

Issue 2075153002: Reland of 'Move content/browser/power_save_blocker to //device/power_save_blocker' (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: missing libs for component mac Created 4 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 | « content/public/android/BUILD.gn ('k') | content/public/browser/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2013 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 package org.chromium.content.browser;
6
7 import android.view.View;
8
9 import org.chromium.base.annotations.CalledByNative;
10 import org.chromium.base.annotations.JNINamespace;
11 import org.chromium.ui.base.ViewAndroidDelegate;
12
13 import java.lang.ref.WeakReference;
14
15 @JNINamespace("content")
16 class PowerSaveBlocker {
17 // WeakReference to prevent leaks in Android WebView.
18 private WeakReference<View> mKeepScreenOnView;
19
20 @CalledByNative
21 private static PowerSaveBlocker create() {
22 return new PowerSaveBlocker();
23 }
24
25 private PowerSaveBlocker() {}
26
27 @CalledByNative
28 private void applyBlock(ViewAndroidDelegate delegate) {
29 assert mKeepScreenOnView == null;
30 View anchorView = delegate.acquireAnchorView();
31 mKeepScreenOnView = new WeakReference<>(anchorView);
32 delegate.setAnchorViewPosition(anchorView, 0, 0, 0, 0);
33 anchorView.setKeepScreenOn(true);
34 }
35
36 @CalledByNative
37 private void removeBlock(ViewAndroidDelegate delegate) {
38 assert mKeepScreenOnView != null;
39 View anchorView = mKeepScreenOnView.get();
40 mKeepScreenOnView = null;
41 if (anchorView == null) return;
42
43 anchorView.setKeepScreenOn(false);
44 delegate.releaseAnchorView(anchorView);
45 }
46 }
OLDNEW
« no previous file with comments | « content/public/android/BUILD.gn ('k') | content/public/browser/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698