Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(647)

Side by Side Diff: chrome/browser/ui/views/desktop_media_picker_views.cc

Issue 1313843003: Enable keyboard navigation for Desktopcapture window selection dialog (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added a unit test function Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/desktop_media_picker_views.h" 5 #include "chrome/browser/ui/views/desktop_media_picker_views.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/browser/media/desktop_media_list.h" 10 #include "chrome/browser/media/desktop_media_list.h"
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 } 199 }
200 } 200 }
201 201
202 DesktopMediaListView::DesktopMediaListView( 202 DesktopMediaListView::DesktopMediaListView(
203 DesktopMediaPickerDialogView* parent, 203 DesktopMediaPickerDialogView* parent,
204 scoped_ptr<DesktopMediaList> media_list) 204 scoped_ptr<DesktopMediaList> media_list)
205 : parent_(parent), 205 : parent_(parent),
206 media_list_(media_list.Pass()), 206 media_list_(media_list.Pass()),
207 weak_factory_(this) { 207 weak_factory_(this) {
208 media_list_->SetThumbnailSize(gfx::Size(kThumbnailWidth, kThumbnailHeight)); 208 media_list_->SetThumbnailSize(gfx::Size(kThumbnailWidth, kThumbnailHeight));
209 SetFocusable(true);
209 } 210 }
210 211
211 DesktopMediaListView::~DesktopMediaListView() {} 212 DesktopMediaListView::~DesktopMediaListView() {}
212 213
213 void DesktopMediaListView::StartUpdating(DesktopMediaID dialog_window_id) { 214 void DesktopMediaListView::StartUpdating(DesktopMediaID dialog_window_id) {
214 media_list_->SetViewDialogWindowId(dialog_window_id); 215 media_list_->SetViewDialogWindowId(dialog_window_id);
215 media_list_->StartUpdating(this); 216 media_list_->StartUpdating(this);
216 } 217 }
217 218
218 void DesktopMediaListView::OnSelectionChanged() { 219 void DesktopMediaListView::OnSelectionChanged() {
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 return l10n_util::GetStringFUTF16(IDS_DESKTOP_MEDIA_PICKER_TITLE, app_name_); 489 return l10n_util::GetStringFUTF16(IDS_DESKTOP_MEDIA_PICKER_TITLE, app_name_);
489 } 490 }
490 491
491 bool DesktopMediaPickerDialogView::IsDialogButtonEnabled( 492 bool DesktopMediaPickerDialogView::IsDialogButtonEnabled(
492 ui::DialogButton button) const { 493 ui::DialogButton button) const {
493 if (button == ui::DIALOG_BUTTON_OK) 494 if (button == ui::DIALOG_BUTTON_OK)
494 return list_view_->GetSelection() != NULL; 495 return list_view_->GetSelection() != NULL;
495 return true; 496 return true;
496 } 497 }
497 498
499 views::View* DesktopMediaPickerDialogView::GetInitiallyFocusedView(){
500 return list_view_;
501 }
502
498 base::string16 DesktopMediaPickerDialogView::GetDialogButtonLabel( 503 base::string16 DesktopMediaPickerDialogView::GetDialogButtonLabel(
499 ui::DialogButton button) const { 504 ui::DialogButton button) const {
500 return l10n_util::GetStringUTF16(button == ui::DIALOG_BUTTON_OK ? 505 return l10n_util::GetStringUTF16(button == ui::DIALOG_BUTTON_OK ?
501 IDS_DESKTOP_MEDIA_PICKER_SHARE : IDS_CANCEL); 506 IDS_DESKTOP_MEDIA_PICKER_SHARE : IDS_CANCEL);
502 } 507 }
503 508
504 bool DesktopMediaPickerDialogView::Accept() { 509 bool DesktopMediaPickerDialogView::Accept() {
505 DesktopMediaSourceView* selection = list_view_->GetSelection(); 510 DesktopMediaSourceView* selection = list_view_->GetSelection();
506 511
507 // Ok button should only be enabled when a source is selected. 512 // Ok button should only be enabled when a source is selected.
(...skipping 28 matching lines...) Expand all
536 541
537 void DesktopMediaPickerDialogView::OnMediaListRowsChanged() { 542 void DesktopMediaPickerDialogView::OnMediaListRowsChanged() {
538 gfx::Rect widget_bound = GetWidget()->GetWindowBoundsInScreen(); 543 gfx::Rect widget_bound = GetWidget()->GetWindowBoundsInScreen();
539 544
540 int new_height = widget_bound.height() - scroll_view_->height() + 545 int new_height = widget_bound.height() - scroll_view_->height() +
541 scroll_view_->GetPreferredSize().height(); 546 scroll_view_->GetPreferredSize().height();
542 547
543 GetWidget()->CenterWindow(gfx::Size(widget_bound.width(), new_height)); 548 GetWidget()->CenterWindow(gfx::Size(widget_bound.width(), new_height));
544 } 549 }
545 550
551 DesktopMediaListView*
552 DesktopMediaPickerDialogView::GetMediaListViewForTesting() const {
553 return list_view_;
554 }
555
546 DesktopMediaSourceView* 556 DesktopMediaSourceView*
547 DesktopMediaPickerDialogView::GetMediaSourceViewForTesting(int index) const { 557 DesktopMediaPickerDialogView::GetMediaSourceViewForTesting(int index) const {
548 if (list_view_->child_count() <= index) 558 if (list_view_->child_count() <= index)
549 return NULL; 559 return NULL;
550 560
551 return reinterpret_cast<DesktopMediaSourceView*>(list_view_->child_at(index)); 561 return reinterpret_cast<DesktopMediaSourceView*>(list_view_->child_at(index));
552 } 562 }
553 563
554 DesktopMediaPickerViews::DesktopMediaPickerViews() : dialog_(NULL) { 564 DesktopMediaPickerViews::DesktopMediaPickerViews() : dialog_(NULL) {
555 } 565 }
(...skipping 29 matching lines...) Expand all
585 content::BrowserThread::PostTask( 595 content::BrowserThread::PostTask(
586 content::BrowserThread::UI, FROM_HERE, 596 content::BrowserThread::UI, FROM_HERE,
587 base::Bind(callback_, source)); 597 base::Bind(callback_, source));
588 callback_.Reset(); 598 callback_.Reset();
589 } 599 }
590 600
591 // static 601 // static
592 scoped_ptr<DesktopMediaPicker> DesktopMediaPicker::Create() { 602 scoped_ptr<DesktopMediaPicker> DesktopMediaPicker::Create() {
593 return scoped_ptr<DesktopMediaPicker>(new DesktopMediaPickerViews()); 603 return scoped_ptr<DesktopMediaPicker>(new DesktopMediaPickerViews());
594 } 604 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698