| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "device/power_save_blocker/power_save_blocker.h" | 5 #include "device/power_save_blocker/power_save_blocker.h" |
| 6 | 6 |
| 7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); | 56 DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); |
| 57 | 57 |
| 58 if (!view_android_) | 58 if (!view_android_) |
| 59 return; | 59 return; |
| 60 | 60 |
| 61 JNIEnv* env = AttachCurrentThread(); | 61 JNIEnv* env = AttachCurrentThread(); |
| 62 anchor_view_ = view_android_->AcquireAnchorView(); | 62 anchor_view_ = view_android_->AcquireAnchorView(); |
| 63 const ScopedJavaLocalRef<jobject> popup_view = anchor_view_.view(); | 63 const ScopedJavaLocalRef<jobject> popup_view = anchor_view_.view(); |
| 64 if (popup_view.is_null()) | 64 if (popup_view.is_null()) |
| 65 return; | 65 return; |
| 66 view_android_->SetAnchorRect(popup_view, gfx::RectF()); |
| 66 ScopedJavaLocalRef<jobject> obj(java_power_save_blocker_); | 67 ScopedJavaLocalRef<jobject> obj(java_power_save_blocker_); |
| 67 Java_PowerSaveBlocker_applyBlock(env, obj, popup_view); | 68 Java_PowerSaveBlocker_applyBlock(env, obj, popup_view); |
| 68 } | 69 } |
| 69 | 70 |
| 70 void PowerSaveBlocker::Delegate::RemoveBlock() { | 71 void PowerSaveBlocker::Delegate::RemoveBlock() { |
| 71 DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); | 72 DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); |
| 72 ScopedJavaLocalRef<jobject> obj(java_power_save_blocker_); | 73 ScopedJavaLocalRef<jobject> obj(java_power_save_blocker_); |
| 73 Java_PowerSaveBlocker_removeBlock(AttachCurrentThread(), obj); | 74 Java_PowerSaveBlocker_removeBlock(AttachCurrentThread(), obj); |
| 74 anchor_view_.Reset(); | 75 anchor_view_.Reset(); |
| 75 } | 76 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 96 const base::WeakPtr<ui::ViewAndroid>& view_android) { | 97 const base::WeakPtr<ui::ViewAndroid>& view_android) { |
| 97 DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); | 98 DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); |
| 98 if (!view_android) | 99 if (!view_android) |
| 99 return; | 100 return; |
| 100 | 101 |
| 101 delegate_ = new Delegate(view_android, ui_task_runner_); | 102 delegate_ = new Delegate(view_android, ui_task_runner_); |
| 102 delegate_->ApplyBlock(); | 103 delegate_->ApplyBlock(); |
| 103 } | 104 } |
| 104 | 105 |
| 105 } // namespace device | 106 } // namespace device |
| OLD | NEW |