Chromium Code Reviews| 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..9057688b12d09500cbd047d2f8218718dc4b97de 100644 |
| --- a/chrome/browser/ui/toolbar/toolbar_model_impl.cc |
| +++ b/chrome/browser/ui/toolbar/toolbar_model_impl.cc |
| @@ -154,40 +154,6 @@ 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(); |
| @@ -225,6 +191,46 @@ bool ToolbarModelImpl::ShouldDisplayURL() const { |
| return true; |
| } |
| +bool ToolbarModelImpl::WouldOmitURLDueToOriginChip() const { |
|
Peter Kasting
2014/05/05 22:39:04
Please move both ShouldDisplayURL() and this funct
macourteau
2014/05/08 21:35:55
Done.
|
| + 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::ShouldShowOriginChip() const { |
| + return (chrome::ShouldDisplayOriginChipV2() && |
|
Peter Kasting
2014/05/05 22:39:04
Nit: No ()
macourteau
2014/05/08 21:35:55
Done.
|
| + WouldOmitURLDueToOriginChip() && |
| + origin_chip_enabled()); |
| +} |
| + |
| ToolbarModel::SecurityLevel ToolbarModelImpl::GetSecurityLevel( |
| bool ignore_editing) const { |
| // When editing, assume no security style. |