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

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

Issue 502693003: Cleanup DesktopMediaPicker Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/views/desktop_media_picker_views.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 source_view->SetThumbnail(source.thumbnail); 374 source_view->SetThumbnail(source.thumbnail);
375 } 375 }
376 376
377 void DesktopMediaListView::AcceptSelection() { 377 void DesktopMediaListView::AcceptSelection() {
378 OnSelectionChanged(); 378 OnSelectionChanged();
379 OnDoubleClick(); 379 OnDoubleClick();
380 } 380 }
381 381
382 DesktopMediaPickerDialogView::DesktopMediaPickerDialogView( 382 DesktopMediaPickerDialogView::DesktopMediaPickerDialogView(
383 content::WebContents* parent_web_contents, 383 content::WebContents* parent_web_contents,
384 gfx::NativeWindow context,
385 gfx::NativeWindow parent_window,
386 DesktopMediaPickerViews* parent, 384 DesktopMediaPickerViews* parent,
387 const base::string16& app_name, 385 const base::string16& app_name,
388 const base::string16& target_name, 386 const base::string16& target_name,
389 scoped_ptr<DesktopMediaList> media_list) 387 scoped_ptr<DesktopMediaList> media_list)
390 : parent_(parent), 388 : parent_(parent),
391 app_name_(app_name), 389 app_name_(app_name),
392 label_(new views::Label()), 390 label_(new views::Label()),
393 scroll_view_(views::ScrollView::CreateScrollViewWithBorder()), 391 scroll_view_(views::ScrollView::CreateScrollViewWithBorder()),
394 list_view_(new DesktopMediaListView(this, media_list.Pass())) { 392 list_view_(new DesktopMediaListView(this, media_list.Pass())) {
395 if (app_name == target_name) { 393 if (app_name == target_name) {
(...skipping 10 matching lines...) Expand all
406 scroll_view_->SetContents(list_view_); 404 scroll_view_->SetContents(list_view_);
407 scroll_view_->ClipHeightTo( 405 scroll_view_->ClipHeightTo(
408 GetMediaListViewHeightForRows(1), GetMediaListViewHeightForRows(2)); 406 GetMediaListViewHeightForRows(1), GetMediaListViewHeightForRows(2));
409 AddChildView(scroll_view_); 407 AddChildView(scroll_view_);
410 408
411 // If |parent_web_contents| is set and it's not a background page then the 409 // If |parent_web_contents| is set and it's not a background page then the
412 // picker will be shown modal to the web contents. Otherwise the picker is 410 // picker will be shown modal to the web contents. Otherwise the picker is
413 // shown in a separate window. 411 // shown in a separate window.
414 views::Widget* widget = NULL; 412 views::Widget* widget = NULL;
415 bool modal_dialog = 413 bool modal_dialog =
416 parent_web_contents &&
417 !parent_web_contents->GetDelegate()->IsNeverVisible(parent_web_contents); 414 !parent_web_contents->GetDelegate()->IsNeverVisible(parent_web_contents);
418 if (modal_dialog) { 415 if (modal_dialog) {
419 widget = CreateWebModalDialogViews(this, parent_web_contents); 416 widget = CreateWebModalDialogViews(this, parent_web_contents);
420 } else { 417 } else {
421 widget = DialogDelegate::CreateDialogWidget(this, context, NULL); 418 widget = DialogDelegate::CreateDialogWidget(
419 this, parent_web_contents->GetTopLevelNativeWindow(), NULL);
422 } 420 }
423 421
424 // DesktopMediaList needs to know the ID of the picker window which 422 // DesktopMediaList needs to know the ID of the picker window which
425 // matches the ID it gets from the OS. Depending on the OS and configuration 423 // matches the ID it gets from the OS. Depending on the OS and configuration
426 // we get this ID differently. 424 // we get this ID differently.
427 DesktopMediaID::Id dialog_window_id = 0; 425 DesktopMediaID::Id dialog_window_id = 0;
428 426
429 // If the picker is not modal then the picker window needs to be filtered. 427 // If the picker is not modal then the picker window needs to be filtered.
430 if (!modal_dialog) { 428 if (!modal_dialog) {
431 #if defined(USE_ASH) 429 #if defined(USE_ASH)
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 } 562 }
565 563
566 DesktopMediaPickerViews::~DesktopMediaPickerViews() { 564 DesktopMediaPickerViews::~DesktopMediaPickerViews() {
567 if (dialog_) { 565 if (dialog_) {
568 dialog_->DetachParent(); 566 dialog_->DetachParent();
569 dialog_->GetWidget()->Close(); 567 dialog_->GetWidget()->Close();
570 } 568 }
571 } 569 }
572 570
573 void DesktopMediaPickerViews::Show(content::WebContents* web_contents, 571 void DesktopMediaPickerViews::Show(content::WebContents* web_contents,
574 gfx::NativeWindow context,
575 gfx::NativeWindow parent,
576 const base::string16& app_name, 572 const base::string16& app_name,
577 const base::string16& target_name, 573 const base::string16& target_name,
578 scoped_ptr<DesktopMediaList> media_list, 574 scoped_ptr<DesktopMediaList> media_list,
579 const DoneCallback& done_callback) { 575 const DoneCallback& done_callback) {
580 callback_ = done_callback; 576 callback_ = done_callback;
581 dialog_ = new DesktopMediaPickerDialogView( 577 dialog_ = new DesktopMediaPickerDialogView(
582 web_contents, context, parent, this, app_name, target_name, 578 web_contents, this, app_name, target_name, media_list.Pass());
583 media_list.Pass());
584 } 579 }
585 580
586 void DesktopMediaPickerViews::NotifyDialogResult(DesktopMediaID source) { 581 void DesktopMediaPickerViews::NotifyDialogResult(DesktopMediaID source) {
587 // Once this method is called the |dialog_| will close and destroy itself. 582 // Once this method is called the |dialog_| will close and destroy itself.
588 dialog_->DetachParent(); 583 dialog_->DetachParent();
589 dialog_ = NULL; 584 dialog_ = NULL;
590 585
591 DCHECK(!callback_.is_null()); 586 DCHECK(!callback_.is_null());
592 587
593 // Notify the |callback_| asynchronously because it may need to destroy 588 // Notify the |callback_| asynchronously because it may need to destroy
594 // DesktopMediaPicker. 589 // DesktopMediaPicker.
595 content::BrowserThread::PostTask( 590 content::BrowserThread::PostTask(
596 content::BrowserThread::UI, FROM_HERE, 591 content::BrowserThread::UI, FROM_HERE,
597 base::Bind(callback_, source)); 592 base::Bind(callback_, source));
598 callback_.Reset(); 593 callback_.Reset();
599 } 594 }
600 595
601 // static 596 // static
602 scoped_ptr<DesktopMediaPicker> DesktopMediaPicker::Create() { 597 scoped_ptr<DesktopMediaPicker> DesktopMediaPicker::Create() {
603 return scoped_ptr<DesktopMediaPicker>(new DesktopMediaPickerViews()); 598 return scoped_ptr<DesktopMediaPicker>(new DesktopMediaPickerViews());
604 } 599 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/desktop_media_picker_views.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698