| 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/security_state_tab_helper.h" | |
| 8 #include "chrome/browser/ui/view_ids.h" | 7 #include "chrome/browser/ui/view_ids.h" |
| 9 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 8 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
| 10 #include "chrome/browser/ui/views/website_settings/website_settings_popup_view.h
" | 9 #include "chrome/browser/ui/views/website_settings/website_settings_popup_view.h
" |
| 11 #include "chrome/grit/generated_resources.h" | 10 #include "chrome/grit/generated_resources.h" |
| 12 #include "chrome/grit/theme_resources.h" | 11 #include "chrome/grit/theme_resources.h" |
| 13 #include "components/grit/components_scaled_resources.h" | 12 #include "components/grit/components_scaled_resources.h" |
| 14 #include "components/omnibox/browser/omnibox_edit_model.h" | 13 #include "components/omnibox/browser/omnibox_edit_model.h" |
| 15 #include "components/security_state/core/security_state.h" | |
| 16 #include "content/public/browser/navigation_controller.h" | |
| 17 #include "content/public/browser/navigation_entry.h" | |
| 18 #include "content/public/browser/web_contents.h" | 14 #include "content/public/browser/web_contents.h" |
| 19 #include "ui/base/l10n/l10n_util.h" | 15 #include "ui/base/l10n/l10n_util.h" |
| 20 #include "ui/views/controls/label.h" | 16 #include "ui/views/controls/label.h" |
| 21 | 17 |
| 22 using content::NavigationEntry; | |
| 23 using content::WebContents; | 18 using content::WebContents; |
| 24 | 19 |
| 25 LocationIconView::LocationIconView(const gfx::FontList& font_list, | 20 LocationIconView::LocationIconView(const gfx::FontList& font_list, |
| 26 LocationBarView* location_bar) | 21 LocationBarView* location_bar) |
| 27 : IconLabelBubbleView(font_list, true), | 22 : IconLabelBubbleView(font_list, true), |
| 28 suppress_mouse_released_action_(false), | 23 suppress_mouse_released_action_(false), |
| 29 location_bar_(location_bar), | 24 location_bar_(location_bar), |
| 30 animation_(this) { | 25 animation_(this) { |
| 31 set_id(VIEW_ID_LOCATION_ICON); | 26 set_id(VIEW_ID_LOCATION_ICON); |
| 32 | 27 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 } | 94 } |
| 100 | 95 |
| 101 SkColor LocationIconView::GetTextColor() const { | 96 SkColor LocationIconView::GetTextColor() const { |
| 102 return location_bar_->GetColor(LocationBarView::SECURITY_CHIP_TEXT); | 97 return location_bar_->GetColor(LocationBarView::SECURITY_CHIP_TEXT); |
| 103 } | 98 } |
| 104 | 99 |
| 105 bool LocationIconView::OnActivate(const ui::Event& event) { | 100 bool LocationIconView::OnActivate(const ui::Event& event) { |
| 106 WebContents* contents = location_bar_->GetWebContents(); | 101 WebContents* contents = location_bar_->GetWebContents(); |
| 107 if (!contents) | 102 if (!contents) |
| 108 return false; | 103 return false; |
| 109 | 104 location_bar_->delegate()->ShowWebsiteSettings(contents); |
| 110 // Important to use GetVisibleEntry to match what's showing in the omnibox. | |
| 111 NavigationEntry* entry = contents->GetController().GetVisibleEntry(); | |
| 112 // The visible entry can be nullptr in the case of window.open(""). | |
| 113 if (!entry) | |
| 114 return false; | |
| 115 | |
| 116 SecurityStateTabHelper* helper = | |
| 117 SecurityStateTabHelper::FromWebContents(contents); | |
| 118 DCHECK(helper); | |
| 119 security_state::SecurityInfo security_info; | |
| 120 helper->GetSecurityInfo(&security_info); | |
| 121 | |
| 122 location_bar_->delegate()->ShowWebsiteSettings( | |
| 123 contents, entry->GetVirtualURL(), security_info); | |
| 124 return true; | 105 return true; |
| 125 } | 106 } |
| 126 | 107 |
| 127 void LocationIconView::GetAccessibleNodeData(ui::AXNodeData* node_data) { | 108 void LocationIconView::GetAccessibleNodeData(ui::AXNodeData* node_data) { |
| 128 IconLabelBubbleView::GetAccessibleNodeData(node_data); | 109 IconLabelBubbleView::GetAccessibleNodeData(node_data); |
| 129 node_data->role = ui::AX_ROLE_POP_UP_BUTTON; | 110 node_data->role = ui::AX_ROLE_POP_UP_BUTTON; |
| 130 } | 111 } |
| 131 | 112 |
| 132 gfx::Size LocationIconView::GetMinimumSizeForLabelText( | 113 gfx::Size LocationIconView::GetMinimumSizeForLabelText( |
| 133 const base::string16& text) const { | 114 const base::string16& text) const { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 return size; | 152 return size; |
| 172 } | 153 } |
| 173 | 154 |
| 174 void LocationIconView::OnClickOrTap(const ui::LocatedEvent& event) { | 155 void LocationIconView::OnClickOrTap(const ui::LocatedEvent& event) { |
| 175 // Do not show page info if the user has been editing the location bar or the | 156 // Do not show page info if the user has been editing the location bar or the |
| 176 // location bar is at the NTP. | 157 // location bar is at the NTP. |
| 177 if (location_bar_->GetOmniboxView()->IsEditingOrEmpty()) | 158 if (location_bar_->GetOmniboxView()->IsEditingOrEmpty()) |
| 178 return; | 159 return; |
| 179 ProcessLocatedEvent(event); | 160 ProcessLocatedEvent(event); |
| 180 } | 161 } |
| OLD | NEW |