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/infobars/extension_infobar.h" | 5 #include "chrome/browser/ui/views/infobars/extension_infobar.h" |
6 | 6 |
7 #include "chrome/browser/extensions/extension_context_menu_model.h" | 7 #include "chrome/browser/extensions/extension_context_menu_model.h" |
8 #include "chrome/browser/extensions/extension_infobar_delegate.h" | 8 #include "chrome/browser/extensions/extension_infobar_delegate.h" |
9 #include "chrome/browser/extensions/extension_view_host.h" | 9 #include "chrome/browser/extensions/extension_view_host.h" |
10 #include "chrome/browser/platform_util.h" | 10 #include "chrome/browser/platform_util.h" |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 | 100 |
101 infobar_icon_->SetPosition(gfx::Point(StartX(), OffsetY(infobar_icon_))); | 101 infobar_icon_->SetPosition(gfx::Point(StartX(), OffsetY(infobar_icon_))); |
102 ExtensionViewViews* extension_view = GetExtensionView(); | 102 ExtensionViewViews* extension_view = GetExtensionView(); |
103 // TODO(pkasting): We'd like to simply set the extension view's desired height | 103 // TODO(pkasting): We'd like to simply set the extension view's desired height |
104 // at creation time and position using OffsetY() like for other infobar items, | 104 // at creation time and position using OffsetY() like for other infobar items, |
105 // but the NativeViewHost inside does not seem to be clipped by the ClipRect() | 105 // but the NativeViewHost inside does not seem to be clipped by the ClipRect() |
106 // call in InfoBarView::PaintChildren(), so we have to manually clamp the size | 106 // call in InfoBarView::PaintChildren(), so we have to manually clamp the size |
107 // here. | 107 // here. |
108 extension_view->SetSize( | 108 extension_view->SetSize( |
109 gfx::Size(std::max(0, EndX() - StartX() - NonExtensionViewWidth()), | 109 gfx::Size(std::max(0, EndX() - StartX() - NonExtensionViewWidth()), |
110 std::min(height() - kSeparatorLineHeight - arrow_height(), | 110 std::min(height() - gSeparatorLineHeight - arrow_height(), |
111 GetDelegate()->height()))); | 111 GetDelegate()->height()))); |
112 // We do SetPosition() separately after SetSize() so OffsetY() will work. | 112 // We do SetPosition() separately after SetSize() so OffsetY() will work. |
113 extension_view->SetPosition( | 113 extension_view->SetPosition( |
114 gfx::Point(infobar_icon_->bounds().right() + kIconHorizontalMargin, | 114 gfx::Point(infobar_icon_->bounds().right() + kIconHorizontalMargin, |
115 std::max(arrow_height(), OffsetY(extension_view)))); | 115 std::max(arrow_height(), OffsetY(extension_view)))); |
116 } | 116 } |
117 | 117 |
118 void ExtensionInfoBar::ViewHierarchyChanged( | 118 void ExtensionInfoBar::ViewHierarchyChanged( |
119 const ViewHierarchyChangedDetails& details) { | 119 const ViewHierarchyChangedDetails& details) { |
120 if (!details.is_add || (details.child != this) || (infobar_icon_ != NULL)) { | 120 if (!details.is_add || (details.child != this) || (infobar_icon_ != NULL)) { |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 } | 226 } |
227 | 227 |
228 ExtensionViewViews* ExtensionInfoBar::GetExtensionView() { | 228 ExtensionViewViews* ExtensionInfoBar::GetExtensionView() { |
229 return static_cast<ExtensionViewViews*>( | 229 return static_cast<ExtensionViewViews*>( |
230 GetDelegate()->extension_view_host()->view()); | 230 GetDelegate()->extension_view_host()->view()); |
231 } | 231 } |
232 | 232 |
233 int ExtensionInfoBar::NonExtensionViewWidth() const { | 233 int ExtensionInfoBar::NonExtensionViewWidth() const { |
234 return infobar_icon_->width() + kIconHorizontalMargin; | 234 return infobar_icon_->width() + kIconHorizontalMargin; |
235 } | 235 } |
OLD | NEW |