| 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_capture/desktop_media_picker_views.h" | 5 #include "chrome/browser/ui/views/desktop_capture/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 "chrome/browser/media/desktop_media_list.h" | 9 #include "chrome/browser/media/desktop_media_list.h" |
| 10 #include "chrome/browser/ui/views/desktop_capture/desktop_media_list_view.h" | 10 #include "chrome/browser/ui/views/desktop_capture/desktop_media_list_view.h" |
| 11 #include "chrome/browser/ui/views/desktop_capture/desktop_media_source_view.h" | 11 #include "chrome/browser/ui/views/desktop_capture/desktop_media_source_view.h" |
| 12 #include "chrome/browser/ui/views/desktop_media_picker_views_deprecated.h" | 12 #include "chrome/browser/ui/views/desktop_media_picker_views_deprecated.h" |
| 13 #include "chrome/grit/chromium_strings.h" | 13 #include "chrome/grit/chromium_strings.h" |
| 14 #include "chrome/grit/generated_resources.h" | 14 #include "chrome/grit/generated_resources.h" |
| 15 #include "chrome/grit/google_chrome_strings.h" | 15 #include "chrome/grit/google_chrome_strings.h" |
| 16 #include "components/constrained_window/constrained_window_views.h" | 16 #include "components/constrained_window/constrained_window_views.h" |
| 17 #include "components/web_modal/web_contents_modal_dialog_manager.h" | 17 #include "components/web_modal/web_contents_modal_dialog_manager.h" |
| 18 #include "content/public/browser/browser_thread.h" | 18 #include "content/public/browser/browser_thread.h" |
| 19 #include "content/public/browser/render_frame_host.h" | 19 #include "content/public/browser/render_frame_host.h" |
| 20 #include "content/public/browser/web_contents_delegate.h" | 20 #include "content/public/browser/web_contents_delegate.h" |
| 21 #include "extensions/common/switches.h" | 21 #include "extensions/common/switches.h" |
| 22 #include "grit/components_strings.h" | 22 #include "grit/components_strings.h" |
| 23 #include "ui/aura/window_tree_host.h" | 23 #include "ui/aura/window_tree_host.h" |
| 24 #include "ui/base/l10n/l10n_util.h" | 24 #include "ui/base/l10n/l10n_util.h" |
| 25 #include "ui/events/keycodes/keyboard_codes.h" | 25 #include "ui/events/keycodes/keyboard_codes.h" |
| 26 #include "ui/gfx/canvas.h" | 26 #include "ui/gfx/canvas.h" |
| 27 #include "ui/views/background.h" |
| 27 #include "ui/views/controls/button/checkbox.h" | 28 #include "ui/views/controls/button/checkbox.h" |
| 28 #include "ui/views/controls/scroll_view.h" | 29 #include "ui/views/controls/scroll_view.h" |
| 29 #include "ui/views/controls/tabbed_pane/tabbed_pane.h" | 30 #include "ui/views/controls/tabbed_pane/tabbed_pane.h" |
| 30 #include "ui/views/layout/box_layout.h" | 31 #include "ui/views/layout/box_layout.h" |
| 31 #include "ui/views/layout/layout_constants.h" | 32 #include "ui/views/layout/layout_constants.h" |
| 32 #include "ui/views/widget/widget.h" | 33 #include "ui/views/widget/widget.h" |
| 33 #include "ui/views/window/dialog_client_view.h" | 34 #include "ui/views/window/dialog_client_view.h" |
| 34 #include "ui/wm/core/shadow_types.h" | 35 #include "ui/wm/core/shadow_types.h" |
| 35 | 36 |
| 36 using content::DesktopMediaID; | 37 using content::DesktopMediaID; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 65 audio_share_checkbox_(nullptr), | 66 audio_share_checkbox_(nullptr), |
| 66 pane_(new views::TabbedPane()) { | 67 pane_(new views::TabbedPane()) { |
| 67 SetLayoutManager(new views::BoxLayout( | 68 SetLayoutManager(new views::BoxLayout( |
| 68 views::BoxLayout::kVertical, views::kButtonHEdgeMarginNew, | 69 views::BoxLayout::kVertical, views::kButtonHEdgeMarginNew, |
| 69 views::kPanelVertMargin, views::kLabelToControlVerticalSpacing)); | 70 views::kPanelVertMargin, views::kLabelToControlVerticalSpacing)); |
| 70 | 71 |
| 71 description_label_->SetMultiLine(true); | 72 description_label_->SetMultiLine(true); |
| 72 description_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 73 description_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 73 AddChildView(description_label_); | 74 AddChildView(description_label_); |
| 74 | 75 |
| 76 const SkColor bg_color = GetNativeTheme()->GetSystemColor( |
| 77 ui::NativeTheme::kColorId_MenuBackgroundColor); |
| 78 |
| 75 if (screen_list) { | 79 if (screen_list) { |
| 76 source_types_.push_back(DesktopMediaID::TYPE_SCREEN); | 80 source_types_.push_back(DesktopMediaID::TYPE_SCREEN); |
| 77 | 81 |
| 82 const DesktopMediaSourceViewStyle kSingleScreenStyle( |
| 83 1, // columns |
| 84 gfx::Size(360, 280), // item_size |
| 85 gfx::Rect(), // label_rect |
| 86 gfx::HorizontalAlignment::ALIGN_CENTER, // text_alignment |
| 87 gfx::Rect(20, 20, 320, 240), // image_rect |
| 88 4, // selection_border_thickness |
| 89 5); // focus_rectangle_inset |
| 90 |
| 91 const DesktopMediaSourceViewStyle kGenericScreenStyle( |
| 92 2, // columns |
| 93 gfx::Size(270, 220), // item_size |
| 94 gfx::Rect(15, 165, 240, 40), // label_rect |
| 95 gfx::HorizontalAlignment::ALIGN_CENTER, // text_alignment |
| 96 gfx::Rect(15, 15, 240, 150), // image_rect |
| 97 2, // selection_border_thickness |
| 98 5); // focus_rectangle_inset |
| 99 |
| 78 views::ScrollView* screen_scroll_view = | 100 views::ScrollView* screen_scroll_view = |
| 79 views::ScrollView::CreateScrollViewWithBorder(); | 101 views::ScrollView::CreateScrollViewWithBorder(); |
| 80 list_views_.push_back( | 102 list_views_.push_back(new DesktopMediaListView( |
| 81 new DesktopMediaListView(this, std::move(screen_list))); | 103 this, std::move(screen_list), kGenericScreenStyle, kSingleScreenStyle)); |
| 82 | 104 |
| 83 screen_scroll_view->SetContents(list_views_.back()); | 105 screen_scroll_view->SetContents(list_views_.back()); |
| 84 screen_scroll_view->ClipHeightTo(kListItemHeight, kListItemHeight * 2); | 106 screen_scroll_view->ClipHeightTo( |
| 107 kGenericScreenStyle.item_size.height(), |
| 108 kGenericScreenStyle.item_size.height() * 2); |
| 109 screen_scroll_view->set_hide_horizontal_scrollbar(true); |
| 110 screen_scroll_view->set_background( |
| 111 views::Background::CreateSolidBackground(bg_color)); |
| 112 |
| 85 pane_->AddTab( | 113 pane_->AddTab( |
| 86 l10n_util::GetStringUTF16(IDS_DESKTOP_MEDIA_PICKER_SOURCE_TYPE_SCREEN), | 114 l10n_util::GetStringUTF16(IDS_DESKTOP_MEDIA_PICKER_SOURCE_TYPE_SCREEN), |
| 87 screen_scroll_view); | 115 screen_scroll_view); |
| 88 pane_->set_listener(this); | 116 pane_->set_listener(this); |
| 89 } | 117 } |
| 90 | 118 |
| 91 if (window_list) { | 119 if (window_list) { |
| 92 source_types_.push_back(DesktopMediaID::TYPE_WINDOW); | 120 source_types_.push_back(DesktopMediaID::TYPE_WINDOW); |
| 121 |
| 122 const DesktopMediaSourceViewStyle kWindowStyle( |
| 123 3, // columns |
| 124 gfx::Size(180, 160), // item_size |
| 125 gfx::Rect(10, 110, 160, 40), // label_rect |
| 126 gfx::HorizontalAlignment::ALIGN_CENTER, // text_alignment |
| 127 gfx::Rect(8, 8, 164, 104), // image_rect |
| 128 2, // selection_border_thickness |
| 129 5); // focus_rectangle_inset |
| 130 |
| 93 views::ScrollView* window_scroll_view = | 131 views::ScrollView* window_scroll_view = |
| 94 views::ScrollView::CreateScrollViewWithBorder(); | 132 views::ScrollView::CreateScrollViewWithBorder(); |
| 95 list_views_.push_back( | 133 list_views_.push_back(new DesktopMediaListView(this, std::move(window_list), |
| 96 new DesktopMediaListView(this, std::move(window_list))); | 134 kWindowStyle, kWindowStyle)); |
| 97 | |
| 98 window_scroll_view->SetContents(list_views_.back()); | 135 window_scroll_view->SetContents(list_views_.back()); |
| 99 window_scroll_view->ClipHeightTo(kListItemHeight, kListItemHeight * 2); | 136 window_scroll_view->ClipHeightTo(kWindowStyle.item_size.height(), |
| 137 kWindowStyle.item_size.height() * 2); |
| 138 window_scroll_view->set_hide_horizontal_scrollbar(true); |
| 139 window_scroll_view->set_background( |
| 140 views::Background::CreateSolidBackground(bg_color)); |
| 100 | 141 |
| 101 pane_->AddTab( | 142 pane_->AddTab( |
| 102 l10n_util::GetStringUTF16(IDS_DESKTOP_MEDIA_PICKER_SOURCE_TYPE_WINDOW), | 143 l10n_util::GetStringUTF16(IDS_DESKTOP_MEDIA_PICKER_SOURCE_TYPE_WINDOW), |
| 103 window_scroll_view); | 144 window_scroll_view); |
| 104 pane_->set_listener(this); | 145 pane_->set_listener(this); |
| 105 } | 146 } |
| 106 | 147 |
| 107 if (tab_list) { | 148 if (tab_list) { |
| 108 source_types_.push_back(DesktopMediaID::TYPE_WEB_CONTENTS); | 149 source_types_.push_back(DesktopMediaID::TYPE_WEB_CONTENTS); |
| 150 |
| 151 const DesktopMediaSourceViewStyle kTabStyle( |
| 152 1, // columns |
| 153 gfx::Size(600, 30), // item_size |
| 154 gfx::Rect(46, 0, 490, 30), // label_rect |
| 155 gfx::HorizontalAlignment::ALIGN_LEFT, // text_alignment |
| 156 gfx::Rect(10, 2, 26, 26), // image_rect |
| 157 1, // selection_border_thickness |
| 158 0); // focus_rectangle_inset |
| 159 |
| 109 views::ScrollView* tab_scroll_view = | 160 views::ScrollView* tab_scroll_view = |
| 110 views::ScrollView::CreateScrollViewWithBorder(); | 161 views::ScrollView::CreateScrollViewWithBorder(); |
| 111 list_views_.push_back(new DesktopMediaListView(this, std::move(tab_list))); | 162 list_views_.push_back(new DesktopMediaListView(this, std::move(tab_list), |
| 163 kTabStyle, kTabStyle)); |
| 112 | 164 |
| 113 tab_scroll_view->SetContents(list_views_.back()); | 165 tab_scroll_view->SetContents(list_views_.back()); |
| 114 tab_scroll_view->ClipHeightTo(kListItemHeight, kListItemHeight * 2); | 166 tab_scroll_view->ClipHeightTo(kTabStyle.item_size.height(), |
| 167 kTabStyle.item_size.height() * 2); |
| 168 tab_scroll_view->set_hide_horizontal_scrollbar(true); |
| 169 tab_scroll_view->set_background( |
| 170 views::Background::CreateSolidBackground(bg_color)); |
| 115 | 171 |
| 116 pane_->AddTab( | 172 pane_->AddTab( |
| 117 l10n_util::GetStringUTF16(IDS_DESKTOP_MEDIA_PICKER_SOURCE_TYPE_TAB), | 173 l10n_util::GetStringUTF16(IDS_DESKTOP_MEDIA_PICKER_SOURCE_TYPE_TAB), |
| 118 tab_scroll_view); | 174 tab_scroll_view); |
| 119 pane_->set_listener(this); | 175 pane_->set_listener(this); |
| 120 } | 176 } |
| 121 | 177 |
| 122 if (app_name == target_name) { | 178 if (app_name == target_name) { |
| 123 description_label_->SetText( | 179 description_label_->SetText( |
| 124 l10n_util::GetStringFUTF16(IDS_DESKTOP_MEDIA_PICKER_TEXT, app_name)); | 180 l10n_util::GetStringFUTF16(IDS_DESKTOP_MEDIA_PICKER_TEXT, app_name)); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 135 l10n_util::GetStringUTF16(IDS_DESKTOP_MEDIA_PICKER_AUDIO_SHARE)); | 191 l10n_util::GetStringUTF16(IDS_DESKTOP_MEDIA_PICKER_AUDIO_SHARE)); |
| 136 audio_share_checkbox_->SetChecked(true); | 192 audio_share_checkbox_->SetChecked(true); |
| 137 } | 193 } |
| 138 | 194 |
| 139 // Focus on the first non-null media_list. | 195 // Focus on the first non-null media_list. |
| 140 SwitchSourceType(0); | 196 SwitchSourceType(0); |
| 141 | 197 |
| 142 // If |parent_web_contents| is set and it's not a background page then the | 198 // If |parent_web_contents| is set and it's not a background page then the |
| 143 // picker will be shown modal to the web contents. Otherwise the picker is | 199 // picker will be shown modal to the web contents. Otherwise the picker is |
| 144 // shown in a separate window. | 200 // shown in a separate window. |
| 145 views::Widget* widget = NULL; | 201 views::Widget* widget = nullptr; |
| 146 bool modal_dialog = | 202 bool modal_dialog = |
| 147 parent_web_contents && | 203 parent_web_contents && |
| 148 !parent_web_contents->GetDelegate()->IsNeverVisible(parent_web_contents); | 204 !parent_web_contents->GetDelegate()->IsNeverVisible(parent_web_contents); |
| 149 if (modal_dialog) { | 205 if (modal_dialog) { |
| 150 widget = | 206 widget = |
| 151 constrained_window::ShowWebModalDialogViews(this, parent_web_contents); | 207 constrained_window::ShowWebModalDialogViews(this, parent_web_contents); |
| 152 } else { | 208 } else { |
| 153 widget = DialogDelegate::CreateDialogWidget(this, context, NULL); | 209 widget = DialogDelegate::CreateDialogWidget(this, context, nullptr); |
| 154 widget->Show(); | 210 widget->Show(); |
| 155 } | 211 } |
| 156 | 212 |
| 157 // If the picker is not modal to the calling web contents then it is displayed | 213 // If the picker is not modal to the calling web contents then it is displayed |
| 158 // in its own top-level window, so in that case it needs to be filtered out of | 214 // in its own top-level window, so in that case it needs to be filtered out of |
| 159 // the list of top-level windows available for capture, and to achieve that | 215 // the list of top-level windows available for capture, and to achieve that |
| 160 // the Id is passed to DesktopMediaList. | 216 // the Id is passed to DesktopMediaList. |
| 161 DesktopMediaID dialog_window_id; | 217 DesktopMediaID dialog_window_id; |
| 162 if (!modal_dialog) { | 218 if (!modal_dialog) { |
| 163 dialog_window_id = DesktopMediaID::RegisterAuraWindow( | 219 dialog_window_id = DesktopMediaID::RegisterAuraWindow( |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 audio_share_checkbox_->SetVisible(true); | 255 audio_share_checkbox_->SetVisible(true); |
| 200 break; | 256 break; |
| 201 case DesktopMediaID::TYPE_NONE: | 257 case DesktopMediaID::TYPE_NONE: |
| 202 NOTREACHED(); | 258 NOTREACHED(); |
| 203 break; | 259 break; |
| 204 } | 260 } |
| 205 } | 261 } |
| 206 } | 262 } |
| 207 | 263 |
| 208 void DesktopMediaPickerDialogView::DetachParent() { | 264 void DesktopMediaPickerDialogView::DetachParent() { |
| 209 parent_ = NULL; | 265 parent_ = nullptr; |
| 210 } | 266 } |
| 211 | 267 |
| 212 gfx::Size DesktopMediaPickerDialogView::GetPreferredSize() const { | 268 gfx::Size DesktopMediaPickerDialogView::GetPreferredSize() const { |
| 213 static const size_t kDialogViewWidth = 600; | 269 static const size_t kDialogViewWidth = 600; |
| 214 return gfx::Size(kDialogViewWidth, GetHeightForWidth(kDialogViewWidth)); | 270 return gfx::Size(kDialogViewWidth, GetHeightForWidth(kDialogViewWidth)); |
| 215 } | 271 } |
| 216 | 272 |
| 217 ui::ModalType DesktopMediaPickerDialogView::GetModalType() const { | 273 ui::ModalType DesktopMediaPickerDialogView::GetModalType() const { |
| 218 return ui::MODAL_TYPE_CHILD; | 274 return ui::MODAL_TYPE_CHILD; |
| 219 } | 275 } |
| 220 | 276 |
| 221 base::string16 DesktopMediaPickerDialogView::GetWindowTitle() const { | 277 base::string16 DesktopMediaPickerDialogView::GetWindowTitle() const { |
| 222 return l10n_util::GetStringUTF16(IDS_DESKTOP_MEDIA_PICKER_TITLE); | 278 return l10n_util::GetStringUTF16(IDS_DESKTOP_MEDIA_PICKER_TITLE); |
| 223 } | 279 } |
| 224 | 280 |
| 225 bool DesktopMediaPickerDialogView::IsDialogButtonEnabled( | 281 bool DesktopMediaPickerDialogView::IsDialogButtonEnabled( |
| 226 ui::DialogButton button) const { | 282 ui::DialogButton button) const { |
| 227 if (button == ui::DIALOG_BUTTON_OK) | 283 if (button == ui::DIALOG_BUTTON_OK) |
| 228 return list_views_[pane_->selected_tab_index()]->GetSelection() != NULL; | 284 return list_views_[pane_->selected_tab_index()]->GetSelection() != nullptr; |
| 229 return true; | 285 return true; |
| 230 } | 286 } |
| 231 | 287 |
| 232 views::View* DesktopMediaPickerDialogView::GetInitiallyFocusedView() { | 288 views::View* DesktopMediaPickerDialogView::GetInitiallyFocusedView() { |
| 233 return list_views_[0]; | 289 return list_views_[0]; |
| 234 } | 290 } |
| 235 | 291 |
| 236 base::string16 DesktopMediaPickerDialogView::GetDialogButtonLabel( | 292 base::string16 DesktopMediaPickerDialogView::GetDialogButtonLabel( |
| 237 ui::DialogButton button) const { | 293 ui::DialogButton button) const { |
| 238 return l10n_util::GetStringUTF16(button == ui::DIALOG_BUTTON_OK | 294 return l10n_util::GetStringUTF16(button == ui::DIALOG_BUTTON_OK |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 } | 358 } |
| 303 | 359 |
| 304 DesktopMediaListView* DesktopMediaPickerDialogView::GetMediaListViewForTesting() | 360 DesktopMediaListView* DesktopMediaPickerDialogView::GetMediaListViewForTesting() |
| 305 const { | 361 const { |
| 306 return list_views_[pane_->selected_tab_index()]; | 362 return list_views_[pane_->selected_tab_index()]; |
| 307 } | 363 } |
| 308 | 364 |
| 309 DesktopMediaSourceView* | 365 DesktopMediaSourceView* |
| 310 DesktopMediaPickerDialogView::GetMediaSourceViewForTesting(int index) const { | 366 DesktopMediaPickerDialogView::GetMediaSourceViewForTesting(int index) const { |
| 311 if (list_views_[pane_->selected_tab_index()]->child_count() <= index) | 367 if (list_views_[pane_->selected_tab_index()]->child_count() <= index) |
| 312 return NULL; | 368 return nullptr; |
| 313 | 369 |
| 314 return reinterpret_cast<DesktopMediaSourceView*>( | 370 return reinterpret_cast<DesktopMediaSourceView*>( |
| 315 list_views_[pane_->selected_tab_index()]->child_at(index)); | 371 list_views_[pane_->selected_tab_index()]->child_at(index)); |
| 316 } | 372 } |
| 317 | 373 |
| 318 views::Checkbox* DesktopMediaPickerDialogView::GetCheckboxForTesting() const { | 374 views::Checkbox* DesktopMediaPickerDialogView::GetCheckboxForTesting() const { |
| 319 return audio_share_checkbox_; | 375 return audio_share_checkbox_; |
| 320 } | 376 } |
| 321 | 377 |
| 322 int DesktopMediaPickerDialogView::GetIndexOfSourceTypeForTesting( | 378 int DesktopMediaPickerDialogView::GetIndexOfSourceTypeForTesting( |
| 323 DesktopMediaID::Type source_type) const { | 379 DesktopMediaID::Type source_type) const { |
| 324 for (size_t i = 0; i < source_types_.size(); i++) { | 380 for (size_t i = 0; i < source_types_.size(); i++) { |
| 325 if (source_types_[i] == source_type) | 381 if (source_types_[i] == source_type) |
| 326 return i; | 382 return i; |
| 327 } | 383 } |
| 328 return -1; | 384 return -1; |
| 329 } | 385 } |
| 330 | 386 |
| 331 views::TabbedPane* DesktopMediaPickerDialogView::GetPaneForTesting() const { | 387 views::TabbedPane* DesktopMediaPickerDialogView::GetPaneForTesting() const { |
| 332 return pane_; | 388 return pane_; |
| 333 } | 389 } |
| 334 | 390 |
| 335 DesktopMediaPickerViews::DesktopMediaPickerViews() : dialog_(NULL) {} | 391 DesktopMediaPickerViews::DesktopMediaPickerViews() : dialog_(nullptr) {} |
| 336 | 392 |
| 337 DesktopMediaPickerViews::~DesktopMediaPickerViews() { | 393 DesktopMediaPickerViews::~DesktopMediaPickerViews() { |
| 338 if (dialog_) { | 394 if (dialog_) { |
| 339 dialog_->DetachParent(); | 395 dialog_->DetachParent(); |
| 340 dialog_->GetWidget()->Close(); | 396 dialog_->GetWidget()->Close(); |
| 341 } | 397 } |
| 342 } | 398 } |
| 343 | 399 |
| 344 void DesktopMediaPickerViews::Show( | 400 void DesktopMediaPickerViews::Show( |
| 345 content::WebContents* web_contents, | 401 content::WebContents* web_contents, |
| 346 gfx::NativeWindow context, | 402 gfx::NativeWindow context, |
| 347 gfx::NativeWindow parent, | 403 gfx::NativeWindow parent, |
| 348 const base::string16& app_name, | 404 const base::string16& app_name, |
| 349 const base::string16& target_name, | 405 const base::string16& target_name, |
| 350 std::unique_ptr<DesktopMediaList> screen_list, | 406 std::unique_ptr<DesktopMediaList> screen_list, |
| 351 std::unique_ptr<DesktopMediaList> window_list, | 407 std::unique_ptr<DesktopMediaList> window_list, |
| 352 std::unique_ptr<DesktopMediaList> tab_list, | 408 std::unique_ptr<DesktopMediaList> tab_list, |
| 353 bool request_audio, | 409 bool request_audio, |
| 354 const DoneCallback& done_callback) { | 410 const DoneCallback& done_callback) { |
| 355 callback_ = done_callback; | 411 callback_ = done_callback; |
| 356 dialog_ = new DesktopMediaPickerDialogView( | 412 dialog_ = new DesktopMediaPickerDialogView( |
| 357 web_contents, context, this, app_name, target_name, | 413 web_contents, context, this, app_name, target_name, |
| 358 std::move(screen_list), std::move(window_list), std::move(tab_list), | 414 std::move(screen_list), std::move(window_list), std::move(tab_list), |
| 359 request_audio); | 415 request_audio); |
| 360 } | 416 } |
| 361 | 417 |
| 362 void DesktopMediaPickerViews::NotifyDialogResult(DesktopMediaID source) { | 418 void DesktopMediaPickerViews::NotifyDialogResult(DesktopMediaID source) { |
| 363 // Once this method is called the |dialog_| will close and destroy itself. | 419 // Once this method is called the |dialog_| will close and destroy itself. |
| 364 dialog_->DetachParent(); | 420 dialog_->DetachParent(); |
| 365 dialog_ = NULL; | 421 dialog_ = nullptr; |
| 366 | 422 |
| 367 DCHECK(!callback_.is_null()); | 423 DCHECK(!callback_.is_null()); |
| 368 | 424 |
| 369 // Notify the |callback_| asynchronously because it may need to destroy | 425 // Notify the |callback_| asynchronously because it may need to destroy |
| 370 // DesktopMediaPicker. | 426 // DesktopMediaPicker. |
| 371 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, | 427 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, |
| 372 base::Bind(callback_, source)); | 428 base::Bind(callback_, source)); |
| 373 callback_.Reset(); | 429 callback_.Reset(); |
| 374 } | 430 } |
| 375 | 431 |
| 376 // static | 432 // static |
| 377 std::unique_ptr<DesktopMediaPicker> DesktopMediaPicker::Create() { | 433 std::unique_ptr<DesktopMediaPicker> DesktopMediaPicker::Create() { |
| 378 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | 434 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 379 extensions::switches::kDisableDesktopCapturePickerOldUI)) { | 435 extensions::switches::kDisableDesktopCapturePickerOldUI)) { |
| 380 return std::unique_ptr<DesktopMediaPicker>( | 436 return std::unique_ptr<DesktopMediaPicker>( |
| 381 new deprecated::DesktopMediaPickerViews()); | 437 new deprecated::DesktopMediaPickerViews()); |
| 382 } | 438 } |
| 383 return std::unique_ptr<DesktopMediaPicker>(new DesktopMediaPickerViews()); | 439 return std::unique_ptr<DesktopMediaPicker>(new DesktopMediaPickerViews()); |
| 384 } | 440 } |
| OLD | NEW |