| 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/webrtc/desktop_media_list.h" | 9 #include "chrome/browser/media/webrtc/desktop_media_list.h" |
| 10 #include "chrome/browser/ui/browser_finder.h" | 10 #include "chrome/browser/ui/browser_finder.h" |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 return ui::MODAL_TYPE_CHILD; | 283 return ui::MODAL_TYPE_CHILD; |
| 284 } | 284 } |
| 285 | 285 |
| 286 base::string16 DesktopMediaPickerDialogView::GetWindowTitle() const { | 286 base::string16 DesktopMediaPickerDialogView::GetWindowTitle() const { |
| 287 return l10n_util::GetStringUTF16(IDS_DESKTOP_MEDIA_PICKER_TITLE); | 287 return l10n_util::GetStringUTF16(IDS_DESKTOP_MEDIA_PICKER_TITLE); |
| 288 } | 288 } |
| 289 | 289 |
| 290 bool DesktopMediaPickerDialogView::IsDialogButtonEnabled( | 290 bool DesktopMediaPickerDialogView::IsDialogButtonEnabled( |
| 291 ui::DialogButton button) const { | 291 ui::DialogButton button) const { |
| 292 if (button == ui::DIALOG_BUTTON_OK) | 292 if (button == ui::DIALOG_BUTTON_OK) |
| 293 return list_views_[pane_->selected_tab_index()]->GetSelection() != nullptr; | 293 return list_views_[pane_->GetSelectedTabIndex()]->GetSelection() != nullptr; |
| 294 return true; | 294 return true; |
| 295 } | 295 } |
| 296 | 296 |
| 297 views::View* DesktopMediaPickerDialogView::GetInitiallyFocusedView() { | 297 views::View* DesktopMediaPickerDialogView::GetInitiallyFocusedView() { |
| 298 return list_views_[0]; | 298 return list_views_[0]; |
| 299 } | 299 } |
| 300 | 300 |
| 301 base::string16 DesktopMediaPickerDialogView::GetDialogButtonLabel( | 301 base::string16 DesktopMediaPickerDialogView::GetDialogButtonLabel( |
| 302 ui::DialogButton button) const { | 302 ui::DialogButton button) const { |
| 303 return l10n_util::GetStringUTF16(button == ui::DIALOG_BUTTON_OK | 303 return l10n_util::GetStringUTF16(button == ui::DIALOG_BUTTON_OK |
| 304 ? IDS_DESKTOP_MEDIA_PICKER_SHARE | 304 ? IDS_DESKTOP_MEDIA_PICKER_SHARE |
| 305 : IDS_CANCEL); | 305 : IDS_CANCEL); |
| 306 } | 306 } |
| 307 | 307 |
| 308 bool DesktopMediaPickerDialogView::ShouldDefaultButtonBeBlue() const { | 308 bool DesktopMediaPickerDialogView::ShouldDefaultButtonBeBlue() const { |
| 309 return true; | 309 return true; |
| 310 } | 310 } |
| 311 | 311 |
| 312 views::View* DesktopMediaPickerDialogView::CreateExtraView() { | 312 views::View* DesktopMediaPickerDialogView::CreateExtraView() { |
| 313 return audio_share_checkbox_; | 313 return audio_share_checkbox_; |
| 314 } | 314 } |
| 315 | 315 |
| 316 bool DesktopMediaPickerDialogView::Accept() { | 316 bool DesktopMediaPickerDialogView::Accept() { |
| 317 DesktopMediaSourceView* selection = | 317 DesktopMediaSourceView* selection = |
| 318 list_views_[pane_->selected_tab_index()]->GetSelection(); | 318 list_views_[pane_->GetSelectedTabIndex()]->GetSelection(); |
| 319 | 319 |
| 320 // Ok button should only be enabled when a source is selected. | 320 // Ok button should only be enabled when a source is selected. |
| 321 DCHECK(selection); | 321 DCHECK(selection); |
| 322 DesktopMediaID source = selection->source_id(); | 322 DesktopMediaID source = selection->source_id(); |
| 323 source.audio_share = audio_share_checkbox_ && | 323 source.audio_share = audio_share_checkbox_ && |
| 324 audio_share_checkbox_->visible() && | 324 audio_share_checkbox_->visible() && |
| 325 audio_share_checkbox_->checked(); | 325 audio_share_checkbox_->checked(); |
| 326 | 326 |
| 327 if (source.type == DesktopMediaID::TYPE_WEB_CONTENTS) { | 327 if (source.type == DesktopMediaID::TYPE_WEB_CONTENTS) { |
| 328 // Activate the selected tab and bring the browser window for the selected | 328 // Activate the selected tab and bring the browser window for the selected |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 gfx::Rect widget_bound = GetWidget()->GetWindowBoundsInScreen(); | 366 gfx::Rect widget_bound = GetWidget()->GetWindowBoundsInScreen(); |
| 367 | 367 |
| 368 int new_height = widget_bound.height() - pane_->height() + | 368 int new_height = widget_bound.height() - pane_->height() + |
| 369 pane_->GetPreferredSize().height(); | 369 pane_->GetPreferredSize().height(); |
| 370 | 370 |
| 371 GetWidget()->CenterWindow(gfx::Size(widget_bound.width(), new_height)); | 371 GetWidget()->CenterWindow(gfx::Size(widget_bound.width(), new_height)); |
| 372 } | 372 } |
| 373 | 373 |
| 374 DesktopMediaListView* DesktopMediaPickerDialogView::GetMediaListViewForTesting() | 374 DesktopMediaListView* DesktopMediaPickerDialogView::GetMediaListViewForTesting() |
| 375 const { | 375 const { |
| 376 return list_views_[pane_->selected_tab_index()]; | 376 return list_views_[pane_->GetSelectedTabIndex()]; |
| 377 } | 377 } |
| 378 | 378 |
| 379 DesktopMediaSourceView* | 379 DesktopMediaSourceView* |
| 380 DesktopMediaPickerDialogView::GetMediaSourceViewForTesting(int index) const { | 380 DesktopMediaPickerDialogView::GetMediaSourceViewForTesting(int index) const { |
| 381 if (list_views_[pane_->selected_tab_index()]->child_count() <= index) | 381 if (list_views_[pane_->GetSelectedTabIndex()]->child_count() <= index) |
| 382 return nullptr; | 382 return nullptr; |
| 383 | 383 |
| 384 return reinterpret_cast<DesktopMediaSourceView*>( | 384 return reinterpret_cast<DesktopMediaSourceView*>( |
| 385 list_views_[pane_->selected_tab_index()]->child_at(index)); | 385 list_views_[pane_->GetSelectedTabIndex()]->child_at(index)); |
| 386 } | 386 } |
| 387 | 387 |
| 388 views::Checkbox* DesktopMediaPickerDialogView::GetCheckboxForTesting() const { | 388 views::Checkbox* DesktopMediaPickerDialogView::GetCheckboxForTesting() const { |
| 389 return audio_share_checkbox_; | 389 return audio_share_checkbox_; |
| 390 } | 390 } |
| 391 | 391 |
| 392 int DesktopMediaPickerDialogView::GetIndexOfSourceTypeForTesting( | 392 int DesktopMediaPickerDialogView::GetIndexOfSourceTypeForTesting( |
| 393 DesktopMediaID::Type source_type) const { | 393 DesktopMediaID::Type source_type) const { |
| 394 for (size_t i = 0; i < source_types_.size(); i++) { | 394 for (size_t i = 0; i < source_types_.size(); i++) { |
| 395 if (source_types_[i] == source_type) | 395 if (source_types_[i] == source_type) |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 445 | 445 |
| 446 // static | 446 // static |
| 447 std::unique_ptr<DesktopMediaPicker> DesktopMediaPicker::Create() { | 447 std::unique_ptr<DesktopMediaPicker> DesktopMediaPicker::Create() { |
| 448 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 448 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 449 extensions::switches::kDisableDesktopCapturePickerNewUI)) { | 449 extensions::switches::kDisableDesktopCapturePickerNewUI)) { |
| 450 return std::unique_ptr<DesktopMediaPicker>( | 450 return std::unique_ptr<DesktopMediaPicker>( |
| 451 new deprecated::DesktopMediaPickerViews()); | 451 new deprecated::DesktopMediaPickerViews()); |
| 452 } | 452 } |
| 453 return std::unique_ptr<DesktopMediaPicker>(new DesktopMediaPickerViews()); | 453 return std::unique_ptr<DesktopMediaPicker>(new DesktopMediaPickerViews()); |
| 454 } | 454 } |
| OLD | NEW |