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/page_info_bubble_view.h" | 5 #include "chrome/browser/ui/views/page_info_bubble_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "chrome/browser/certificate_viewer.h" | 10 #include "chrome/browser/certificate_viewer.h" |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 // Calculate how much space the separators take up (with padding). | 140 // Calculate how much space the separators take up (with padding). |
141 views::Separator separator; | 141 views::Separator separator; |
142 gfx::Size separator_size = separator.GetPreferredSize(); | 142 gfx::Size separator_size = separator.GetPreferredSize(); |
143 gfx::Size separator_plus_padding(0, separator_size.height() + | 143 gfx::Size separator_plus_padding(0, separator_size.height() + |
144 kPaddingAboveSeparator + | 144 kPaddingAboveSeparator + |
145 kPaddingBelowSeparator); | 145 kPaddingBelowSeparator); |
146 return separator_plus_padding; | 146 return separator_plus_padding; |
147 } | 147 } |
148 | 148 |
149 double PageInfoBubbleView::GetResizeAnimationCurrentValue() { | 149 double PageInfoBubbleView::GetResizeAnimationCurrentValue() { |
150 #if defined(OS_CHROMEOS) | |
151 // We don't run the animation on Chrome OS; see explanation in | |
152 // OnPageInfoModelChanged(). | |
153 return 1.0; | |
154 #else | |
155 return resize_animation_.GetCurrentValue(); | 150 return resize_animation_.GetCurrentValue(); |
156 #endif | |
157 } | 151 } |
158 | 152 |
159 double PageInfoBubbleView::HeightAnimationValue() { | 153 double PageInfoBubbleView::HeightAnimationValue() { |
160 // We use the first half of the animation to get to fully expanded mode. | 154 // We use the first half of the animation to get to fully expanded mode. |
161 // Towards the end, we also animate the section into view, as determined | 155 // Towards the end, we also animate the section into view, as determined |
162 // by OpacityAnimationValue(). | 156 // by OpacityAnimationValue(). |
163 return std::min(1.0, 2.0 * GetResizeAnimationCurrentValue()); | 157 return std::min(1.0, 2.0 * GetResizeAnimationCurrentValue()); |
164 } | 158 } |
165 | 159 |
166 void PageInfoBubbleView::LayoutSections() { | 160 void PageInfoBubbleView::LayoutSections() { |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 size.set_height(target_height); | 263 size.set_height(target_height); |
270 return size; | 264 return size; |
271 } | 265 } |
272 | 266 |
273 void PageInfoBubbleView::OnPageInfoModelChanged() { | 267 void PageInfoBubbleView::OnPageInfoModelChanged() { |
274 // The start height must take into account that when we start animating, | 268 // The start height must take into account that when we start animating, |
275 // a separator plus padding is immediately added before the view is animated | 269 // a separator plus padding is immediately added before the view is animated |
276 // into existence. | 270 // into existence. |
277 animation_start_height_ = bounds().height() + GetSeparatorSize().height(); | 271 animation_start_height_ = bounds().height() + GetSeparatorSize().height(); |
278 LayoutSections(); | 272 LayoutSections(); |
279 #if defined(OS_CHROMEOS) | |
280 // Animating a window's size doesn't work well in X. Each resize request gets | |
281 // rerouted to the window manager, which forwards it on to the X server. | |
282 // That's okay, but to avoid jank (the window's pixmap will have garbage in it | |
283 // after being resized), compositing window managers also send | |
284 // _NET_WM_SYNC_REQUEST messages to clients before resizing to ask for notice | |
285 // after the window has been repainted at the new size. Chrome appears to | |
286 // fall behind in handling the repaints, and the sync request responses | |
287 // typically don't get sent back to the window manager until the animation is | |
288 // done, which results in the window being invisible until then: | |
289 // http://crosbug.com/14993. Trying to e.g. just animate the first-visit | |
290 // section's opacity has the same negative effect, so we avoid doing any | |
291 // animation. | |
292 // TODO(derat): Remove this once we're not using a toplevel X window for the | |
293 // bubble. | |
294 SizeToContents(); | |
295 #else | |
296 resize_animation_.SetSlideDuration(kPageInfoSlideDuration); | 273 resize_animation_.SetSlideDuration(kPageInfoSlideDuration); |
297 resize_animation_.Show(); | 274 resize_animation_.Show(); |
298 #endif | |
299 } | 275 } |
300 | 276 |
301 gfx::Rect PageInfoBubbleView::GetAnchorRect() { | 277 gfx::Rect PageInfoBubbleView::GetAnchorRect() { |
302 // Compensate for some built-in padding in the icon. | 278 // Compensate for some built-in padding in the icon. |
303 gfx::Rect anchor(BubbleDelegateView::GetAnchorRect()); | 279 gfx::Rect anchor(BubbleDelegateView::GetAnchorRect()); |
304 anchor.Inset(0, anchor_view() ? 5 : 0); | 280 anchor.Inset(0, anchor_view() ? 5 : 0); |
305 return anchor; | 281 return anchor; |
306 } | 282 } |
307 | 283 |
308 void PageInfoBubbleView::LinkClicked(views::Link* source, int event_flags) { | 284 void PageInfoBubbleView::LinkClicked(views::Link* source, int event_flags) { |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
477 const GURL& url, | 453 const GURL& url, |
478 const SSLStatus& ssl, | 454 const SSLStatus& ssl, |
479 bool show_history) { | 455 bool show_history) { |
480 PageInfoBubbleView* page_info_bubble = | 456 PageInfoBubbleView* page_info_bubble = |
481 new PageInfoBubbleView(anchor_view, profile, url, ssl, show_history); | 457 new PageInfoBubbleView(anchor_view, profile, url, ssl, show_history); |
482 views::BubbleDelegateView::CreateBubble(page_info_bubble); | 458 views::BubbleDelegateView::CreateBubble(page_info_bubble); |
483 page_info_bubble->Show(); | 459 page_info_bubble->Show(); |
484 } | 460 } |
485 | 461 |
486 } | 462 } |
OLD | NEW |