| 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 "build/build_config.h" |
| 8 #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h" | 9 #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/search/search.h" | 11 #include "chrome/browser/search/search.h" |
| 11 #include "chrome/browser/ssl/security_state_tab_helper.h" | 12 #include "chrome/browser/ssl/security_state_tab_helper.h" |
| 12 #include "chrome/common/pref_names.h" | 13 #include "chrome/common/pref_names.h" |
| 13 #include "chrome/common/url_constants.h" | 14 #include "chrome/common/url_constants.h" |
| 14 #include "components/google/core/browser/google_util.h" | 15 #include "components/google/core/browser/google_util.h" |
| 15 #include "components/omnibox/browser/autocomplete_input.h" | 16 #include "components/omnibox/browser/autocomplete_input.h" |
| 16 #include "components/prefs/pref_service.h" | 17 #include "components/prefs/pref_service.h" |
| 17 #include "components/security_state/core/security_state.h" | 18 #include "components/security_state/core/security_state.h" |
| 18 #include "content/public/browser/navigation_controller.h" | 19 #include "content/public/browser/navigation_controller.h" |
| 19 #include "content/public/browser/navigation_entry.h" | 20 #include "content/public/browser/navigation_entry.h" |
| 20 #include "content/public/browser/ssl_status.h" | 21 #include "content/public/browser/ssl_status.h" |
| 21 #include "content/public/browser/web_contents.h" | 22 #include "content/public/browser/web_contents.h" |
| 22 #include "content/public/common/url_constants.h" | 23 #include "content/public/common/url_constants.h" |
| 23 #include "extensions/common/constants.h" | 24 #include "extensions/common/constants.h" |
| 24 | 25 |
| 25 #if !defined(OS_ANDROID) | 26 #if defined(OS_ANDROID) |
| 27 #include "chrome/browser/android/offline_pages/offline_page_utils.h" |
| 28 #else |
| 26 #include "components/omnibox/browser/vector_icons.h" // nogncheck | 29 #include "components/omnibox/browser/vector_icons.h" // nogncheck |
| 27 #include "components/toolbar/vector_icons.h" // nogncheck | 30 #include "components/toolbar/vector_icons.h" // nogncheck |
| 28 #endif | 31 #endif |
| 29 | 32 |
| 30 ChromeToolbarModelDelegate::ChromeToolbarModelDelegate() {} | 33 ChromeToolbarModelDelegate::ChromeToolbarModelDelegate() {} |
| 31 | 34 |
| 32 ChromeToolbarModelDelegate::~ChromeToolbarModelDelegate() {} | 35 ChromeToolbarModelDelegate::~ChromeToolbarModelDelegate() {} |
| 33 | 36 |
| 34 base::string16 ChromeToolbarModelDelegate::FormattedStringWithEquivalentMeaning( | 37 base::string16 ChromeToolbarModelDelegate::FormattedStringWithEquivalentMeaning( |
| 35 const GURL& url, | 38 const GURL& url, |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 if (url.SchemeIs(content::kChromeUIScheme)) | 122 if (url.SchemeIs(content::kChromeUIScheme)) |
| 120 return &toolbar::kProductIcon; | 123 return &toolbar::kProductIcon; |
| 121 | 124 |
| 122 if (url.SchemeIs(extensions::kExtensionScheme)) | 125 if (url.SchemeIs(extensions::kExtensionScheme)) |
| 123 return &omnibox::kExtensionAppIcon; | 126 return &omnibox::kExtensionAppIcon; |
| 124 #endif | 127 #endif |
| 125 | 128 |
| 126 return nullptr; | 129 return nullptr; |
| 127 } | 130 } |
| 128 | 131 |
| 132 bool ChromeToolbarModelDelegate::IsOfflinePage() const { |
| 133 #if defined(OS_ANDROID) |
| 134 content::WebContents* web_contents = GetActiveWebContents(); |
| 135 return web_contents && |
| 136 offline_pages::OfflinePageUtils::GetOfflinePageFromWebContents( |
| 137 web_contents); |
| 138 #else |
| 139 return false; |
| 140 #endif |
| 141 } |
| 142 |
| 129 content::NavigationController* | 143 content::NavigationController* |
| 130 ChromeToolbarModelDelegate::GetNavigationController() const { | 144 ChromeToolbarModelDelegate::GetNavigationController() const { |
| 131 // This |current_tab| can be null during the initialization of the toolbar | 145 // This |current_tab| can be null during the initialization of the toolbar |
| 132 // during window creation (i.e. before any tabs have been added to the | 146 // during window creation (i.e. before any tabs have been added to the |
| 133 // window). | 147 // window). |
| 134 content::WebContents* current_tab = GetActiveWebContents(); | 148 content::WebContents* current_tab = GetActiveWebContents(); |
| 135 return current_tab ? ¤t_tab->GetController() : nullptr; | 149 return current_tab ? ¤t_tab->GetController() : nullptr; |
| 136 } | 150 } |
| 137 | 151 |
| 138 content::NavigationEntry* ChromeToolbarModelDelegate::GetNavigationEntry() | 152 content::NavigationEntry* ChromeToolbarModelDelegate::GetNavigationEntry() |
| 139 const { | 153 const { |
| 140 content::NavigationController* controller = GetNavigationController(); | 154 content::NavigationController* controller = GetNavigationController(); |
| 141 return controller ? controller->GetVisibleEntry() : nullptr; | 155 return controller ? controller->GetVisibleEntry() : nullptr; |
| 142 } | 156 } |
| 143 | 157 |
| 144 Profile* ChromeToolbarModelDelegate::GetProfile() const { | 158 Profile* ChromeToolbarModelDelegate::GetProfile() const { |
| 145 content::NavigationController* controller = GetNavigationController(); | 159 content::NavigationController* controller = GetNavigationController(); |
| 146 return controller | 160 return controller |
| 147 ? Profile::FromBrowserContext(controller->GetBrowserContext()) | 161 ? Profile::FromBrowserContext(controller->GetBrowserContext()) |
| 148 : nullptr; | 162 : nullptr; |
| 149 } | 163 } |
| OLD | NEW |