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 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
571 return R.dimen.webapp_control_container_height; | 569 return R.dimen.webapp_control_container_height; |
572 } | 570 } |
573 | 571 |
574 @Override | 572 @Override |
575 protected Drawable getBackgroundDrawable() { | 573 protected Drawable getBackgroundDrawable() { |
576 return null; | 574 return null; |
577 } | 575 } |
578 | 576 |
579 @Override | 577 @Override |
580 protected TabDelegateFactory createTabDelegateFactory() { | 578 protected TabDelegateFactory createTabDelegateFactory() { |
581 return new FullScreenDelegateFactory() { | 579 return new WebappDelegateFactory(this); |
582 @Override | |
583 public TopControlsVisibilityDelegate createTopControlsVisibilityDele
gate(Tab tab) { | |
584 return new TopControlsVisibilityDelegate(tab) { | |
585 @Override | |
586 public boolean isShowingTopControlsEnabled() { | |
587 if (!super.isShowingTopControlsEnabled()) return false; | |
588 return shouldShowTopControls(mTab.getUrl(), mTab.getSecu
rityLevel()); | |
589 } | |
590 | |
591 @Override | |
592 public boolean isHidingTopControlsEnabled() { | |
593 return !isShowingTopControlsEnabled(); | |
594 } | |
595 }; | |
596 } | |
597 }; | |
598 } | |
599 | |
600 public boolean shouldShowTopControls(String url, int securityLevel) { | |
601 // Do not show top controls when URL is not ready yet. | |
602 boolean visible = false; | |
603 if (TextUtils.isEmpty(url)) return false; | |
604 | |
605 boolean isSameWebsite = UrlUtilities.sameDomainOrHost( | |
606 mWebappInfo.uri().toString(), url, true); | |
607 visible = !isSameWebsite | |
608 || securityLevel == ConnectionSecurityLevel.SECURITY_ERROR | |
609 || securityLevel == ConnectionSecurityLevel.SECURITY_WARNING; | |
610 return visible; | |
611 } | 580 } |
612 | 581 |
613 // We're temporarily disable CS on webapp since there are some issues. (http
://crbug.com/471950) | 582 // We're temporarily disable CS on webapp since there are some issues. (http
://crbug.com/471950) |
614 // TODO(changwan): re-enable it once the issues are resolved. | 583 // TODO(changwan): re-enable it once the issues are resolved. |
615 @Override | 584 @Override |
616 protected boolean isContextualSearchAllowed() { | 585 protected boolean isContextualSearchAllowed() { |
617 return false; | 586 return false; |
618 } | 587 } |
619 } | 588 } |
OLD | NEW |