OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/extensions/bookmark_app_bubble_view.h" | 5 #include "chrome/browser/ui/views/extensions/bookmark_app_bubble_view.h" |
6 | 6 |
7 #include "base/strings/string16.h" | 7 #include "base/strings/string16.h" |
8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "chrome/grit/generated_resources.h" | 10 #include "chrome/grit/generated_resources.h" |
11 #include "content/public/browser/web_contents.h" | 11 #include "content/public/browser/web_contents.h" |
12 #include "extensions/common/constants.h" | 12 #include "extensions/common/constants.h" |
| 13 #include "ui/accessibility/ax_view_state.h" |
13 #include "ui/base/l10n/l10n_util.h" | 14 #include "ui/base/l10n/l10n_util.h" |
14 #include "ui/base/resource/resource_bundle.h" | 15 #include "ui/base/resource/resource_bundle.h" |
15 #include "ui/events/keycodes/keyboard_codes.h" | 16 #include "ui/events/keycodes/keyboard_codes.h" |
16 #include "ui/gfx/geometry/safe_integer_conversions.h" | 17 #include "ui/gfx/geometry/safe_integer_conversions.h" |
17 #include "ui/gfx/image/image_skia.h" | 18 #include "ui/gfx/image/image_skia.h" |
18 #include "ui/gfx/image/image_skia_source.h" | 19 #include "ui/gfx/image/image_skia_source.h" |
19 #include "ui/views/controls/button/checkbox.h" | 20 #include "ui/views/controls/button/checkbox.h" |
20 #include "ui/views/controls/button/label_button.h" | 21 #include "ui/views/controls/button/label_button.h" |
21 #include "ui/views/controls/image_view.h" | 22 #include "ui/views/controls/image_view.h" |
22 #include "ui/views/controls/label.h" | 23 #include "ui/views/controls/label.h" |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 | 173 |
173 gfx::Size image_size(kIconSize, kIconSize); | 174 gfx::Size image_size(kIconSize, kIconSize); |
174 gfx::ImageSkia image(new WebAppInfoImageSource(kIconSize, web_app_info_), | 175 gfx::ImageSkia image(new WebAppInfoImageSource(kIconSize, web_app_info_), |
175 image_size); | 176 image_size); |
176 icon_image_view_->SetImageSize(image_size); | 177 icon_image_view_->SetImageSize(image_size); |
177 icon_image_view_->SetImage(image); | 178 icon_image_view_->SetImage(image); |
178 layout->AddView(icon_image_view_); | 179 layout->AddView(icon_image_view_); |
179 | 180 |
180 title_tf_ = new views::Textfield(); | 181 title_tf_ = new views::Textfield(); |
181 title_tf_->SetText(web_app_info_.title); | 182 title_tf_->SetText(web_app_info_.title); |
| 183 title_tf_->SetAccessibleName(l10n_util::GetStringUTF16( |
| 184 IDS_BOOKMARK_APP_AX_BUBBLE_NAME_LABEL)); |
182 title_tf_->set_controller(this); | 185 title_tf_->set_controller(this); |
183 layout->AddView(title_tf_); | 186 layout->AddView(title_tf_); |
184 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 187 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
185 | 188 |
186 layout->StartRow(0, CONTENT_COLUMN_SET_ID); | 189 layout->StartRow(0, CONTENT_COLUMN_SET_ID); |
187 open_as_window_checkbox_ = new views::Checkbox( | 190 open_as_window_checkbox_ = new views::Checkbox( |
188 l10n_util::GetStringUTF16(IDS_BOOKMARK_APP_BUBBLE_OPEN_AS_WINDOW)); | 191 l10n_util::GetStringUTF16(IDS_BOOKMARK_APP_BUBBLE_OPEN_AS_WINDOW)); |
189 open_as_window_checkbox_->SetChecked(web_app_info_.open_as_window); | 192 open_as_window_checkbox_->SetChecked(web_app_info_.open_as_window); |
190 layout->AddView(open_as_window_checkbox_); | 193 layout->AddView(open_as_window_checkbox_); |
191 layout->AddView(add_button_); | 194 layout->AddView(add_button_); |
(...skipping 14 matching lines...) Expand all Loading... |
206 | 209 |
207 bool BookmarkAppBubbleView::AcceleratorPressed( | 210 bool BookmarkAppBubbleView::AcceleratorPressed( |
208 const ui::Accelerator& accelerator) { | 211 const ui::Accelerator& accelerator) { |
209 if (accelerator.key_code() == ui::VKEY_RETURN) { | 212 if (accelerator.key_code() == ui::VKEY_RETURN) { |
210 HandleButtonPressed(add_button_); | 213 HandleButtonPressed(add_button_); |
211 } | 214 } |
212 | 215 |
213 return BubbleDelegateView::AcceleratorPressed(accelerator); | 216 return BubbleDelegateView::AcceleratorPressed(accelerator); |
214 } | 217 } |
215 | 218 |
| 219 void BookmarkAppBubbleView::GetAccessibleState(ui::AXViewState* state) { |
| 220 views::BubbleDelegateView::GetAccessibleState(state); |
| 221 state->name = l10n_util::GetStringUTF16(IDS_BOOKMARK_APP_BUBBLE_TITLE); |
| 222 } |
| 223 |
216 gfx::Size BookmarkAppBubbleView::GetMinimumSize() const { | 224 gfx::Size BookmarkAppBubbleView::GetMinimumSize() const { |
217 gfx::Size size(views::BubbleDelegateView::GetPreferredSize()); | 225 gfx::Size size(views::BubbleDelegateView::GetPreferredSize()); |
218 size.SetToMax(gfx::Size(kMinBubbleWidth, 0)); | 226 size.SetToMax(gfx::Size(kMinBubbleWidth, 0)); |
219 return size; | 227 return size; |
220 } | 228 } |
221 | 229 |
222 void BookmarkAppBubbleView::ButtonPressed(views::Button* sender, | 230 void BookmarkAppBubbleView::ButtonPressed(views::Button* sender, |
223 const ui::Event& event) { | 231 const ui::Event& event) { |
224 HandleButtonPressed(sender); | 232 HandleButtonPressed(sender); |
225 } | 233 } |
(...skipping 17 matching lines...) Expand all Loading... |
243 | 251 |
244 void BookmarkAppBubbleView::UpdateAddButtonState() { | 252 void BookmarkAppBubbleView::UpdateAddButtonState() { |
245 add_button_->SetEnabled(!GetTrimmedTitle().empty()); | 253 add_button_->SetEnabled(!GetTrimmedTitle().empty()); |
246 } | 254 } |
247 | 255 |
248 base::string16 BookmarkAppBubbleView::GetTrimmedTitle() { | 256 base::string16 BookmarkAppBubbleView::GetTrimmedTitle() { |
249 base::string16 title(title_tf_->text()); | 257 base::string16 title(title_tf_->text()); |
250 base::TrimWhitespace(title, base::TRIM_ALL, &title); | 258 base::TrimWhitespace(title, base::TRIM_ALL, &title); |
251 return title; | 259 return title; |
252 } | 260 } |
OLD | NEW |