| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 #include "chrome/browser/ui/views/location_bar/location_icon_view.h" | 5 #include "chrome/browser/ui/views/location_bar/location_icon_view.h" |
| 6 | 6 |
| 7 #include "chrome/browser/ssl/chrome_security_state_model_client.h" | 7 #include "chrome/browser/ssl/security_state_tab_helper.h" |
| 8 #include "chrome/browser/ui/view_ids.h" | 8 #include "chrome/browser/ui/view_ids.h" |
| 9 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 9 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
| 10 #include "chrome/browser/ui/views/website_settings/website_settings_popup_view.h
" | 10 #include "chrome/browser/ui/views/website_settings/website_settings_popup_view.h
" |
| 11 #include "chrome/grit/generated_resources.h" | 11 #include "chrome/grit/generated_resources.h" |
| 12 #include "chrome/grit/theme_resources.h" | 12 #include "chrome/grit/theme_resources.h" |
| 13 #include "components/grit/components_scaled_resources.h" | 13 #include "components/grit/components_scaled_resources.h" |
| 14 #include "components/omnibox/browser/omnibox_edit_model.h" | 14 #include "components/omnibox/browser/omnibox_edit_model.h" |
| 15 #include "components/security_state/core/security_state.h" |
| 15 #include "content/public/browser/navigation_controller.h" | 16 #include "content/public/browser/navigation_controller.h" |
| 16 #include "content/public/browser/navigation_entry.h" | 17 #include "content/public/browser/navigation_entry.h" |
| 17 #include "content/public/browser/web_contents.h" | 18 #include "content/public/browser/web_contents.h" |
| 18 #include "ui/base/l10n/l10n_util.h" | 19 #include "ui/base/l10n/l10n_util.h" |
| 19 #include "ui/views/controls/label.h" | 20 #include "ui/views/controls/label.h" |
| 20 | 21 |
| 21 using content::NavigationEntry; | 22 using content::NavigationEntry; |
| 22 using content::WebContents; | 23 using content::WebContents; |
| 23 | 24 |
| 24 LocationIconView::LocationIconView(const gfx::FontList& font_list, | 25 LocationIconView::LocationIconView(const gfx::FontList& font_list, |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 WebContents* contents = location_bar_->GetWebContents(); | 106 WebContents* contents = location_bar_->GetWebContents(); |
| 106 if (!contents) | 107 if (!contents) |
| 107 return false; | 108 return false; |
| 108 | 109 |
| 109 // Important to use GetVisibleEntry to match what's showing in the omnibox. | 110 // Important to use GetVisibleEntry to match what's showing in the omnibox. |
| 110 NavigationEntry* entry = contents->GetController().GetVisibleEntry(); | 111 NavigationEntry* entry = contents->GetController().GetVisibleEntry(); |
| 111 // The visible entry can be nullptr in the case of window.open(""). | 112 // The visible entry can be nullptr in the case of window.open(""). |
| 112 if (!entry) | 113 if (!entry) |
| 113 return false; | 114 return false; |
| 114 | 115 |
| 115 ChromeSecurityStateModelClient* model_client = | 116 SecurityStateTabHelper* helper = |
| 116 ChromeSecurityStateModelClient::FromWebContents(contents); | 117 SecurityStateTabHelper::FromWebContents(contents); |
| 117 DCHECK(model_client); | 118 DCHECK(helper); |
| 118 security_state::SecurityStateModel::SecurityInfo security_info; | 119 security_state::SecurityInfo security_info; |
| 119 model_client->GetSecurityInfo(&security_info); | 120 helper->GetSecurityInfo(&security_info); |
| 120 | 121 |
| 121 location_bar_->delegate()->ShowWebsiteSettings( | 122 location_bar_->delegate()->ShowWebsiteSettings( |
| 122 contents, entry->GetVirtualURL(), security_info); | 123 contents, entry->GetVirtualURL(), security_info); |
| 123 return true; | 124 return true; |
| 124 } | 125 } |
| 125 | 126 |
| 126 gfx::Size LocationIconView::GetMinimumSizeForLabelText( | 127 gfx::Size LocationIconView::GetMinimumSizeForLabelText( |
| 127 const base::string16& text) const { | 128 const base::string16& text) const { |
| 128 views::Label label(text, font_list()); | 129 views::Label label(text, font_list()); |
| 129 return GetMinimumSizeForPreferredSize( | 130 return GetMinimumSizeForPreferredSize( |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 return size; | 165 return size; |
| 165 } | 166 } |
| 166 | 167 |
| 167 void LocationIconView::OnClickOrTap(const ui::LocatedEvent& event) { | 168 void LocationIconView::OnClickOrTap(const ui::LocatedEvent& event) { |
| 168 // Do not show page info if the user has been editing the location bar or the | 169 // Do not show page info if the user has been editing the location bar or the |
| 169 // location bar is at the NTP. | 170 // location bar is at the NTP. |
| 170 if (location_bar_->GetOmniboxView()->IsEditingOrEmpty()) | 171 if (location_bar_->GetOmniboxView()->IsEditingOrEmpty()) |
| 171 return; | 172 return; |
| 172 ProcessLocatedEvent(event); | 173 ProcessLocatedEvent(event); |
| 173 } | 174 } |
| OLD | NEW |