| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #include "chrome/browser/ui/toolbar/chrome_toolbar_model_delegate.h" | 5 #include "chrome/browser/ui/toolbar/chrome_toolbar_model_delegate.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h" | 8 #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/search/search.h" | 10 #include "chrome/browser/search/search.h" |
| 11 #include "chrome/browser/ssl/security_state_tab_helper.h" | 11 #include "chrome/browser/ssl/security_state_tab_helper.h" |
| 12 #include "chrome/common/pref_names.h" | 12 #include "chrome/common/pref_names.h" |
| 13 #include "chrome/common/url_constants.h" | 13 #include "chrome/common/url_constants.h" |
| 14 #include "components/google/core/browser/google_util.h" | 14 #include "components/google/core/browser/google_util.h" |
| 15 #include "components/omnibox/browser/autocomplete_input.h" | 15 #include "components/omnibox/browser/autocomplete_input.h" |
| 16 #include "components/prefs/pref_service.h" | 16 #include "components/prefs/pref_service.h" |
| 17 #include "components/security_state/core/security_state.h" | 17 #include "components/security_state/core/security_state.h" |
| 18 #include "content/public/browser/navigation_controller.h" | 18 #include "content/public/browser/navigation_controller.h" |
| 19 #include "content/public/browser/navigation_entry.h" | 19 #include "content/public/browser/navigation_entry.h" |
| 20 #include "content/public/browser/ssl_status.h" | 20 #include "content/public/browser/ssl_status.h" |
| 21 #include "content/public/browser/web_contents.h" | 21 #include "content/public/browser/web_contents.h" |
| 22 #include "content/public/common/url_constants.h" | 22 #include "content/public/common/url_constants.h" |
| 23 #include "extensions/common/constants.h" | 23 #include "extensions/common/constants.h" |
| 24 #include "ui/gfx/vector_icons_public.h" | 24 |
| 25 #if !defined(OS_ANDROID) |
| 26 #include "components/omnibox/browser/vector_icons.h" // nogncheck |
| 27 #include "components/toolbar/vector_icons.h" // nogncheck |
| 28 #endif |
| 25 | 29 |
| 26 ChromeToolbarModelDelegate::ChromeToolbarModelDelegate() {} | 30 ChromeToolbarModelDelegate::ChromeToolbarModelDelegate() {} |
| 27 | 31 |
| 28 ChromeToolbarModelDelegate::~ChromeToolbarModelDelegate() {} | 32 ChromeToolbarModelDelegate::~ChromeToolbarModelDelegate() {} |
| 29 | 33 |
| 30 base::string16 ChromeToolbarModelDelegate::FormattedStringWithEquivalentMeaning( | 34 base::string16 ChromeToolbarModelDelegate::FormattedStringWithEquivalentMeaning( |
| 31 const GURL& url, | 35 const GURL& url, |
| 32 const base::string16& formatted_url) const { | 36 const base::string16& formatted_url) const { |
| 33 return AutocompleteInput::FormattedStringWithEquivalentMeaning( | 37 return AutocompleteInput::FormattedStringWithEquivalentMeaning( |
| 34 url, formatted_url, ChromeAutocompleteSchemeClassifier(GetProfile())); | 38 url, formatted_url, ChromeAutocompleteSchemeClassifier(GetProfile())); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 // initialization), so nothing can fail. | 103 // initialization), so nothing can fail. |
| 100 if (!web_contents) | 104 if (!web_contents) |
| 101 return false; | 105 return false; |
| 102 security_state::SecurityInfo security_info; | 106 security_state::SecurityInfo security_info; |
| 103 SecurityStateTabHelper::FromWebContents(web_contents) | 107 SecurityStateTabHelper::FromWebContents(web_contents) |
| 104 ->GetSecurityInfo(&security_info); | 108 ->GetSecurityInfo(&security_info); |
| 105 return security_info.malicious_content_status != | 109 return security_info.malicious_content_status != |
| 106 security_state::MALICIOUS_CONTENT_STATUS_NONE; | 110 security_state::MALICIOUS_CONTENT_STATUS_NONE; |
| 107 } | 111 } |
| 108 | 112 |
| 109 gfx::VectorIconId ChromeToolbarModelDelegate::GetVectorIconOverride() const { | 113 const gfx::VectorIcon* ChromeToolbarModelDelegate::GetVectorIconOverride() |
| 114 const { |
| 110 #if !defined(OS_ANDROID) | 115 #if !defined(OS_ANDROID) |
| 111 GURL url; | 116 GURL url; |
| 112 GetURL(&url); | 117 GetURL(&url); |
| 113 | 118 |
| 114 if (url.SchemeIs(content::kChromeUIScheme)) | 119 if (url.SchemeIs(content::kChromeUIScheme)) |
| 115 return gfx::VectorIconId::LOCATION_BAR_PRODUCT; | 120 return &toolbar::kProductIcon; |
| 116 | 121 |
| 117 if (url.SchemeIs(extensions::kExtensionScheme)) | 122 if (url.SchemeIs(extensions::kExtensionScheme)) |
| 118 return gfx::VectorIconId::OMNIBOX_EXTENSION_APP; | 123 return &omnibox::kExtensionAppIcon; |
| 119 #endif | 124 #endif |
| 120 | 125 |
| 121 return gfx::VectorIconId::VECTOR_ICON_NONE; | 126 return nullptr; |
| 122 } | 127 } |
| 123 | 128 |
| 124 content::NavigationController* | 129 content::NavigationController* |
| 125 ChromeToolbarModelDelegate::GetNavigationController() const { | 130 ChromeToolbarModelDelegate::GetNavigationController() const { |
| 126 // This |current_tab| can be null during the initialization of the toolbar | 131 // This |current_tab| can be null during the initialization of the toolbar |
| 127 // during window creation (i.e. before any tabs have been added to the | 132 // during window creation (i.e. before any tabs have been added to the |
| 128 // window). | 133 // window). |
| 129 content::WebContents* current_tab = GetActiveWebContents(); | 134 content::WebContents* current_tab = GetActiveWebContents(); |
| 130 return current_tab ? ¤t_tab->GetController() : nullptr; | 135 return current_tab ? ¤t_tab->GetController() : nullptr; |
| 131 } | 136 } |
| 132 | 137 |
| 133 content::NavigationEntry* ChromeToolbarModelDelegate::GetNavigationEntry() | 138 content::NavigationEntry* ChromeToolbarModelDelegate::GetNavigationEntry() |
| 134 const { | 139 const { |
| 135 content::NavigationController* controller = GetNavigationController(); | 140 content::NavigationController* controller = GetNavigationController(); |
| 136 return controller ? controller->GetVisibleEntry() : nullptr; | 141 return controller ? controller->GetVisibleEntry() : nullptr; |
| 137 } | 142 } |
| 138 | 143 |
| 139 Profile* ChromeToolbarModelDelegate::GetProfile() const { | 144 Profile* ChromeToolbarModelDelegate::GetProfile() const { |
| 140 content::NavigationController* controller = GetNavigationController(); | 145 content::NavigationController* controller = GetNavigationController(); |
| 141 return controller | 146 return controller |
| 142 ? Profile::FromBrowserContext(controller->GetBrowserContext()) | 147 ? Profile::FromBrowserContext(controller->GetBrowserContext()) |
| 143 : nullptr; | 148 : nullptr; |
| 144 } | 149 } |
| OLD | NEW |