Chromium Code Reviews| Index: chrome/browser/ui/views/desktop_media_picker_views.cc |
| diff --git a/chrome/browser/ui/views/desktop_media_picker_views.cc b/chrome/browser/ui/views/desktop_media_picker_views.cc |
| index f6b9b8a6526dd793859cc1bb9ae06169c7a90fdf..fea6071a3f462a8265177b8cf2c650e4f97d79a9 100644 |
| --- a/chrome/browser/ui/views/desktop_media_picker_views.cc |
| +++ b/chrome/browser/ui/views/desktop_media_picker_views.cc |
| @@ -8,6 +8,9 @@ |
| #include "chrome/browser/media/desktop_media_list.h" |
| #include "chrome/browser/media/desktop_media_list_observer.h" |
| #include "chrome/browser/ui/ash/ash_util.h" |
| +#include "components/web_modal/web_contents_modal_dialog_host.h" |
| +#include "components/web_modal/web_contents_modal_dialog_manager.h" |
| +#include "components/web_modal/web_contents_modal_dialog_manager_delegate.h" |
| #include "content/public/browser/browser_thread.h" |
| #include "grit/generated_resources.h" |
| #include "ui/aura/window_tree_host.h" |
| @@ -27,6 +30,8 @@ |
| #include "ui/wm/core/shadow_types.h" |
| using content::DesktopMediaID; |
| +using web_modal::WebContentsModalDialogManager; |
| +using web_modal::WebContentsModalDialogManagerDelegate; |
| namespace { |
| @@ -147,7 +152,8 @@ class DesktopMediaListView : public views::View, |
| // Dialog view used for DesktopMediaPickerViews. |
| class DesktopMediaPickerDialogView : public views::DialogDelegateView { |
| public: |
| - DesktopMediaPickerDialogView(gfx::NativeWindow context, |
| + DesktopMediaPickerDialogView(content::WebContents* parent_web_contents, |
| + gfx::NativeWindow context, |
| gfx::NativeWindow parent_window, |
| DesktopMediaPickerViews* parent, |
| const base::string16& app_name, |
| @@ -173,6 +179,7 @@ class DesktopMediaPickerDialogView : public views::DialogDelegateView { |
| ui::DialogButton button) const OVERRIDE; |
| virtual bool Accept() OVERRIDE; |
| virtual void DeleteDelegate() OVERRIDE; |
| + virtual views::Widget* GetWidget() OVERRIDE; |
| private: |
| DesktopMediaPickerViews* parent_; |
| @@ -181,6 +188,7 @@ class DesktopMediaPickerDialogView : public views::DialogDelegateView { |
| views::Label* label_; |
| views::ScrollView* scroll_view_; |
| DesktopMediaListView* list_view_; |
| + views::Widget* widget_; |
|
sky
2014/05/23 00:03:02
Why do you need to cache widget_ and override GetW
zel
2014/05/23 17:51:44
Done.
|
| DISALLOW_COPY_AND_ASSIGN(DesktopMediaPickerDialogView); |
| }; |
| @@ -194,7 +202,8 @@ class DesktopMediaPickerViews : public DesktopMediaPicker { |
| void NotifyDialogResult(DesktopMediaID source); |
| // DesktopMediaPicker overrides. |
| - virtual void Show(gfx::NativeWindow context, |
| + virtual void Show(content::WebContents* web_contents, |
| + gfx::NativeWindow context, |
| gfx::NativeWindow parent, |
| const base::string16& app_name, |
| const base::string16& target_name, |
| @@ -485,6 +494,7 @@ void DesktopMediaListView::OnSourceThumbnailChanged(int index) { |
| } |
| DesktopMediaPickerDialogView::DesktopMediaPickerDialogView( |
| + content::WebContents* parent_web_contents, |
| gfx::NativeWindow context, |
| gfx::NativeWindow parent_window, |
| DesktopMediaPickerViews* parent, |
| @@ -495,7 +505,8 @@ DesktopMediaPickerDialogView::DesktopMediaPickerDialogView( |
| app_name_(app_name), |
| label_(new views::Label()), |
| scroll_view_(views::ScrollView::CreateScrollViewWithBorder()), |
| - list_view_(new DesktopMediaListView(this, media_list.Pass())) { |
| + list_view_(new DesktopMediaListView(this, media_list.Pass())), |
| + widget_(NULL) { |
| if (app_name == target_name) { |
| label_->SetText( |
| l10n_util::GetStringFUTF16(IDS_DESKTOP_MEDIA_PICKER_TEXT, app_name)); |
| @@ -510,7 +521,15 @@ DesktopMediaPickerDialogView::DesktopMediaPickerDialogView( |
| scroll_view_->SetContents(list_view_); |
| AddChildView(scroll_view_); |
| - DialogDelegate::CreateDialogWidget(this, context, parent_window); |
| + WebContentsModalDialogManager* web_contents_modal_dialog_manager = |
| + WebContentsModalDialogManager::FromWebContents(parent_web_contents); |
| + DCHECK(web_contents_modal_dialog_manager); |
| + WebContentsModalDialogManagerDelegate* delegate = |
| + web_contents_modal_dialog_manager->delegate(); |
| + DCHECK(delegate); |
| + widget_ = views::Widget::CreateWindowAsFramelessChild( |
| + this, |
| + delegate->GetWebContentsModalDialogHost()->GetHostView()); |
| // DesktopMediaList needs to know the ID of the picker window which |
| // matches the ID it gets from the OS. Depending on the OS and configuration |
| @@ -531,11 +550,16 @@ DesktopMediaPickerDialogView::DesktopMediaPickerDialogView( |
| list_view_->StartUpdating(dialog_window_id); |
| - GetWidget()->Show(); |
| + web_contents_modal_dialog_manager->ShowModalDialog( |
| + GetWidget()->GetNativeView()); |
| } |
| DesktopMediaPickerDialogView::~DesktopMediaPickerDialogView() {} |
| +views::Widget* DesktopMediaPickerDialogView::GetWidget() { |
| + return widget_; |
| +} |
| + |
| void DesktopMediaPickerDialogView::DetachParent() { |
| parent_ = NULL; |
| } |
| @@ -619,7 +643,8 @@ DesktopMediaPickerViews::~DesktopMediaPickerViews() { |
| } |
| } |
| -void DesktopMediaPickerViews::Show(gfx::NativeWindow context, |
| +void DesktopMediaPickerViews::Show(content::WebContents* web_contents, |
| + gfx::NativeWindow context, |
| gfx::NativeWindow parent, |
| const base::string16& app_name, |
| const base::string16& target_name, |
| @@ -627,7 +652,8 @@ void DesktopMediaPickerViews::Show(gfx::NativeWindow context, |
| const DoneCallback& done_callback) { |
| callback_ = done_callback; |
| dialog_ = new DesktopMediaPickerDialogView( |
| - context, parent, this, app_name, target_name, media_list.Pass()); |
| + web_contents, context, parent, this, app_name, target_name, |
| + media_list.Pass()); |
| } |
| void DesktopMediaPickerViews::NotifyDialogResult( |