OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/toolbar/toolbar_actions_bar_bubble_views.h" | 5 #include "chrome/browser/ui/views/toolbar/toolbar_actions_bar_bubble_views.h" |
6 | 6 |
7 #include "chrome/browser/ui/views/harmony/chrome_layout_provider.h" | 7 #include "chrome/browser/ui/views/harmony/chrome_layout_provider.h" |
8 #include "chrome/grit/locale_settings.h" | 8 #include "chrome/grit/locale_settings.h" |
9 #include "ui/base/resource/resource_bundle.h" | 9 #include "ui/base/resource/resource_bundle.h" |
10 #include "ui/gfx/color_palette.h" | 10 #include "ui/gfx/color_palette.h" |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
94 ToolbarActionsBarBubbleDelegate::CLOSE_DISMISS_USER_ACTION); | 94 ToolbarActionsBarBubbleDelegate::CLOSE_DISMISS_USER_ACTION); |
95 return true; | 95 return true; |
96 } | 96 } |
97 | 97 |
98 bool ToolbarActionsBarBubbleViews::Accept() { | 98 bool ToolbarActionsBarBubbleViews::Accept() { |
99 delegate_->OnBubbleClosed(ToolbarActionsBarBubbleDelegate::CLOSE_EXECUTE); | 99 delegate_->OnBubbleClosed(ToolbarActionsBarBubbleDelegate::CLOSE_EXECUTE); |
100 return true; | 100 return true; |
101 } | 101 } |
102 | 102 |
103 bool ToolbarActionsBarBubbleViews::Close() { | 103 bool ToolbarActionsBarBubbleViews::Close() { |
104 delegate_->OnBubbleClosed(close_reason_); | 104 // When LinkClicked() calls OnBubbleClosed(), the Widget may close |
Devlin
2017/04/19 15:04:22
This sounds a bit off to me. Maybe "delegate_->On
tapted
2017/04/20 11:55:42
Done.
| |
105 // automatically in response to the delegate action (e.g. losing focus when | |
106 // a browser is raised). | |
Devlin
2017/04/19 15:04:22
browser is raised -> tab is opened?
tapted
2017/04/20 11:55:42
Done.
| |
107 if (close_reason_ != ToolbarActionsBarBubbleDelegate::CLOSE_LEARN_MORE) | |
Devlin
2017/04/19 15:04:22
close_reason_ is only set for LinkClicked(), which
tapted
2017/04/20 11:55:41
I went for a bool. Called it |delegate_notified_of
| |
108 delegate_->OnBubbleClosed(close_reason_); | |
105 return true; | 109 return true; |
106 } | 110 } |
107 | 111 |
108 void ToolbarActionsBarBubbleViews::Init() { | 112 void ToolbarActionsBarBubbleViews::Init() { |
109 ChromeLayoutProvider* provider = ChromeLayoutProvider::Get(); | 113 ChromeLayoutProvider* provider = ChromeLayoutProvider::Get(); |
110 SetLayoutManager(new views::BoxLayout( | 114 SetLayoutManager(new views::BoxLayout( |
111 views::BoxLayout::kVertical, 0, 0, | 115 views::BoxLayout::kVertical, 0, 0, |
112 provider->GetDistanceMetric(views::DISTANCE_RELATED_CONTROL_VERTICAL))); | 116 provider->GetDistanceMetric(views::DISTANCE_RELATED_CONTROL_VERTICAL))); |
113 | 117 |
114 // Add the content string. | 118 // Add the content string. |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
153 | 157 |
154 base::string16 ToolbarActionsBarBubbleViews::GetDialogButtonLabel( | 158 base::string16 ToolbarActionsBarBubbleViews::GetDialogButtonLabel( |
155 ui::DialogButton button) const { | 159 ui::DialogButton button) const { |
156 return button == ui::DIALOG_BUTTON_OK ? delegate_->GetActionButtonText() | 160 return button == ui::DIALOG_BUTTON_OK ? delegate_->GetActionButtonText() |
157 : delegate_->GetDismissButtonText(); | 161 : delegate_->GetDismissButtonText(); |
158 } | 162 } |
159 | 163 |
160 void ToolbarActionsBarBubbleViews::LinkClicked(views::Link* link, | 164 void ToolbarActionsBarBubbleViews::LinkClicked(views::Link* link, |
161 int event_flags) { | 165 int event_flags) { |
162 close_reason_ = ToolbarActionsBarBubbleDelegate::CLOSE_LEARN_MORE; | 166 close_reason_ = ToolbarActionsBarBubbleDelegate::CLOSE_LEARN_MORE; |
167 // Force the delegate action to happen here rather than in Close() so that | |
168 // Close() can distinguish between the codepaths. | |
Devlin
2017/04/19 15:04:22
I don't follow the "so that Close() can distinguis
tapted
2017/04/20 11:55:41
I think this captures it:
// Force the delegate
| |
169 delegate_->OnBubbleClosed(close_reason_); | |
170 // Note that the Widget may or may not already be closed at this point, | |
171 // depending on delegate_->ShouldCloseOnDeactivate(). Widget::Close() protects | |
172 // against multiple calls (so long as they are not nested), and Widget | |
173 // destruction is asynchronous, so it is safe to call Close() again. | |
163 GetWidget()->Close(); | 174 GetWidget()->Close(); |
164 } | 175 } |
OLD | NEW |