Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(814)

Side by Side Diff: chrome/browser/ui/views/location_bar/location_icon_view.cc

Issue 2348853004: Remove non-md code in location bar (Views). (Closed)
Patch Set: resolve change collision Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "base/strings/utf_string_conversions.h"
8 #include "chrome/browser/ssl/chrome_security_state_model_client.h" 7 #include "chrome/browser/ssl/chrome_security_state_model_client.h"
9 #include "chrome/browser/ui/view_ids.h" 8 #include "chrome/browser/ui/view_ids.h"
10 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" 9 #include "chrome/browser/ui/views/location_bar/location_bar_view.h"
11 #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 "
12 #include "chrome/grit/generated_resources.h" 11 #include "chrome/grit/generated_resources.h"
13 #include "chrome/grit/theme_resources.h" 12 #include "chrome/grit/theme_resources.h"
14 #include "components/grit/components_scaled_resources.h" 13 #include "components/grit/components_scaled_resources.h"
15 #include "components/omnibox/browser/omnibox_edit_model.h" 14 #include "components/omnibox/browser/omnibox_edit_model.h"
16 #include "content/public/browser/navigation_controller.h" 15 #include "content/public/browser/navigation_controller.h"
17 #include "content/public/browser/navigation_entry.h" 16 #include "content/public/browser/navigation_entry.h"
18 #include "content/public/browser/web_contents.h" 17 #include "content/public/browser/web_contents.h"
19 #include "ui/base/l10n/l10n_util.h" 18 #include "ui/base/l10n/l10n_util.h"
20 #include "ui/base/material_design/material_design_controller.h"
21 #include "ui/gfx/color_palette.h"
22 #include "ui/views/controls/label.h" 19 #include "ui/views/controls/label.h"
23 #include "ui/views/painter.h"
24 20
25 using content::NavigationEntry; 21 using content::NavigationEntry;
26 using content::WebContents; 22 using content::WebContents;
27 23
28 LocationIconView::LocationIconView(const gfx::FontList& font_list, 24 LocationIconView::LocationIconView(const gfx::FontList& font_list,
29 SkColor parent_background_color,
30 LocationBarView* location_bar) 25 LocationBarView* location_bar)
31 : IconLabelBubbleView(IDR_OMNIBOX_HTTPS_INVALID, 26 : IconLabelBubbleView(font_list, true),
32 font_list,
33 parent_background_color,
34 true),
35 suppress_mouse_released_action_(false), 27 suppress_mouse_released_action_(false),
36 location_bar_(location_bar), 28 location_bar_(location_bar),
37 animation_(this) { 29 animation_(this) {
38 set_id(VIEW_ID_LOCATION_ICON); 30 set_id(VIEW_ID_LOCATION_ICON);
39 31
40 #if defined(OS_MACOSX) 32 #if defined(OS_MACOSX)
41 SetFocusBehavior(FocusBehavior::ACCESSIBLE_ONLY); 33 SetFocusBehavior(FocusBehavior::ACCESSIBLE_ONLY);
42 #else 34 #else
43 SetFocusBehavior(FocusBehavior::ALWAYS); 35 SetFocusBehavior(FocusBehavior::ALWAYS);
44 #endif 36 #endif
45 37
46 SetBackground(false);
47 animation_.SetSlideDuration(kOpenTimeMS); 38 animation_.SetSlideDuration(kOpenTimeMS);
48 } 39 }
49 40
50 LocationIconView::~LocationIconView() { 41 LocationIconView::~LocationIconView() {
51 } 42 }
52 43
53 gfx::Size LocationIconView::GetMinimumSize() const { 44 gfx::Size LocationIconView::GetMinimumSize() const {
54 return GetMinimumSizeForPreferredSize(GetPreferredSize()); 45 return GetMinimumSizeForPreferredSize(GetPreferredSize());
55 } 46 }
56 47
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 base::string16* tooltip) const { 92 base::string16* tooltip) const {
102 if (show_tooltip_) 93 if (show_tooltip_)
103 *tooltip = l10n_util::GetStringUTF16(IDS_TOOLTIP_LOCATION_ICON); 94 *tooltip = l10n_util::GetStringUTF16(IDS_TOOLTIP_LOCATION_ICON);
104 return show_tooltip_; 95 return show_tooltip_;
105 } 96 }
106 97
107 SkColor LocationIconView::GetTextColor() const { 98 SkColor LocationIconView::GetTextColor() const {
108 return location_bar_->GetColor(LocationBarView::SECURITY_CHIP_TEXT); 99 return location_bar_->GetColor(LocationBarView::SECURITY_CHIP_TEXT);
109 } 100 }
110 101
111 SkColor LocationIconView::GetBorderColor() const {
112 return GetTextColor();
113 }
114
115 bool LocationIconView::OnActivate(const ui::Event& event) { 102 bool LocationIconView::OnActivate(const ui::Event& event) {
116 WebContents* contents = location_bar_->GetWebContents(); 103 WebContents* contents = location_bar_->GetWebContents();
117 if (!contents) 104 if (!contents)
118 return false; 105 return false;
119 106
120 // Important to use GetVisibleEntry to match what's showing in the omnibox. 107 // Important to use GetVisibleEntry to match what's showing in the omnibox.
121 NavigationEntry* entry = contents->GetController().GetVisibleEntry(); 108 NavigationEntry* entry = contents->GetController().GetVisibleEntry();
122 // The visible entry can be nullptr in the case of window.open(""). 109 // The visible entry can be nullptr in the case of window.open("").
123 if (!entry) 110 if (!entry)
124 return false; 111 return false;
125 112
126 ChromeSecurityStateModelClient* model_client = 113 ChromeSecurityStateModelClient* model_client =
127 ChromeSecurityStateModelClient::FromWebContents(contents); 114 ChromeSecurityStateModelClient::FromWebContents(contents);
128 DCHECK(model_client); 115 DCHECK(model_client);
129 116
130 location_bar_->delegate()->ShowWebsiteSettings( 117 location_bar_->delegate()->ShowWebsiteSettings(
131 contents, entry->GetVirtualURL(), model_client->GetSecurityInfo()); 118 contents, entry->GetVirtualURL(), model_client->GetSecurityInfo());
132 return true; 119 return true;
133 } 120 }
134 121
135 gfx::Size LocationIconView::GetMinimumSizeForLabelText( 122 gfx::Size LocationIconView::GetMinimumSizeForLabelText(
136 const base::string16& text) const { 123 const base::string16& text) const {
137 views::Label label(text, font_list()); 124 views::Label label(text, font_list());
138 return GetMinimumSizeForPreferredSize( 125 return GetMinimumSizeForPreferredSize(
139 GetSizeForLabelWidth(label.GetPreferredSize().width())); 126 GetSizeForLabelWidth(label.GetPreferredSize().width()));
140 } 127 }
141 128
142 void LocationIconView::SetBackground(bool should_show_ev) {
143 static const int kEvBackgroundImages[] = IMAGE_GRID(IDR_OMNIBOX_EV_BUBBLE);
144 if (should_show_ev)
145 SetBackgroundImageGrid(kEvBackgroundImages);
146 else
147 UnsetBackgroundImageGrid();
148 }
149
150 void LocationIconView::SetSecurityState(bool should_show, bool should_animate) { 129 void LocationIconView::SetSecurityState(bool should_show, bool should_animate) {
151 if (!should_animate) { 130 if (!should_animate) {
152 animation_.Reset(should_show); 131 animation_.Reset(should_show);
153 } else if (should_show) { 132 } else if (should_show) {
154 animation_.Show(); 133 animation_.Show();
155 } else { 134 } else {
156 animation_.Hide(); 135 animation_.Hide();
157 } 136 }
137 // The label text color may have changed.
138 OnNativeThemeChanged(GetNativeTheme());
158 } 139 }
159 140
160 double LocationIconView::WidthMultiplier() const { 141 double LocationIconView::WidthMultiplier() const {
161 return animation_.GetCurrentValue(); 142 return animation_.GetCurrentValue();
162 } 143 }
163 144
164 void LocationIconView::AnimationProgressed(const gfx::Animation*) { 145 void LocationIconView::AnimationProgressed(const gfx::Animation*) {
165 location_bar_->Layout(); 146 location_bar_->Layout();
166 location_bar_->SchedulePaint(); 147 location_bar_->SchedulePaint();
167 } 148 }
(...skipping 11 matching lines...) Expand all
179 return size; 160 return size;
180 } 161 }
181 162
182 void LocationIconView::OnClickOrTap(const ui::LocatedEvent& event) { 163 void LocationIconView::OnClickOrTap(const ui::LocatedEvent& event) {
183 // Do not show page info if the user has been editing the location bar or the 164 // Do not show page info if the user has been editing the location bar or the
184 // location bar is at the NTP. 165 // location bar is at the NTP.
185 if (location_bar_->GetOmniboxView()->IsEditingOrEmpty()) 166 if (location_bar_->GetOmniboxView()->IsEditingOrEmpty())
186 return; 167 return;
187 ProcessLocatedEvent(event); 168 ProcessLocatedEvent(event);
188 } 169 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698