OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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 package org.chromium.chrome.browser.webapps; | 5 package org.chromium.chrome.browser.webapps; |
6 | 6 |
7 import android.content.Context; | 7 import android.content.Context; |
8 import android.graphics.Color; | 8 import android.graphics.Color; |
| 9 import android.graphics.Rect; |
9 import android.util.AttributeSet; | 10 import android.util.AttributeSet; |
10 import android.view.View; | 11 import android.view.View; |
11 | 12 |
12 import org.chromium.chrome.browser.compositor.layouts.eventfilter.EdgeSwipeHandl
er; | 13 import org.chromium.chrome.browser.compositor.layouts.eventfilter.EdgeSwipeHandl
er; |
| 14 import org.chromium.chrome.browser.compositor.resources.ResourceFactory; |
13 import org.chromium.chrome.browser.widget.ClipDrawableProgressBar.DrawingInfo; | 15 import org.chromium.chrome.browser.widget.ClipDrawableProgressBar.DrawingInfo; |
14 import org.chromium.chrome.browser.widget.ControlContainer; | 16 import org.chromium.chrome.browser.widget.ControlContainer; |
15 import org.chromium.chrome.browser.widget.ViewResourceFrameLayout; | 17 import org.chromium.chrome.browser.widget.ViewResourceFrameLayout; |
16 import org.chromium.ui.resources.dynamics.ViewResourceAdapter; | 18 import org.chromium.ui.resources.dynamics.ViewResourceAdapter; |
17 | 19 |
18 /** | 20 /** |
19 * The control container used by WebApps. | 21 * The control container used by WebApps. |
20 */ | 22 */ |
21 public class WebappControlContainer extends ViewResourceFrameLayout | 23 public class WebappControlContainer extends ViewResourceFrameLayout |
22 implements ControlContainer { | 24 implements ControlContainer { |
| 25 private class WebAppViewResourceAdapter extends ViewResourceAdapter { |
| 26 private final Rect mToolbarRect = new Rect(); |
| 27 private final Rect mLocationBarContentRect = new Rect(); |
| 28 |
| 29 public WebAppViewResourceAdapter(View view) { |
| 30 super(view); |
| 31 } |
| 32 |
| 33 @Override |
| 34 public long createNativeResource() { |
| 35 mToolbarRect.set(0, 0, getWidth(), getHeight()); |
| 36 mLocationBarContentRect.set(0, 0, getWidth(), getHeight()); |
| 37 return ResourceFactory.createToolbarContainerResource( |
| 38 mToolbarRect, mLocationBarContentRect, 0); |
| 39 } |
| 40 } |
23 | 41 |
24 /** Constructor for inflating from XML. */ | 42 /** Constructor for inflating from XML. */ |
25 public WebappControlContainer(Context context, AttributeSet attrs) { | 43 public WebappControlContainer(Context context, AttributeSet attrs) { |
26 super(context, attrs); | 44 super(context, attrs); |
27 } | 45 } |
28 | 46 |
29 @Override | 47 @Override |
30 public void initWithToolbar(int toolbarLayoutId) { | 48 public void initWithToolbar(int toolbarLayoutId) { |
31 } | 49 } |
32 | 50 |
33 @Override | 51 @Override |
| 52 protected final ViewResourceAdapter createResourceAdapter() { |
| 53 return new WebAppViewResourceAdapter(this); |
| 54 } |
| 55 |
| 56 @Override |
34 public ViewResourceAdapter getToolbarResourceAdapter() { | 57 public ViewResourceAdapter getToolbarResourceAdapter() { |
35 return getResourceAdapter(); | 58 return getResourceAdapter(); |
36 } | 59 } |
37 | 60 |
38 @Override | 61 @Override |
39 public void getProgressBarDrawingInfo(DrawingInfo drawingInfoOut) { | 62 public void getProgressBarDrawingInfo(DrawingInfo drawingInfoOut) { |
40 } | 63 } |
41 | 64 |
42 @Override | 65 @Override |
43 public void setSwipeHandler(EdgeSwipeHandler handler) { | 66 public void setSwipeHandler(EdgeSwipeHandler handler) { |
44 } | 67 } |
45 | 68 |
46 @Override | 69 @Override |
47 public int getToolbarBackgroundColor() { | 70 public int getToolbarBackgroundColor() { |
48 return Color.WHITE; | 71 return Color.WHITE; |
49 } | 72 } |
50 | 73 |
51 @Override | 74 @Override |
52 public View getView() { | 75 public View getView() { |
53 return this; | 76 return this; |
54 } | 77 } |
55 } | 78 } |
OLD | NEW |