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.Intent; | 7 import android.content.Intent; |
8 import android.graphics.Bitmap; | 8 import android.graphics.Bitmap; |
9 import android.graphics.Color; | 9 import android.graphics.Color; |
10 import android.graphics.drawable.Drawable; | 10 import android.graphics.drawable.Drawable; |
(...skipping 19 matching lines...) Expand all Loading... |
30 import org.chromium.blink_public.platform.WebDisplayMode; | 30 import org.chromium.blink_public.platform.WebDisplayMode; |
31 import org.chromium.chrome.R; | 31 import org.chromium.chrome.R; |
32 import org.chromium.chrome.browser.TabState; | 32 import org.chromium.chrome.browser.TabState; |
33 import org.chromium.chrome.browser.document.DocumentUtils; | 33 import org.chromium.chrome.browser.document.DocumentUtils; |
34 import org.chromium.chrome.browser.fullscreen.ChromeFullscreenManager; | 34 import org.chromium.chrome.browser.fullscreen.ChromeFullscreenManager; |
35 import org.chromium.chrome.browser.metrics.WebappUma; | 35 import org.chromium.chrome.browser.metrics.WebappUma; |
36 import org.chromium.chrome.browser.tab.EmptyTabObserver; | 36 import org.chromium.chrome.browser.tab.EmptyTabObserver; |
37 import org.chromium.chrome.browser.tab.Tab; | 37 import org.chromium.chrome.browser.tab.Tab; |
38 import org.chromium.chrome.browser.tab.TabDelegateFactory; | 38 import org.chromium.chrome.browser.tab.TabDelegateFactory; |
39 import org.chromium.chrome.browser.tab.TabObserver; | 39 import org.chromium.chrome.browser.tab.TabObserver; |
40 import org.chromium.chrome.browser.tab.TopControlsVisibilityDelegate; | |
41 import org.chromium.chrome.browser.util.ColorUtils; | 40 import org.chromium.chrome.browser.util.ColorUtils; |
42 import org.chromium.chrome.browser.util.UrlUtilities; | 41 import org.chromium.chrome.browser.util.UrlUtilities; |
43 import org.chromium.chrome.browser.widget.ControlContainer; | 42 import org.chromium.chrome.browser.widget.ControlContainer; |
44 import org.chromium.components.security_state.ConnectionSecurityLevel; | |
45 import org.chromium.content.browser.ScreenOrientationProvider; | 43 import org.chromium.content.browser.ScreenOrientationProvider; |
46 import org.chromium.content_public.browser.LoadUrlParams; | 44 import org.chromium.content_public.browser.LoadUrlParams; |
47 import org.chromium.net.NetworkChangeNotifier; | 45 import org.chromium.net.NetworkChangeNotifier; |
48 import org.chromium.ui.base.PageTransition; | 46 import org.chromium.ui.base.PageTransition; |
49 | 47 |
50 import java.io.File; | 48 import java.io.File; |
51 import java.io.FileNotFoundException; | 49 import java.io.FileNotFoundException; |
52 import java.io.FileOutputStream; | 50 import java.io.FileOutputStream; |
53 import java.io.IOException; | 51 import java.io.IOException; |
54 import java.util.concurrent.TimeUnit; | 52 import java.util.concurrent.TimeUnit; |
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
570 return R.dimen.webapp_control_container_height; | 568 return R.dimen.webapp_control_container_height; |
571 } | 569 } |
572 | 570 |
573 @Override | 571 @Override |
574 protected Drawable getBackgroundDrawable() { | 572 protected Drawable getBackgroundDrawable() { |
575 return null; | 573 return null; |
576 } | 574 } |
577 | 575 |
578 @Override | 576 @Override |
579 protected TabDelegateFactory createTabDelegateFactory() { | 577 protected TabDelegateFactory createTabDelegateFactory() { |
580 return new FullScreenDelegateFactory() { | 578 return new WebappDelegateFactory(this); |
581 @Override | |
582 public TopControlsVisibilityDelegate createTopControlsVisibilityDele
gate(Tab tab) { | |
583 return new TopControlsVisibilityDelegate(tab) { | |
584 @Override | |
585 public boolean isShowingTopControlsEnabled() { | |
586 if (!super.isShowingTopControlsEnabled()) return false; | |
587 return shouldShowTopControls(mTab.getUrl(), mTab.getSecu
rityLevel()); | |
588 } | |
589 | |
590 @Override | |
591 public boolean isHidingTopControlsEnabled() { | |
592 return !isShowingTopControlsEnabled(); | |
593 } | |
594 }; | |
595 } | |
596 }; | |
597 } | |
598 | |
599 public boolean shouldShowTopControls(String url, int securityLevel) { | |
600 // Do not show top controls when URL is not ready yet. | |
601 boolean visible = false; | |
602 if (TextUtils.isEmpty(url)) return false; | |
603 | |
604 boolean isSameWebsite = UrlUtilities.sameDomainOrHost( | |
605 mWebappInfo.uri().toString(), url, true); | |
606 visible = !isSameWebsite | |
607 || securityLevel == ConnectionSecurityLevel.SECURITY_ERROR | |
608 || securityLevel == ConnectionSecurityLevel.SECURITY_WARNING; | |
609 return visible; | |
610 } | 579 } |
611 | 580 |
612 // We're temporarily disable CS on webapp since there are some issues. (http
://crbug.com/471950) | 581 // We're temporarily disable CS on webapp since there are some issues. (http
://crbug.com/471950) |
613 // TODO(changwan): re-enable it once the issues are resolved. | 582 // TODO(changwan): re-enable it once the issues are resolved. |
614 @Override | 583 @Override |
615 protected boolean isContextualSearchAllowed() { | 584 protected boolean isContextualSearchAllowed() { |
616 return false; | 585 return false; |
617 } | 586 } |
618 } | 587 } |
OLD | NEW |