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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> |
8 | 9 |
9 #include "base/logging.h" | 10 #include "base/logging.h" |
10 #include "chrome/browser/ui/omnibox/alternate_nav_infobar_delegate.h" | 11 #include "chrome/browser/ui/omnibox/alternate_nav_infobar_delegate.h" |
11 #include "ui/base/window_open_disposition.h" | 12 #include "ui/base/window_open_disposition.h" |
12 #include "ui/gfx/text_elider.h" | 13 #include "ui/gfx/text_elider.h" |
13 #include "ui/views/controls/label.h" | 14 #include "ui/views/controls/label.h" |
14 #include "ui/views/controls/link.h" | 15 #include "ui/views/controls/link.h" |
15 | 16 |
16 | 17 |
17 // AlternateNavInfoBarDelegate ------------------------------------------------- | 18 // AlternateNavInfoBarDelegate ------------------------------------------------- |
18 | 19 |
19 // static | 20 // static |
20 scoped_ptr<infobars::InfoBar> AlternateNavInfoBarDelegate::CreateInfoBar( | 21 scoped_ptr<infobars::InfoBar> AlternateNavInfoBarDelegate::CreateInfoBar( |
21 scoped_ptr<AlternateNavInfoBarDelegate> delegate) { | 22 scoped_ptr<AlternateNavInfoBarDelegate> delegate) { |
22 return make_scoped_ptr(new AlternateNavInfoBarView(delegate.Pass())); | 23 return make_scoped_ptr(new AlternateNavInfoBarView(std::move(delegate))); |
23 } | 24 } |
24 | 25 |
25 | 26 |
26 // AlternateNavInfoBarView ----------------------------------------------------- | 27 // AlternateNavInfoBarView ----------------------------------------------------- |
27 | 28 |
28 AlternateNavInfoBarView::AlternateNavInfoBarView( | 29 AlternateNavInfoBarView::AlternateNavInfoBarView( |
29 scoped_ptr<AlternateNavInfoBarDelegate> delegate) | 30 scoped_ptr<AlternateNavInfoBarDelegate> delegate) |
30 : InfoBarView(delegate.Pass()), | 31 : InfoBarView(std::move(delegate)), |
31 label_1_(NULL), | 32 label_1_(NULL), |
32 link_(NULL), | 33 link_(NULL), |
33 label_2_(NULL) { | 34 label_2_(NULL) {} |
34 } | |
35 | 35 |
36 AlternateNavInfoBarView::~AlternateNavInfoBarView() { | 36 AlternateNavInfoBarView::~AlternateNavInfoBarView() { |
37 } | 37 } |
38 | 38 |
39 // static | 39 // static |
40 void AlternateNavInfoBarView::ElideLabels(Labels* labels, int available_width) { | 40 void AlternateNavInfoBarView::ElideLabels(Labels* labels, int available_width) { |
41 views::Label* last_label = labels->back(); | 41 views::Label* last_label = labels->back(); |
42 labels->pop_back(); | 42 labels->pop_back(); |
43 int used_width = 0; | 43 int used_width = 0; |
44 for (Labels::iterator i(labels->begin()); i != labels->end(); ++i) | 44 for (Labels::iterator i(labels->begin()); i != labels->end(); ++i) |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 return; // We're closing; don't call anything, it might access the owner. | 108 return; // We're closing; don't call anything, it might access the owner. |
109 DCHECK(link_ != NULL); | 109 DCHECK(link_ != NULL); |
110 DCHECK_EQ(link_, source); | 110 DCHECK_EQ(link_, source); |
111 if (GetDelegate()->LinkClicked(ui::DispositionFromEventFlags(event_flags))) | 111 if (GetDelegate()->LinkClicked(ui::DispositionFromEventFlags(event_flags))) |
112 RemoveSelf(); | 112 RemoveSelf(); |
113 } | 113 } |
114 | 114 |
115 AlternateNavInfoBarDelegate* AlternateNavInfoBarView::GetDelegate() { | 115 AlternateNavInfoBarDelegate* AlternateNavInfoBarView::GetDelegate() { |
116 return static_cast<AlternateNavInfoBarDelegate*>(delegate()); | 116 return static_cast<AlternateNavInfoBarDelegate*>(delegate()); |
117 } | 117 } |
OLD | NEW |