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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> |
8 | 9 |
9 #include "base/callback.h" | 10 #include "base/callback.h" |
10 #include "base/command_line.h" | 11 #include "base/command_line.h" |
11 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
12 #include "build/build_config.h" | 13 #include "build/build_config.h" |
13 #include "chrome/browser/media/desktop_media_list.h" | 14 #include "chrome/browser/media/desktop_media_list.h" |
14 #include "chrome/browser/ui/ash/ash_util.h" | 15 #include "chrome/browser/ui/ash/ash_util.h" |
15 #include "chrome/common/chrome_switches.h" | 16 #include "chrome/common/chrome_switches.h" |
16 #include "chrome/grit/generated_resources.h" | 17 #include "chrome/grit/generated_resources.h" |
17 #include "components/constrained_window/constrained_window_views.h" | 18 #include "components/constrained_window/constrained_window_views.h" |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 // on the long tap (when the tap gesture starts). | 204 // on the long tap (when the tap gesture starts). |
204 if (event->type() == ui::ET_GESTURE_TAP_DOWN) { | 205 if (event->type() == ui::ET_GESTURE_TAP_DOWN) { |
205 RequestFocus(); | 206 RequestFocus(); |
206 event->SetHandled(); | 207 event->SetHandled(); |
207 } | 208 } |
208 } | 209 } |
209 | 210 |
210 DesktopMediaListView::DesktopMediaListView( | 211 DesktopMediaListView::DesktopMediaListView( |
211 DesktopMediaPickerDialogView* parent, | 212 DesktopMediaPickerDialogView* parent, |
212 scoped_ptr<DesktopMediaList> media_list) | 213 scoped_ptr<DesktopMediaList> media_list) |
213 : parent_(parent), | 214 : parent_(parent), media_list_(std::move(media_list)), weak_factory_(this) { |
214 media_list_(media_list.Pass()), | |
215 weak_factory_(this) { | |
216 media_list_->SetThumbnailSize(gfx::Size(kThumbnailWidth, kThumbnailHeight)); | 215 media_list_->SetThumbnailSize(gfx::Size(kThumbnailWidth, kThumbnailHeight)); |
217 SetFocusable(true); | 216 SetFocusable(true); |
218 } | 217 } |
219 | 218 |
220 DesktopMediaListView::~DesktopMediaListView() {} | 219 DesktopMediaListView::~DesktopMediaListView() {} |
221 | 220 |
222 void DesktopMediaListView::StartUpdating(DesktopMediaID dialog_window_id) { | 221 void DesktopMediaListView::StartUpdating(DesktopMediaID dialog_window_id) { |
223 media_list_->SetViewDialogWindowId(dialog_window_id); | 222 media_list_->SetViewDialogWindowId(dialog_window_id); |
224 media_list_->StartUpdating(this); | 223 media_list_->StartUpdating(this); |
225 } | 224 } |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 content::WebContents* parent_web_contents, | 390 content::WebContents* parent_web_contents, |
392 gfx::NativeWindow context, | 391 gfx::NativeWindow context, |
393 DesktopMediaPickerViews* parent, | 392 DesktopMediaPickerViews* parent, |
394 const base::string16& app_name, | 393 const base::string16& app_name, |
395 const base::string16& target_name, | 394 const base::string16& target_name, |
396 scoped_ptr<DesktopMediaList> media_list) | 395 scoped_ptr<DesktopMediaList> media_list) |
397 : parent_(parent), | 396 : parent_(parent), |
398 app_name_(app_name), | 397 app_name_(app_name), |
399 label_(new views::Label()), | 398 label_(new views::Label()), |
400 scroll_view_(views::ScrollView::CreateScrollViewWithBorder()), | 399 scroll_view_(views::ScrollView::CreateScrollViewWithBorder()), |
401 list_view_(new DesktopMediaListView(this, media_list.Pass())) { | 400 list_view_(new DesktopMediaListView(this, std::move(media_list))) { |
402 if (app_name == target_name) { | 401 if (app_name == target_name) { |
403 label_->SetText( | 402 label_->SetText( |
404 l10n_util::GetStringFUTF16(IDS_DESKTOP_MEDIA_PICKER_TEXT, app_name)); | 403 l10n_util::GetStringFUTF16(IDS_DESKTOP_MEDIA_PICKER_TEXT, app_name)); |
405 } else { | 404 } else { |
406 label_->SetText(l10n_util::GetStringFUTF16( | 405 label_->SetText(l10n_util::GetStringFUTF16( |
407 IDS_DESKTOP_MEDIA_PICKER_TEXT_DELEGATED, app_name, target_name)); | 406 IDS_DESKTOP_MEDIA_PICKER_TEXT_DELEGATED, app_name, target_name)); |
408 } | 407 } |
409 label_->SetMultiLine(true); | 408 label_->SetMultiLine(true); |
410 label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 409 label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
411 AddChildView(label_); | 410 AddChildView(label_); |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
580 } | 579 } |
581 | 580 |
582 void DesktopMediaPickerViews::Show(content::WebContents* web_contents, | 581 void DesktopMediaPickerViews::Show(content::WebContents* web_contents, |
583 gfx::NativeWindow context, | 582 gfx::NativeWindow context, |
584 gfx::NativeWindow parent, | 583 gfx::NativeWindow parent, |
585 const base::string16& app_name, | 584 const base::string16& app_name, |
586 const base::string16& target_name, | 585 const base::string16& target_name, |
587 scoped_ptr<DesktopMediaList> media_list, | 586 scoped_ptr<DesktopMediaList> media_list, |
588 const DoneCallback& done_callback) { | 587 const DoneCallback& done_callback) { |
589 callback_ = done_callback; | 588 callback_ = done_callback; |
590 dialog_ = new DesktopMediaPickerDialogView( | 589 dialog_ = |
591 web_contents, context, this, app_name, target_name, media_list.Pass()); | 590 new DesktopMediaPickerDialogView(web_contents, context, this, app_name, |
| 591 target_name, std::move(media_list)); |
592 } | 592 } |
593 | 593 |
594 void DesktopMediaPickerViews::NotifyDialogResult(DesktopMediaID source) { | 594 void DesktopMediaPickerViews::NotifyDialogResult(DesktopMediaID source) { |
595 // Once this method is called the |dialog_| will close and destroy itself. | 595 // Once this method is called the |dialog_| will close and destroy itself. |
596 dialog_->DetachParent(); | 596 dialog_->DetachParent(); |
597 dialog_ = NULL; | 597 dialog_ = NULL; |
598 | 598 |
599 DCHECK(!callback_.is_null()); | 599 DCHECK(!callback_.is_null()); |
600 | 600 |
601 // Notify the |callback_| asynchronously because it may need to destroy | 601 // Notify the |callback_| asynchronously because it may need to destroy |
602 // DesktopMediaPicker. | 602 // DesktopMediaPicker. |
603 content::BrowserThread::PostTask( | 603 content::BrowserThread::PostTask( |
604 content::BrowserThread::UI, FROM_HERE, | 604 content::BrowserThread::UI, FROM_HERE, |
605 base::Bind(callback_, source)); | 605 base::Bind(callback_, source)); |
606 callback_.Reset(); | 606 callback_.Reset(); |
607 } | 607 } |
608 | 608 |
609 // static | 609 // static |
610 scoped_ptr<DesktopMediaPicker> DesktopMediaPicker::Create() { | 610 scoped_ptr<DesktopMediaPicker> DesktopMediaPicker::Create() { |
611 return scoped_ptr<DesktopMediaPicker>(new DesktopMediaPickerViews()); | 611 return scoped_ptr<DesktopMediaPicker>(new DesktopMediaPickerViews()); |
612 } | 612 } |
OLD | NEW |