Skip to content

Commit

Permalink
[Chromecast] Add CastContentWindow::NotifyVisibilityChange
Browse files Browse the repository at this point in the history
By default, this should just propagate visibility information to the
delegate. In the future, NotifyVisibilityChange should only be called
by the window manager. Documentation for CastContentWindow was improved
as a minor clean up.

Bug: internal b/79874784
Test: CQ
Change-Id: I3eab9b60b74037cd1f122e03460d0b8fe6db00c0
Reviewed-on: https://chromium-review.googlesource.com/1086042
Commit-Queue: Sean Topping <seantopping@chromium.org>
Reviewed-by: Stephen Lanham <slan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#564644}
  • Loading branch information
Sean Topping authored and Commit Bot committed Jun 5, 2018
1 parent f8e6447 commit e63fc10
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 8 deletions.
7 changes: 6 additions & 1 deletion chromecast/browser/android/cast_content_window_android.cc
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ void CastContentWindowAndroid::RequestVisibility(
env, java_window_, static_cast<int>(visibility_priority));
}

void CastContentWindowAndroid::NotifyVisibilityChange(
VisibilityType visibility_type) {
delegate_->OnVisibilityChange(visibility_type);
}

void CastContentWindowAndroid::RequestMoveOut() {
JNIEnv* env = base::android::AttachCurrentThread();
Java_CastContentWindowAndroid_requestMoveOut(env, java_window_);
Expand All @@ -119,7 +124,7 @@ void CastContentWindowAndroid::OnVisibilityChange(
JNIEnv* env,
const base::android::JavaParamRef<jobject>& jcaller,
int visibility_type) {
delegate_->OnVisibilityChange(static_cast<VisibilityType>(visibility_type));
NotifyVisibilityChange(static_cast<VisibilityType>(visibility_type));
}

base::android::ScopedJavaLocalRef<jstring> CastContentWindowAndroid::GetId(
Expand Down
4 changes: 1 addition & 3 deletions chromecast/browser/android/cast_content_window_android.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,9 @@ class CastContentWindowAndroid : public CastContentWindow {
bool is_visible,
CastWindowManager::WindowId z_order,
VisibilityPriority visibility_priority) override;

void EnableTouchInput(bool enabled) override;

void RequestVisibility(VisibilityPriority visibility_priority) override;

void NotifyVisibilityChange(VisibilityType visibility_type) override;
void RequestMoveOut() override;

// Called through JNI.
Expand Down
23 changes: 22 additions & 1 deletion chromecast/browser/cast_content_window.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,29 @@
namespace chromecast {
namespace shell {

// Describes visual context of the window within the UI.
enum class VisibilityType {
// Unknown visibility state.
UNKNOWN = 0,

// Window is occupying the entire screen and can be interacted with.
FULL_SCREEN = 1,

// Window occupies a portion of the screen, supporting user interaction.
PARTIAL_OUT = 2,
HIDDEN = 3

// Window is hidden, and cannot be interacted with via touch.
HIDDEN = 3,

// Window is being displayed as a small visible tile.
TILE = 4
};

// Represents requested activity windowing behavior. Behavior includes:
// 1. How long the activity should show
// 2. Whether the window should become immediately visible
// 3. How much screen space the window should occupy
// 4. What state to return to when the activity is completed
enum class VisibilityPriority {
// Default priority. It is up to system to decide how to show the activity.
DEFAULT = 0,
Expand Down Expand Up @@ -110,6 +126,11 @@ class CastContentWindow {
// change.
virtual void RequestVisibility(VisibilityPriority visibility_priority) = 0;

// Notify the window that its visibility type has changed. This should only
// ever be called by the window manager.
// TODO(seantopping): Make this private to the window manager.
virtual void NotifyVisibilityChange(VisibilityType visibility_type) = 0;

// Cast activity or application calls it to request for moving out of the
// screen.
virtual void RequestMoveOut() = 0;
Expand Down
14 changes: 11 additions & 3 deletions chromecast/browser/cast_content_window_aura.cc
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,12 @@ std::unique_ptr<CastContentWindow> CastContentWindow::Create(
CastContentWindowAura::CastContentWindowAura(
CastContentWindow::Delegate* delegate,
bool is_touch_enabled)
: back_gesture_dispatcher_(
std::make_unique<CastBackGestureDispatcher>(delegate)),
is_touch_enabled_(is_touch_enabled) {}
: delegate_(delegate),
back_gesture_dispatcher_(
std::make_unique<CastBackGestureDispatcher>(delegate_)),
is_touch_enabled_(is_touch_enabled) {
DCHECK(delegate_);
}

CastContentWindowAura::~CastContentWindowAura() {
if (window_manager_)
Expand Down Expand Up @@ -118,6 +121,11 @@ void CastContentWindowAura::EnableTouchInput(bool enabled) {
void CastContentWindowAura::RequestVisibility(
VisibilityPriority visibility_priority){};

void CastContentWindowAura::NotifyVisibilityChange(
VisibilityType visibility_type) {
delegate_->OnVisibilityChange(visibility_type);
}

void CastContentWindowAura::RequestMoveOut(){};

bool CastContentWindowAura::CanHandleSwipe(CastSideSwipeOrigin swipe_origin) {
Expand Down
3 changes: 3 additions & 0 deletions chromecast/browser/cast_content_window_aura.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class CastContentWindowAura : public CastContentWindow,
CastWindowManager::WindowId z_order,
VisibilityPriority visibility_priority) override;
void RequestVisibility(VisibilityPriority visibility_priority) override;
void NotifyVisibilityChange(VisibilityType visibility_type) override;
void RequestMoveOut() override;
void EnableTouchInput(bool enabled) override;

Expand All @@ -48,6 +49,8 @@ class CastContentWindowAura : public CastContentWindow,
// This class should only be instantiated by CastContentWindow::Create.
CastContentWindowAura(Delegate* delegate, bool is_touch_enabled);

CastContentWindow::Delegate* const delegate_;

// Utility class for detecting and dispatching back gestures to delegates.
std::unique_ptr<CastBackGestureDispatcher> back_gesture_dispatcher_;

Expand Down

0 comments on commit e63fc10

Please sign in to comment.