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

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

Issue 2144903004: New location security strings and animation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed unnecessary method, formatting Created 4 years, 4 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" 7 #include "base/strings/utf_string_conversions.h"
8 #include "chrome/browser/ssl/chrome_security_state_model_client.h" 8 #include "chrome/browser/ssl/chrome_security_state_model_client.h"
9 #include "chrome/browser/ui/view_ids.h" 9 #include "chrome/browser/ui/view_ids.h"
10 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" 10 #include "chrome/browser/ui/views/location_bar/location_bar_view.h"
11 #include "chrome/browser/ui/views/website_settings/website_settings_popup_view.h " 11 #include "chrome/browser/ui/views/website_settings/website_settings_popup_view.h "
12 #include "chrome/grit/generated_resources.h" 12 #include "chrome/grit/generated_resources.h"
13 #include "components/omnibox/browser/omnibox_edit_model.h" 13 #include "components/omnibox/browser/omnibox_edit_model.h"
14 #include "content/public/browser/navigation_controller.h" 14 #include "content/public/browser/navigation_controller.h"
15 #include "content/public/browser/navigation_entry.h" 15 #include "content/public/browser/navigation_entry.h"
16 #include "content/public/browser/web_contents.h" 16 #include "content/public/browser/web_contents.h"
17 #include "grit/components_scaled_resources.h" 17 #include "grit/components_scaled_resources.h"
18 #include "grit/theme_resources.h" 18 #include "grit/theme_resources.h"
19 #include "ui/base/l10n/l10n_util.h" 19 #include "ui/base/l10n/l10n_util.h"
20 #include "ui/base/material_design/material_design_controller.h" 20 #include "ui/base/material_design/material_design_controller.h"
21 #include "ui/gfx/color_palette.h" 21 #include "ui/gfx/color_palette.h"
22 #include "ui/views/controls/label.h" 22 #include "ui/views/controls/label.h"
23 #include "ui/views/painter.h" 23 #include "ui/views/painter.h"
24 24
25 using content::NavigationController;
26 using content::NavigationEntry; 25 using content::NavigationEntry;
27 using content::WebContents; 26 using content::WebContents;
28 27
29 LocationIconView::LocationIconView(const gfx::FontList& font_list, 28 LocationIconView::LocationIconView(const gfx::FontList& font_list,
30 SkColor parent_background_color, 29 SkColor parent_background_color,
31 LocationBarView* location_bar) 30 LocationBarView* location_bar)
32 : IconLabelBubbleView(IDR_OMNIBOX_HTTPS_INVALID, 31 : IconLabelBubbleView(IDR_OMNIBOX_HTTPS_INVALID,
33 font_list, 32 font_list,
34 parent_background_color, 33 parent_background_color,
35 true), 34 true),
36 suppress_mouse_released_action_(false), 35 suppress_mouse_released_action_(false),
37 location_bar_(location_bar) { 36 location_bar_(location_bar),
37 animation_(this) {
38 set_id(VIEW_ID_LOCATION_ICON); 38 set_id(VIEW_ID_LOCATION_ICON);
39 39
40 #if defined(OS_MACOSX) 40 #if defined(OS_MACOSX)
41 SetFocusBehavior(FocusBehavior::ACCESSIBLE_ONLY); 41 SetFocusBehavior(FocusBehavior::ACCESSIBLE_ONLY);
42 #else 42 #else
43 SetFocusBehavior(FocusBehavior::ALWAYS); 43 SetFocusBehavior(FocusBehavior::ALWAYS);
44 #endif 44 #endif
45 45
46 SetBackground(false); 46 SetBackground(false);
47 } 47 }
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 return size; 159 return size;
160 } 160 }
161 161
162 void LocationIconView::SetBackground(bool should_show_ev) { 162 void LocationIconView::SetBackground(bool should_show_ev) {
163 static const int kEvBackgroundImages[] = IMAGE_GRID(IDR_OMNIBOX_EV_BUBBLE); 163 static const int kEvBackgroundImages[] = IMAGE_GRID(IDR_OMNIBOX_EV_BUBBLE);
164 if (should_show_ev) 164 if (should_show_ev)
165 SetBackgroundImageGrid(kEvBackgroundImages); 165 SetBackgroundImageGrid(kEvBackgroundImages);
166 else 166 else
167 UnsetBackgroundImageGrid(); 167 UnsetBackgroundImageGrid();
168 } 168 }
169
170 void LocationIconView::StartAnimation() {
171 if (!(animation_.is_animating() || animation_.GetCurrentValue() == 1)) {
172 animation_.SetSlideDuration(label()->GetPreferredSize().width() * 10);
Peter Kasting 2016/08/15 23:29:50 This doesn't seem right. We should use the same t
Kevin Bailey 2016/08/16 16:39:36 Ok, was just copying other code (I think omnibox_r
Peter Kasting 2016/08/16 18:15:06 Yes, I thought about noting why I'm apparently req
173 animation_.Reset(0);
Peter Kasting 2016/08/15 23:29:50 Shouldn't reset to 0 here; we should animate from
Kevin Bailey 2016/08/16 16:39:37 I'll have to work on this with the rest of the app
Kevin Bailey 2016/08/17 16:33:30 Done, and I don't think we need the checks any mor
174 animation_.Show();
175 }
176 }
177
178 void LocationIconView::StopAnimation() {
179 if (animation_.is_animating() || animation_.GetCurrentValue() == 1)
Peter Kasting 2016/08/15 23:29:50 Why is this conditional needed?
Kevin Bailey 2016/08/16 16:39:36 This replaces 'animation_already_started_'. It is
Peter Kasting 2016/08/16 18:15:06 But if it's removed, the only effect will be that
Kevin Bailey 2016/08/17 16:33:30 Done.
180 animation_.Reset(0);
181 }
182
183 void LocationIconView::AnimationProgressed(const gfx::Animation*) {
184 // Since things are moving (sideways), we need a re-layout and paint.
Peter Kasting 2016/08/15 23:29:50 Nit: This comment is obvious, so I'd remove it.
Kevin Bailey 2016/08/16 16:39:37 Done.
185 location_bar_->Layout();
186 location_bar_->SchedulePaint();
187 }
188
189 double LocationIconView::WidthMultiplier() const {
190 return animation_.GetCurrentValue();
191 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698