| Index: chrome/browser/ui/toolbar/toolbar_model_impl.cc
|
| diff --git a/chrome/browser/ui/toolbar/toolbar_model_impl.cc b/chrome/browser/ui/toolbar/toolbar_model_impl.cc
|
| index 50df4f2e268ce70cf1ae3ba36a9ec5fd7632466f..e46fb0f747bce525847396a7f9ad54e02d5575f7 100644
|
| --- a/chrome/browser/ui/toolbar/toolbar_model_impl.cc
|
| +++ b/chrome/browser/ui/toolbar/toolbar_model_impl.cc
|
| @@ -51,6 +51,7 @@ ToolbarModelImpl::ToolbarModelImpl(ToolbarModelDelegate* delegate)
|
| ToolbarModelImpl::~ToolbarModelImpl() {
|
| }
|
|
|
| +// static
|
| ToolbarModel::SecurityLevel ToolbarModelImpl::GetSecurityLevelForWebContents(
|
| content::WebContents* web_contents) {
|
| if (!web_contents)
|
| @@ -94,6 +95,22 @@ ToolbarModel::SecurityLevel ToolbarModelImpl::GetSecurityLevelForWebContents(
|
| }
|
| }
|
|
|
| +// static
|
| +base::string16 ToolbarModelImpl::GetEVCertName(
|
| + const net::X509Certificate& cert) {
|
| + // EV are required to have an organization name and country.
|
| + if (cert.subject().organization_names.empty() ||
|
| + cert.subject().country_name.empty()) {
|
| + NOTREACHED();
|
| + return base::string16();
|
| + }
|
| +
|
| + return l10n_util::GetStringFUTF16(
|
| + IDS_SECURE_CONNECTION_EV,
|
| + base::UTF8ToUTF16(cert.subject().organization_names[0]),
|
| + base::UTF8ToUTF16(cert.subject().country_name));
|
| +}
|
| +
|
| // ToolbarModelImpl Implementation.
|
| base::string16 ToolbarModelImpl::GetText() const {
|
| base::string16 search_terms(GetSearchTerms(false));
|
| @@ -154,77 +171,11 @@ GURL ToolbarModelImpl::GetURL() const {
|
| return GURL(content::kAboutBlankURL);
|
| }
|
|
|
| -bool ToolbarModelImpl::WouldOmitURLDueToOriginChip() const {
|
| - const char kInterstitialShownKey[] = "interstitial_shown";
|
| -
|
| - // When users type URLs and hit enter, continue to show those URLs until
|
| - // the navigation commits or an interstitial is shown, because having the
|
| - // omnibox clear immediately feels like the input was ignored.
|
| - NavigationController* navigation_controller = GetNavigationController();
|
| - if (navigation_controller) {
|
| - NavigationEntry* pending_entry = navigation_controller->GetPendingEntry();
|
| - if (pending_entry) {
|
| - const NavigationEntry* visible_entry =
|
| - navigation_controller->GetVisibleEntry();
|
| - base::string16 unused;
|
| - // Keep track that we've shown the origin chip on an interstitial so it
|
| - // can be shown even after the interstitial was dismissed, to avoid
|
| - // showing the chip, removing it and then showing it again.
|
| - if (visible_entry &&
|
| - visible_entry->GetPageType() == content::PAGE_TYPE_INTERSTITIAL &&
|
| - !pending_entry->GetExtraData(kInterstitialShownKey, &unused))
|
| - pending_entry->SetExtraData(kInterstitialShownKey, base::string16());
|
| - const content::PageTransition transition_type =
|
| - pending_entry->GetTransitionType();
|
| - if ((transition_type & content::PAGE_TRANSITION_TYPED) != 0 &&
|
| - !pending_entry->GetExtraData(kInterstitialShownKey, &unused))
|
| - return false;
|
| - }
|
| - }
|
| -
|
| - bool should_display_origin_chip =
|
| - chrome::ShouldDisplayOriginChip() || chrome::ShouldDisplayOriginChipV2();
|
| - return should_display_origin_chip && delegate_->InTabbedBrowser() &&
|
| - ShouldDisplayURL() && url_replacement_enabled();
|
| -}
|
| -
|
| bool ToolbarModelImpl::WouldPerformSearchTermReplacement(
|
| bool ignore_editing) const {
|
| return !GetSearchTerms(ignore_editing).empty();
|
| }
|
|
|
| -bool ToolbarModelImpl::ShouldDisplayURL() const {
|
| - // Note: The order here is important.
|
| - // - The WebUI test must come before the extension scheme test because there
|
| - // can be WebUIs that have extension schemes (e.g. the bookmark manager). In
|
| - // that case, we should prefer what the WebUI instance says.
|
| - // - The view-source test must come before the NTP test because of the case
|
| - // of view-source:chrome://newtab, which should display its URL despite what
|
| - // chrome://newtab says.
|
| - NavigationController* controller = GetNavigationController();
|
| - NavigationEntry* entry = controller ? controller->GetVisibleEntry() : NULL;
|
| - if (entry) {
|
| - if (entry->IsViewSourceMode() ||
|
| - entry->GetPageType() == content::PAGE_TYPE_INTERSTITIAL) {
|
| - return true;
|
| - }
|
| -
|
| - GURL url = entry->GetURL();
|
| - GURL virtual_url = entry->GetVirtualURL();
|
| - if (url.SchemeIs(content::kChromeUIScheme) ||
|
| - virtual_url.SchemeIs(content::kChromeUIScheme)) {
|
| - if (!url.SchemeIs(content::kChromeUIScheme))
|
| - url = virtual_url;
|
| - return url.host() != chrome::kChromeUINewTabHost;
|
| - }
|
| - }
|
| -
|
| - if (chrome::IsInstantNTP(delegate_->GetActiveWebContents()))
|
| - return false;
|
| -
|
| - return true;
|
| -}
|
| -
|
| ToolbarModel::SecurityLevel ToolbarModelImpl::GetSecurityLevel(
|
| bool ignore_editing) const {
|
| // When editing, assume no security style.
|
| @@ -273,20 +224,70 @@ base::string16 ToolbarModelImpl::GetEVCertName() const {
|
| return GetEVCertName(*cert.get());
|
| }
|
|
|
| -// static
|
| -base::string16 ToolbarModelImpl::GetEVCertName(
|
| - const net::X509Certificate& cert) {
|
| - // EV are required to have an organization name and country.
|
| - if (cert.subject().organization_names.empty() ||
|
| - cert.subject().country_name.empty()) {
|
| - NOTREACHED();
|
| - return base::string16();
|
| +bool ToolbarModelImpl::ShouldDisplayURL() const {
|
| + // Note: The order here is important.
|
| + // - The WebUI test must come before the extension scheme test because there
|
| + // can be WebUIs that have extension schemes (e.g. the bookmark manager). In
|
| + // that case, we should prefer what the WebUI instance says.
|
| + // - The view-source test must come before the NTP test because of the case
|
| + // of view-source:chrome://newtab, which should display its URL despite what
|
| + // chrome://newtab says.
|
| + NavigationController* controller = GetNavigationController();
|
| + NavigationEntry* entry = controller ? controller->GetVisibleEntry() : NULL;
|
| + if (entry) {
|
| + if (entry->IsViewSourceMode() ||
|
| + entry->GetPageType() == content::PAGE_TYPE_INTERSTITIAL) {
|
| + return true;
|
| + }
|
| +
|
| + GURL url = entry->GetURL();
|
| + GURL virtual_url = entry->GetVirtualURL();
|
| + if (url.SchemeIs(content::kChromeUIScheme) ||
|
| + virtual_url.SchemeIs(content::kChromeUIScheme)) {
|
| + if (!url.SchemeIs(content::kChromeUIScheme))
|
| + url = virtual_url;
|
| + return url.host() != chrome::kChromeUINewTabHost;
|
| + }
|
| }
|
|
|
| - return l10n_util::GetStringFUTF16(
|
| - IDS_SECURE_CONNECTION_EV,
|
| - base::UTF8ToUTF16(cert.subject().organization_names[0]),
|
| - base::UTF8ToUTF16(cert.subject().country_name));
|
| + if (chrome::IsInstantNTP(delegate_->GetActiveWebContents()))
|
| + return false;
|
| +
|
| + return true;
|
| +}
|
| +
|
| +bool ToolbarModelImpl::WouldOmitURLDueToOriginChip() const {
|
| + const char kInterstitialShownKey[] = "interstitial_shown";
|
| +
|
| + // When users type URLs and hit enter, continue to show those URLs until
|
| + // the navigation commits or an interstitial is shown, because having the
|
| + // omnibox clear immediately feels like the input was ignored.
|
| + NavigationController* navigation_controller = GetNavigationController();
|
| + if (navigation_controller) {
|
| + NavigationEntry* pending_entry = navigation_controller->GetPendingEntry();
|
| + if (pending_entry) {
|
| + const NavigationEntry* visible_entry =
|
| + navigation_controller->GetVisibleEntry();
|
| + base::string16 unused;
|
| + // Keep track that we've shown the origin chip on an interstitial so it
|
| + // can be shown even after the interstitial was dismissed, to avoid
|
| + // showing the chip, removing it and then showing it again.
|
| + if (visible_entry &&
|
| + visible_entry->GetPageType() == content::PAGE_TYPE_INTERSTITIAL &&
|
| + !pending_entry->GetExtraData(kInterstitialShownKey, &unused))
|
| + pending_entry->SetExtraData(kInterstitialShownKey, base::string16());
|
| + const content::PageTransition transition_type =
|
| + pending_entry->GetTransitionType();
|
| + if ((transition_type & content::PAGE_TRANSITION_TYPED) != 0 &&
|
| + !pending_entry->GetExtraData(kInterstitialShownKey, &unused))
|
| + return false;
|
| + }
|
| + }
|
| +
|
| + bool should_display_origin_chip =
|
| + chrome::ShouldDisplayOriginChip() || chrome::ShouldDisplayOriginChipV2();
|
| + return should_display_origin_chip && delegate_->InTabbedBrowser() &&
|
| + ShouldDisplayURL() && url_replacement_enabled();
|
| }
|
|
|
| NavigationController* ToolbarModelImpl::GetNavigationController() const {
|
|
|