[Cronet] Delay StartNetLog and StopNetLog until native request context is initialized
[chromium-blink-merge.git] / chrome / browser / android / transition_page_helper.cc
blob713c3861547dcab8eb2376f45613ec80339fdff0
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
3 // found in the LICENSE file.
5 #include "chrome/browser/android/transition_page_helper.h"
7 #include "cc/layers/layer.h"
8 #include "chrome/browser/android/tab_android.h"
9 #include "chrome/browser/ui/android/window_android_helper.h"
10 #include "content/public/browser/android/content_view_core.h"
11 #include "content/public/browser/web_contents.h"
12 #include "jni/TransitionPageHelper_jni.h"
14 // TODO(simonhatch): Why does 1.f opacity seem to kill per-pixel alpha?
15 const float TRANSITION_MAX_OPACITY = 0.99999f;
17 TransitionPageHelper* TransitionPageHelper::FromJavaObject(JNIEnv* env,
18 jobject jobj) {
19 return reinterpret_cast<TransitionPageHelper*>(
20 Java_TransitionPageHelper_getNativePtr(env, jobj));
23 TransitionPageHelper::TransitionPageHelper() {
26 TransitionPageHelper::~TransitionPageHelper() {
29 void TransitionPageHelper::Destroy(JNIEnv* env, jobject jobj) {
30 delete this;
33 void TransitionPageHelper::SetWebContents(JNIEnv* env,
34 jobject jobj,
35 jobject jcontent_view_core) {
36 content::ContentViewCore* content_view_core =
37 content::ContentViewCore::GetNativeContentViewCore(env,
38 jcontent_view_core);
39 DCHECK(content_view_core);
40 DCHECK(content_view_core->GetWebContents());
42 web_contents_.reset(content_view_core->GetWebContents());
45 void TransitionPageHelper::ReleaseWebContents(JNIEnv* env, jobject jobj) {
46 DCHECK(web_contents_.get());
47 web_contents_.reset();
50 void TransitionPageHelper::SetOpacity(JNIEnv* env,
51 jobject jobj,
52 jobject jcontent_view_core,
53 jfloat opacity) {
54 content::ContentViewCore* content_view_core =
55 content::ContentViewCore::GetNativeContentViewCore(env,
56 jcontent_view_core);
57 if (!content_view_core)
58 return;
60 content_view_core->GetLayer()->SetOpacity(
61 std::min(opacity, TRANSITION_MAX_OPACITY));
64 static jlong Init(JNIEnv* env, jobject obj) {
65 return reinterpret_cast<long>(new TransitionPageHelper());
68 bool TransitionPageHelper::Register(JNIEnv* env) {
69 return RegisterNativesImpl(env);