Chromium Code Reviews| 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 <iostream> | |
| 8 | |
| 7 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 8 #include "chrome/browser/ssl/chrome_security_state_model_client.h" | 10 #include "chrome/browser/ssl/chrome_security_state_model_client.h" |
| 9 #include "chrome/browser/ui/view_ids.h" | 11 #include "chrome/browser/ui/view_ids.h" |
| 10 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 12 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
| 11 #include "chrome/browser/ui/views/website_settings/website_settings_popup_view.h " | 13 #include "chrome/browser/ui/views/website_settings/website_settings_popup_view.h " |
| 12 #include "chrome/grit/generated_resources.h" | 14 #include "chrome/grit/generated_resources.h" |
| 13 #include "components/omnibox/browser/omnibox_edit_model.h" | 15 #include "components/omnibox/browser/omnibox_edit_model.h" |
| 14 #include "content/public/browser/navigation_controller.h" | 16 #include "content/public/browser/navigation_controller.h" |
| 15 #include "content/public/browser/navigation_entry.h" | 17 #include "content/public/browser/navigation_entry.h" |
| 16 #include "content/public/browser/web_contents.h" | 18 #include "content/public/browser/web_contents.h" |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 27 using content::WebContents; | 29 using content::WebContents; |
| 28 | 30 |
| 29 LocationIconView::LocationIconView(const gfx::FontList& font_list, | 31 LocationIconView::LocationIconView(const gfx::FontList& font_list, |
| 30 SkColor parent_background_color, | 32 SkColor parent_background_color, |
| 31 LocationBarView* location_bar) | 33 LocationBarView* location_bar) |
| 32 : IconLabelBubbleView(IDR_OMNIBOX_HTTPS_INVALID, | 34 : IconLabelBubbleView(IDR_OMNIBOX_HTTPS_INVALID, |
| 33 font_list, | 35 font_list, |
| 34 parent_background_color, | 36 parent_background_color, |
| 35 true), | 37 true), |
| 36 suppress_mouse_released_action_(false), | 38 suppress_mouse_released_action_(false), |
| 37 location_bar_(location_bar) { | 39 location_bar_(location_bar), |
| 40 animation_(this), | |
| 41 animation_already_started_(false) { | |
| 38 set_id(VIEW_ID_LOCATION_ICON); | 42 set_id(VIEW_ID_LOCATION_ICON); |
| 39 | 43 |
| 40 #if defined(OS_MACOSX) | 44 #if defined(OS_MACOSX) |
| 41 SetFocusBehavior(FocusBehavior::ACCESSIBLE_ONLY); | 45 SetFocusBehavior(FocusBehavior::ACCESSIBLE_ONLY); |
| 42 #else | 46 #else |
| 43 SetFocusBehavior(FocusBehavior::ALWAYS); | 47 SetFocusBehavior(FocusBehavior::ALWAYS); |
| 44 #endif | 48 #endif |
| 45 | 49 |
| 46 SetBackground(false); | 50 SetBackground(false); |
| 51 std::cout << "constructed " << (void*)this << "\n"; | |
| 47 } | 52 } |
| 48 | 53 |
| 49 LocationIconView::~LocationIconView() { | 54 LocationIconView::~LocationIconView() { |
| 55 std::cout << "destructed " << (void*)this << "\n"; | |
| 50 } | 56 } |
| 51 | 57 |
| 52 bool LocationIconView::OnMousePressed(const ui::MouseEvent& event) { | 58 bool LocationIconView::OnMousePressed(const ui::MouseEvent& event) { |
| 59 std::cout << "pressed " << (void*)this << "\n"; | |
| 53 if (event.IsOnlyMiddleMouseButton() && | 60 if (event.IsOnlyMiddleMouseButton() && |
| 54 ui::Clipboard::IsSupportedClipboardType(ui::CLIPBOARD_TYPE_SELECTION)) { | 61 ui::Clipboard::IsSupportedClipboardType(ui::CLIPBOARD_TYPE_SELECTION)) { |
| 55 base::string16 text; | 62 base::string16 text; |
| 56 ui::Clipboard::GetForCurrentThread()->ReadText( | 63 ui::Clipboard::GetForCurrentThread()->ReadText( |
| 57 ui::CLIPBOARD_TYPE_SELECTION, &text); | 64 ui::CLIPBOARD_TYPE_SELECTION, &text); |
| 58 text = OmniboxView::SanitizeTextForPaste(text); | 65 text = OmniboxView::SanitizeTextForPaste(text); |
| 59 OmniboxEditModel* model = location_bar_->GetOmniboxView()->model(); | 66 OmniboxEditModel* model = location_bar_->GetOmniboxView()->model(); |
| 60 if (model->CanPasteAndGo(text)) | 67 if (model->CanPasteAndGo(text)) |
| 61 model->PasteAndGo(text); | 68 model->PasteAndGo(text); |
| 62 } | 69 } |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 159 return size; | 166 return size; |
| 160 } | 167 } |
| 161 | 168 |
| 162 void LocationIconView::SetBackground(bool should_show_ev) { | 169 void LocationIconView::SetBackground(bool should_show_ev) { |
| 163 static const int kEvBackgroundImages[] = IMAGE_GRID(IDR_OMNIBOX_EV_BUBBLE); | 170 static const int kEvBackgroundImages[] = IMAGE_GRID(IDR_OMNIBOX_EV_BUBBLE); |
| 164 if (should_show_ev) | 171 if (should_show_ev) |
| 165 SetBackgroundImageGrid(kEvBackgroundImages); | 172 SetBackgroundImageGrid(kEvBackgroundImages); |
| 166 else | 173 else |
| 167 UnsetBackgroundImageGrid(); | 174 UnsetBackgroundImageGrid(); |
| 168 } | 175 } |
| 176 | |
| 177 void LocationIconView::StartAnimation() { | |
| 178 if (!animation_already_started_) { | |
| 179 std::cout << "width is " << label()->GetPreferredSize().width() << "\n"; | |
| 180 animation_.SetSlideDuration(label()->GetPreferredSize().width() * 10); | |
| 181 // They don't tell you but, to get it slide "down", you must do both: | |
|
Peter Kasting
2016/07/19 21:17:21
Who doesn't tell you? If you're trying to animate
Kevin Bailey
2016/08/12 18:49:15
slide_animation.h says:
// Begin a hiding anima
| |
| 182 animation_.Reset(1); | |
| 183 animation_.Hide(); | |
| 184 animation_already_started_ = true; | |
| 185 } | |
| 186 } | |
| 187 | |
| 188 void LocationIconView::AnimationProgressed(const gfx::Animation*) { | |
| 189 std::cout << "progressed " << animation_.GetCurrentValue() << "\n"; | |
| 190 // Since things are moving (sideways), we need a re-layout and paint. | |
| 191 location_bar_->Layout(); | |
| 192 location_bar_->SchedulePaint(); | |
| 193 } | |
| 194 | |
| 195 /* | |
| 196 int LocationIconView::GetLabelPreferredWidth() const { | |
| 197 gfx::Rect size(label()->GetPreferredSize()); | |
| 198 return size.width() * animation_.GetCurrentValue(); | |
| 199 } | |
| 200 */ | |
| 201 double LocationIconView::WidthMultiplier() const { | |
| 202 return animation_.GetCurrentValue(); | |
| 203 } | |
| 204 | |
| 205 bool LocationIconView::IsShrinking() const { | |
| 206 return true; | |
| 207 } | |
| OLD | NEW |