blob: b39e2b3d7249bb41505e7fe1b124543a97ae67e7 [file] [log] [blame]
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef WEBLAYER_BROWSER_TOP_CONTROLS_CONTAINER_VIEW_H_
#define WEBLAYER_BROWSER_TOP_CONTROLS_CONTAINER_VIEW_H_
#include "base/android/scoped_java_ref.h"
#include "base/macros.h"
#include "base/memory/scoped_refptr.h"
#include "build/build_config.h"
namespace cc {
class UIResourceLayer;
} // namespace cc
namespace content {
class WebContents;
}
namespace weblayer {
class ContentViewRenderView;
// Native side of TopControlsContainerView. Responsible for creating and
// positioning the cc::Layer that contains an image of the contents of the
// top-control.
class TopControlsContainerView {
public:
TopControlsContainerView(content::WebContents* web_contents,
ContentViewRenderView* content_view_render_view);
~TopControlsContainerView();
// Height needed to display the top-control.
int GetTopControlsHeight();
// Creates |top_controls_layer_|.
void CreateTopControlsLayer(
JNIEnv* env,
const base::android::JavaParamRef<jobject>& caller,
int id);
// Deletes |this|.
void DeleteTopControlsContainerView(
JNIEnv* env,
const base::android::JavaParamRef<jobject>& caller);
// Deletes |top_controls_layer_|.
void DeleteTopControlsLayer(
JNIEnv* env,
const base::android::JavaParamRef<jobject>& caller);
// Sets the offsets of the top-controls and content. See ViewAndroidDelegate
// for details on this.
void SetTopControlsOffset(JNIEnv* env,
const base::android::JavaParamRef<jobject>& caller,
int top_controls_offset_y,
int top_content_offset_y);
// Sets the size of |top_controls_layer_|.
void SetTopControlsSize(JNIEnv* env,
const base::android::JavaParamRef<jobject>& caller,
int width,
int height);
// Triggers updating the resource (bitmap) shown in |top_controls_layer_|.
void UpdateTopControlsResource(
JNIEnv* env,
const base::android::JavaParamRef<jobject>& caller);
private:
ContentViewRenderView* content_view_render_view_;
content::WebContents* web_contents_;
int top_controls_resource_id_ = -1;
// Layer containing showing the image for the top-controls. This is a sibling
// of the WebContents layer.
scoped_refptr<cc::UIResourceLayer> top_controls_layer_;
DISALLOW_COPY_AND_ASSIGN(TopControlsContainerView);
};
} // namespace weblayer
#endif // WEBLAYER_BROWSER_TOP_CONTROLS_CONTAINER_VIEW_H_