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/alternate_nav_infobar_view.h" | 5 #include "chrome/browser/ui/views/infobars/alternate_nav_infobar_view.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "chrome/browser/ui/omnibox/alternate_nav_infobar_delegate.h" | 8 #include "chrome/browser/ui/omnibox/alternate_nav_infobar_delegate.h" |
9 #include "ui/base/window_open_disposition.h" | 9 #include "ui/base/window_open_disposition.h" |
10 #include "ui/gfx/text_elider.h" | 10 #include "ui/gfx/text_elider.h" |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 label_2_text_ = message_text.substr(offset); | 88 label_2_text_ = message_text.substr(offset); |
89 label_2_ = CreateLabel(label_2_text_); | 89 label_2_ = CreateLabel(label_2_text_); |
90 AddChildView(label_2_); | 90 AddChildView(label_2_); |
91 } | 91 } |
92 | 92 |
93 // This must happen after adding all other children so InfoBarView can ensure | 93 // This must happen after adding all other children so InfoBarView can ensure |
94 // the close button is the last child. | 94 // the close button is the last child. |
95 InfoBarView::ViewHierarchyChanged(details); | 95 InfoBarView::ViewHierarchyChanged(details); |
96 } | 96 } |
97 | 97 |
98 int AlternateNavInfoBarView::ContentMinimumWidth() { | 98 int AlternateNavInfoBarView::ContentMinimumWidth() const { |
99 int label_1_width = label_1_->GetMinimumSize().width(); | 99 int label_1_width = label_1_->GetMinimumSize().width(); |
100 return label_1_width ? label_1_width : link_->GetMinimumSize().width(); | 100 return label_1_width ? label_1_width : link_->GetMinimumSize().width(); |
101 } | 101 } |
102 | 102 |
103 void AlternateNavInfoBarView::LinkClicked(views::Link* source, | 103 void AlternateNavInfoBarView::LinkClicked(views::Link* source, |
104 int event_flags) { | 104 int event_flags) { |
105 if (!owner()) | 105 if (!owner()) |
106 return; // We're closing; don't call anything, it might access the owner. | 106 return; // We're closing; don't call anything, it might access the owner. |
107 DCHECK(link_ != NULL); | 107 DCHECK(link_ != NULL); |
108 DCHECK_EQ(link_, source); | 108 DCHECK_EQ(link_, source); |
109 if (GetDelegate()->LinkClicked(ui::DispositionFromEventFlags(event_flags))) | 109 if (GetDelegate()->LinkClicked(ui::DispositionFromEventFlags(event_flags))) |
110 RemoveSelf(); | 110 RemoveSelf(); |
111 } | 111 } |
112 | 112 |
113 AlternateNavInfoBarDelegate* AlternateNavInfoBarView::GetDelegate() { | 113 AlternateNavInfoBarDelegate* AlternateNavInfoBarView::GetDelegate() { |
114 return static_cast<AlternateNavInfoBarDelegate*>(delegate()); | 114 return static_cast<AlternateNavInfoBarDelegate*>(delegate()); |
115 } | 115 } |
OLD | NEW |