Upstream version 7.35.139.0
[platform/framework/web/crosswalk.git] / src / content / public / android / java / src / org / chromium / content / browser / ActivityContentVideoViewClient.java
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.app.Activity;
8 import android.view.Gravity;
9 import android.view.View;
10 import android.view.ViewGroup;
11 import android.view.WindowManager;
12 import android.widget.FrameLayout;
13
14 /**
15  * Uses an existing Activity to handle displaying video in full screen.
16  */
17 public class ActivityContentVideoViewClient implements ContentVideoViewClient {
18     private final Activity mActivity;
19     private View mView;
20
21     public ActivityContentVideoViewClient(Activity activity)  {
22         this.mActivity = activity;
23     }
24
25     @Override
26     public boolean onShowCustomView(View view) {
27         mActivity.getWindow().setFlags(
28                 WindowManager.LayoutParams.FLAG_FULLSCREEN,
29                 WindowManager.LayoutParams.FLAG_FULLSCREEN);
30
31         mActivity.getWindow().addContentView(view,
32                 new FrameLayout.LayoutParams(
33                         ViewGroup.LayoutParams.MATCH_PARENT,
34                         ViewGroup.LayoutParams.MATCH_PARENT,
35                         Gravity.CENTER));
36         mView = view;
37         return true;
38     }
39
40     @Override
41     public void onDestroyContentVideoView() {
42         mActivity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
43         FrameLayout decor = (FrameLayout) mActivity.getWindow().getDecorView();
44         decor.removeView(mView);
45         mView = null;
46     }
47
48     @Override
49     public View getVideoLoadingProgressView() {
50         return null;
51     }
52 }