Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 #import "ios/chrome/browser/ui/toolbar/toolbar_model_delegate_ios.h" | 5 #import "ios/chrome/browser/ui/toolbar/toolbar_model_delegate_ios.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "components/omnibox/browser/autocomplete_classifier.h" | 8 #include "components/omnibox/browser/autocomplete_classifier.h" |
| 9 #include "components/omnibox/browser/autocomplete_input.h" | 9 #include "components/omnibox/browser/autocomplete_input.h" |
| 10 #include "components/omnibox/browser/autocomplete_match.h" | 10 #include "components/omnibox/browser/autocomplete_match.h" |
| 11 #include "components/prefs/pref_service.h" | 11 #include "components/prefs/pref_service.h" |
| 12 #include "ios/chrome/browser/autocomplete/autocomplete_scheme_classifier_impl.h" | 12 #include "ios/chrome/browser/autocomplete/autocomplete_scheme_classifier_impl.h" |
| 13 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" | 13 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" |
| 14 #include "ios/chrome/browser/chrome_url_constants.h" | 14 #include "ios/chrome/browser/chrome_url_constants.h" |
| 15 #include "ios/chrome/browser/pref_names.h" | 15 #include "ios/chrome/browser/pref_names.h" |
| 16 #include "ios/chrome/browser/reading_list/offline_url_utils.h" | |
| 17 #include "ios/chrome/browser/ssl/ios_security_state_tab_helper.h" | 16 #include "ios/chrome/browser/ssl/ios_security_state_tab_helper.h" |
| 18 #import "ios/chrome/browser/tabs/tab.h" | 17 #import "ios/chrome/browser/tabs/tab.h" |
| 19 #import "ios/chrome/browser/tabs/tab_model.h" | 18 #import "ios/chrome/browser/tabs/tab_model.h" |
| 20 #import "ios/web/public/navigation_item.h" | 19 #import "ios/web/public/navigation_item.h" |
| 21 #import "ios/web/public/web_state/web_state.h" | 20 #import "ios/web/public/web_state/web_state.h" |
| 22 | 21 |
| 23 ToolbarModelDelegateIOS::ToolbarModelDelegateIOS(TabModel* tab_model) | 22 ToolbarModelDelegateIOS::ToolbarModelDelegateIOS(TabModel* tab_model) |
| 24 : tab_model_([tab_model retain]) {} | 23 : tab_model_([tab_model retain]) {} |
| 25 | 24 |
| 26 ToolbarModelDelegateIOS::~ToolbarModelDelegateIOS() {} | 25 ToolbarModelDelegateIOS::~ToolbarModelDelegateIOS() {} |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 46 const base::string16& formatted_url) const { | 45 const base::string16& formatted_url) const { |
| 47 return AutocompleteInput::FormattedStringWithEquivalentMeaning( | 46 return AutocompleteInput::FormattedStringWithEquivalentMeaning( |
| 48 url, formatted_url, AutocompleteSchemeClassifierImpl()); | 47 url, formatted_url, AutocompleteSchemeClassifierImpl()); |
| 49 } | 48 } |
| 50 | 49 |
| 51 bool ToolbarModelDelegateIOS::GetURL(GURL* url) const { | 50 bool ToolbarModelDelegateIOS::GetURL(GURL* url) const { |
| 52 DCHECK(url); | 51 DCHECK(url); |
| 53 web::NavigationItem* item = GetNavigationItem(); | 52 web::NavigationItem* item = GetNavigationItem(); |
| 54 if (!item) | 53 if (!item) |
| 55 return false; | 54 return false; |
| 56 | 55 *url = ShouldDisplayURL() ? item->GetVirtualURL() : GURL(); |
|
Eugene But (OOO till 7-30)
2016/12/28 17:02:59
I know that you just reverting to the old code, bu
Olivier
2016/12/29 12:37:20
Done.
| |
| 57 if (!ShouldDisplayURL()) { | |
| 58 *url = GURL(); | |
| 59 return true; | |
| 60 } | |
| 61 | |
| 62 // For security reasons, we shouldn't display the https scheme and secure | |
| 63 // padlock when there's no active ssl session. | |
| 64 // To hide the scheme we set it http when the loaded url is offline. | |
| 65 if (reading_list::IsOfflineURL(item->GetURL()) && | |
| 66 item->GetVirtualURL().SchemeIs(url::kHttpsScheme)) { | |
| 67 GURL::Replacements replacements; | |
| 68 replacements.SetScheme(url::kHttpScheme, | |
| 69 url::Component(0, strlen(url::kHttpScheme))); | |
| 70 *url = item->GetVirtualURL().ReplaceComponents(replacements); | |
| 71 return true; | |
| 72 } | |
| 73 | |
| 74 *url = item->GetVirtualURL(); | |
| 75 return true; | 56 return true; |
| 76 } | 57 } |
| 77 | 58 |
| 78 bool ToolbarModelDelegateIOS::ShouldDisplayURL() const { | 59 bool ToolbarModelDelegateIOS::ShouldDisplayURL() const { |
| 79 web::NavigationItem* item = GetNavigationItem(); | 60 web::NavigationItem* item = GetNavigationItem(); |
| 80 if (item) { | 61 if (item) { |
| 81 GURL url = item->GetURL(); | 62 GURL url = item->GetURL(); |
| 82 GURL virtual_url = item->GetVirtualURL(); | 63 GURL virtual_url = item->GetVirtualURL(); |
| 83 if (url.SchemeIs(kChromeUIScheme) || | 64 if (url.SchemeIs(kChromeUIScheme) || |
| 84 virtual_url.SchemeIs(kChromeUIScheme)) { | 65 virtual_url.SchemeIs(kChromeUIScheme)) { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 117 security_state::MALICIOUS_CONTENT_STATUS_NONE; | 98 security_state::MALICIOUS_CONTENT_STATUS_NONE; |
| 118 } | 99 } |
| 119 | 100 |
| 120 scoped_refptr<net::X509Certificate> ToolbarModelDelegateIOS::GetCertificate() | 101 scoped_refptr<net::X509Certificate> ToolbarModelDelegateIOS::GetCertificate() |
| 121 const { | 102 const { |
| 122 web::NavigationItem* item = GetNavigationItem(); | 103 web::NavigationItem* item = GetNavigationItem(); |
| 123 if (item) | 104 if (item) |
| 124 return item->GetSSL().certificate; | 105 return item->GetSSL().certificate; |
| 125 return scoped_refptr<net::X509Certificate>(); | 106 return scoped_refptr<net::X509Certificate>(); |
| 126 } | 107 } |
| OLD | NEW |