OLD | NEW |
---|---|
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 Loading... | |
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 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
436 #endif | 437 #endif |
437 | 438 |
438 // Set native window ID if the windows is outside Ash. | 439 // Set native window ID if the windows is outside Ash. |
439 if (!is_ash_window) { | 440 if (!is_ash_window) { |
440 dialog_window_id.id = AcceleratedWidgetToDesktopMediaId( | 441 dialog_window_id.id = AcceleratedWidgetToDesktopMediaId( |
441 widget->GetNativeWindow()->GetHost()->GetAcceleratedWidget()); | 442 widget->GetNativeWindow()->GetHost()->GetAcceleratedWidget()); |
442 } | 443 } |
443 } | 444 } |
444 | 445 |
445 list_view_->StartUpdating(dialog_window_id); | 446 list_view_->StartUpdating(dialog_window_id); |
447 | |
448 GetInitiallyFocusedView()->RequestFocus(); | |
Peter Kasting
2015/09/24 20:46:56
I've asked several times why this code is still he
gyzhou
2015/10/02 18:51:26
Done.
| |
446 } | 449 } |
447 | 450 |
448 DesktopMediaPickerDialogView::~DesktopMediaPickerDialogView() {} | 451 DesktopMediaPickerDialogView::~DesktopMediaPickerDialogView() {} |
449 | 452 |
450 void DesktopMediaPickerDialogView::DetachParent() { | 453 void DesktopMediaPickerDialogView::DetachParent() { |
451 parent_ = NULL; | 454 parent_ = NULL; |
452 } | 455 } |
453 | 456 |
454 gfx::Size DesktopMediaPickerDialogView::GetPreferredSize() const { | 457 gfx::Size DesktopMediaPickerDialogView::GetPreferredSize() const { |
455 static const size_t kDialogViewWidth = 600; | 458 static const size_t kDialogViewWidth = 600; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
488 return l10n_util::GetStringFUTF16(IDS_DESKTOP_MEDIA_PICKER_TITLE, app_name_); | 491 return l10n_util::GetStringFUTF16(IDS_DESKTOP_MEDIA_PICKER_TITLE, app_name_); |
489 } | 492 } |
490 | 493 |
491 bool DesktopMediaPickerDialogView::IsDialogButtonEnabled( | 494 bool DesktopMediaPickerDialogView::IsDialogButtonEnabled( |
492 ui::DialogButton button) const { | 495 ui::DialogButton button) const { |
493 if (button == ui::DIALOG_BUTTON_OK) | 496 if (button == ui::DIALOG_BUTTON_OK) |
494 return list_view_->GetSelection() != NULL; | 497 return list_view_->GetSelection() != NULL; |
495 return true; | 498 return true; |
496 } | 499 } |
497 | 500 |
501 views::View* DesktopMediaPickerDialogView::GetInitiallyFocusedView(){ | |
502 return list_view_; | |
503 } | |
504 | |
498 base::string16 DesktopMediaPickerDialogView::GetDialogButtonLabel( | 505 base::string16 DesktopMediaPickerDialogView::GetDialogButtonLabel( |
499 ui::DialogButton button) const { | 506 ui::DialogButton button) const { |
500 return l10n_util::GetStringUTF16(button == ui::DIALOG_BUTTON_OK ? | 507 return l10n_util::GetStringUTF16(button == ui::DIALOG_BUTTON_OK ? |
501 IDS_DESKTOP_MEDIA_PICKER_SHARE : IDS_CANCEL); | 508 IDS_DESKTOP_MEDIA_PICKER_SHARE : IDS_CANCEL); |
502 } | 509 } |
503 | 510 |
504 bool DesktopMediaPickerDialogView::Accept() { | 511 bool DesktopMediaPickerDialogView::Accept() { |
505 DesktopMediaSourceView* selection = list_view_->GetSelection(); | 512 DesktopMediaSourceView* selection = list_view_->GetSelection(); |
506 | 513 |
507 // Ok button should only be enabled when a source is selected. | 514 // Ok button should only be enabled when a source is selected. |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
585 content::BrowserThread::PostTask( | 592 content::BrowserThread::PostTask( |
586 content::BrowserThread::UI, FROM_HERE, | 593 content::BrowserThread::UI, FROM_HERE, |
587 base::Bind(callback_, source)); | 594 base::Bind(callback_, source)); |
588 callback_.Reset(); | 595 callback_.Reset(); |
589 } | 596 } |
590 | 597 |
591 // static | 598 // static |
592 scoped_ptr<DesktopMediaPicker> DesktopMediaPicker::Create() { | 599 scoped_ptr<DesktopMediaPicker> DesktopMediaPicker::Create() { |
593 return scoped_ptr<DesktopMediaPicker>(new DesktopMediaPickerViews()); | 600 return scoped_ptr<DesktopMediaPicker>(new DesktopMediaPickerViews()); |
594 } | 601 } |
OLD | NEW |