| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/toolbar_model.h" | 5 #include "chrome/browser/ui/toolbar/toolbar_model.h" |
| 6 | 6 |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "chrome/browser/autocomplete/autocomplete.h" | 8 #include "chrome/browser/autocomplete/autocomplete.h" |
| 9 #include "chrome/browser/autocomplete/autocomplete_edit.h" | 9 #include "chrome/browser/autocomplete/autocomplete_edit.h" |
| 10 #include "chrome/browser/prefs/pref_service.h" | 10 #include "chrome/browser/prefs/pref_service.h" |
| 11 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
| 12 #include "chrome/browser/ssl/ssl_error_info.h" | 12 #include "chrome/browser/ssl/ssl_error_info.h" |
| 13 #include "chrome/browser/ui/toolbar/toolbar_model_delegate.h" | 13 #include "chrome/browser/ui/browser.h" |
| 14 #include "chrome/common/chrome_constants.h" | 14 #include "chrome/common/chrome_constants.h" |
| 15 #include "chrome/common/pref_names.h" | 15 #include "chrome/common/pref_names.h" |
| 16 #include "chrome/common/url_constants.h" | 16 #include "chrome/common/url_constants.h" |
| 17 #include "content/public/browser/cert_store.h" | 17 #include "content/public/browser/cert_store.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/web_contents.h" | 20 #include "content/public/browser/web_contents.h" |
| 21 #include "content/public/browser/web_ui.h" | 21 #include "content/public/browser/web_ui.h" |
| 22 #include "content/public/common/content_constants.h" | 22 #include "content/public/common/content_constants.h" |
| 23 #include "content/public/common/ssl_status.h" | 23 #include "content/public/common/ssl_status.h" |
| 24 #include "grit/generated_resources.h" | 24 #include "grit/generated_resources.h" |
| 25 #include "grit/theme_resources.h" | 25 #include "grit/theme_resources.h" |
| 26 #include "net/base/cert_status_flags.h" | 26 #include "net/base/cert_status_flags.h" |
| 27 #include "net/base/net_util.h" | 27 #include "net/base/net_util.h" |
| 28 #include "ui/base/l10n/l10n_util.h" | 28 #include "ui/base/l10n/l10n_util.h" |
| 29 | 29 |
| 30 using content::NavigationController; | 30 using content::NavigationController; |
| 31 using content::NavigationEntry; | 31 using content::NavigationEntry; |
| 32 using content::SSLStatus; | 32 using content::SSLStatus; |
| 33 using content::WebContents; | 33 using content::WebContents; |
| 34 | 34 |
| 35 ToolbarModel::ToolbarModel(ToolbarModelDelegate* delegate) | 35 ToolbarModel::ToolbarModel(Browser* browser) |
| 36 : delegate_(delegate), | 36 : browser_(browser), |
| 37 input_in_progress_(false) { | 37 input_in_progress_(false) { |
| 38 } | 38 } |
| 39 | 39 |
| 40 ToolbarModel::~ToolbarModel() { | 40 ToolbarModel::~ToolbarModel() { |
| 41 } | 41 } |
| 42 | 42 |
| 43 // ToolbarModel Implementation. | 43 // ToolbarModel Implementation. |
| 44 string16 ToolbarModel::GetText() const { | 44 string16 ToolbarModel::GetText() const { |
| 45 GURL url(chrome::kAboutBlankURL); | 45 GURL url(chrome::kAboutBlankURL); |
| 46 std::string languages; // Empty if we don't have a |navigation_controller|. | 46 std::string languages; // Empty if we don't have a |navigation_controller|. |
| (...skipping 30 matching lines...) Expand all Loading... |
| 77 // chrome://newtab's WebUI says. | 77 // chrome://newtab's WebUI says. |
| 78 NavigationController* controller = GetNavigationController(); | 78 NavigationController* controller = GetNavigationController(); |
| 79 NavigationEntry* entry = controller ? controller->GetVisibleEntry() : NULL; | 79 NavigationEntry* entry = controller ? controller->GetVisibleEntry() : NULL; |
| 80 if (entry) { | 80 if (entry) { |
| 81 if (entry->IsViewSourceMode() || | 81 if (entry->IsViewSourceMode() || |
| 82 entry->GetPageType() == content::PAGE_TYPE_INTERSTITIAL) { | 82 entry->GetPageType() == content::PAGE_TYPE_INTERSTITIAL) { |
| 83 return true; | 83 return true; |
| 84 } | 84 } |
| 85 } | 85 } |
| 86 | 86 |
| 87 WebContents* web_contents = delegate_->GetActiveWebContents(); | 87 WebContents* web_contents = browser_->GetSelectedWebContents(); |
| 88 if (web_contents && web_contents->GetWebUIForCurrentState()) | 88 if (web_contents && web_contents->GetWebUIForCurrentState()) |
| 89 return !web_contents->GetWebUIForCurrentState()->ShouldHideURL(); | 89 return !web_contents->GetWebUIForCurrentState()->ShouldHideURL(); |
| 90 | 90 |
| 91 if (entry && entry->GetURL().SchemeIs(chrome::kExtensionScheme)) | 91 if (entry && entry->GetURL().SchemeIs(chrome::kExtensionScheme)) |
| 92 return false; | 92 return false; |
| 93 | 93 |
| 94 return true; | 94 return true; |
| 95 } | 95 } |
| 96 | 96 |
| 97 ToolbarModel::SecurityLevel ToolbarModel::GetSecurityLevel() const { | 97 ToolbarModel::SecurityLevel ToolbarModel::GetSecurityLevel() const { |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 return l10n_util::GetStringFUTF16( | 167 return l10n_util::GetStringFUTF16( |
| 168 IDS_SECURE_CONNECTION_EV, | 168 IDS_SECURE_CONNECTION_EV, |
| 169 UTF8ToUTF16(cert.subject().organization_names[0]), | 169 UTF8ToUTF16(cert.subject().organization_names[0]), |
| 170 UTF8ToUTF16(cert.subject().country_name)); | 170 UTF8ToUTF16(cert.subject().country_name)); |
| 171 } | 171 } |
| 172 | 172 |
| 173 NavigationController* ToolbarModel::GetNavigationController() const { | 173 NavigationController* ToolbarModel::GetNavigationController() const { |
| 174 // This |current_tab| can be NULL during the initialization of the | 174 // This |current_tab| can be NULL during the initialization of the |
| 175 // toolbar during window creation (i.e. before any tabs have been added | 175 // toolbar during window creation (i.e. before any tabs have been added |
| 176 // to the window). | 176 // to the window). |
| 177 WebContents* current_tab = delegate_->GetActiveWebContents(); | 177 WebContents* current_tab = browser_->GetSelectedWebContents(); |
| 178 return current_tab ? ¤t_tab->GetController() : NULL; | 178 return current_tab ? ¤t_tab->GetController() : NULL; |
| 179 } | 179 } |
| OLD | NEW |