| 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 #include <utility> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
| 14 #include "chrome/browser/media/desktop_media_list.h" | 14 #include "chrome/browser/media/desktop_media_list.h" |
| 15 #include "chrome/browser/ui/ash/ash_util.h" | 15 #include "chrome/browser/ui/ash/ash_util.h" |
| 16 #include "chrome/common/chrome_switches.h" | 16 #include "chrome/common/chrome_switches.h" |
| 17 #include "chrome/grit/generated_resources.h" | 17 #include "chrome/grit/generated_resources.h" |
| 18 #include "components/constrained_window/constrained_window_views.h" | 18 #include "components/constrained_window/constrained_window_views.h" |
| 19 #include "components/web_modal/web_contents_modal_dialog_manager.h" | 19 #include "components/web_modal/web_contents_modal_dialog_manager.h" |
| 20 #include "content/public/browser/browser_thread.h" | 20 #include "content/public/browser/browser_thread.h" |
| 21 #include "content/public/browser/render_frame_host.h" |
| 21 #include "content/public/browser/web_contents_delegate.h" | 22 #include "content/public/browser/web_contents_delegate.h" |
| 22 #include "grit/components_strings.h" | 23 #include "grit/components_strings.h" |
| 23 #include "ui/aura/window_tree_host.h" | 24 #include "ui/aura/window_tree_host.h" |
| 24 #include "ui/base/l10n/l10n_util.h" | 25 #include "ui/base/l10n/l10n_util.h" |
| 25 #include "ui/events/event_constants.h" | 26 #include "ui/events/event_constants.h" |
| 26 #include "ui/events/keycodes/keyboard_codes.h" | 27 #include "ui/events/keycodes/keyboard_codes.h" |
| 27 #include "ui/gfx/canvas.h" | 28 #include "ui/gfx/canvas.h" |
| 28 #include "ui/native_theme/native_theme.h" | 29 #include "ui/native_theme/native_theme.h" |
| 29 #include "ui/views/background.h" | 30 #include "ui/views/background.h" |
| 30 #include "ui/views/bubble/bubble_frame_view.h" | 31 #include "ui/views/bubble/bubble_frame_view.h" |
| (...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 507 ui::DialogButton button) const { | 508 ui::DialogButton button) const { |
| 508 return l10n_util::GetStringUTF16(button == ui::DIALOG_BUTTON_OK ? | 509 return l10n_util::GetStringUTF16(button == ui::DIALOG_BUTTON_OK ? |
| 509 IDS_DESKTOP_MEDIA_PICKER_SHARE : IDS_CANCEL); | 510 IDS_DESKTOP_MEDIA_PICKER_SHARE : IDS_CANCEL); |
| 510 } | 511 } |
| 511 | 512 |
| 512 bool DesktopMediaPickerDialogView::Accept() { | 513 bool DesktopMediaPickerDialogView::Accept() { |
| 513 DesktopMediaSourceView* selection = sources_list_view_->GetSelection(); | 514 DesktopMediaSourceView* selection = sources_list_view_->GetSelection(); |
| 514 | 515 |
| 515 // Ok button should only be enabled when a source is selected. | 516 // Ok button should only be enabled when a source is selected. |
| 516 DCHECK(selection); | 517 DCHECK(selection); |
| 517 | 518 DesktopMediaID source = selection->source_id(); |
| 518 DesktopMediaID source; | |
| 519 if (selection) | |
| 520 source = selection->source_id(); | |
| 521 | |
| 522 source.audio_share = audio_share_checkbox_ && | 519 source.audio_share = audio_share_checkbox_ && |
| 523 audio_share_checkbox_->enabled() && | 520 audio_share_checkbox_->enabled() && |
| 524 audio_share_checkbox_->checked(); | 521 audio_share_checkbox_->checked(); |
| 525 | 522 |
| 523 // If the media source is an tab, activate it. |
| 524 if (source.type == DesktopMediaID::TYPE_WEB_CONTENTS) { |
| 525 content::WebContents* tab = content::WebContents::FromRenderFrameHost( |
| 526 content::RenderFrameHost::FromID( |
| 527 source.web_contents_id.render_process_id, |
| 528 source.web_contents_id.main_render_frame_id)); |
| 529 if (tab) |
| 530 tab->GetDelegate()->ActivateContents(tab); |
| 531 } |
| 532 |
| 526 if (parent_) | 533 if (parent_) |
| 527 parent_->NotifyDialogResult(source); | 534 parent_->NotifyDialogResult(source); |
| 528 | 535 |
| 529 // Return true to close the window. | 536 // Return true to close the window. |
| 530 return true; | 537 return true; |
| 531 } | 538 } |
| 532 | 539 |
| 533 void DesktopMediaPickerDialogView::DeleteDelegate() { | 540 void DesktopMediaPickerDialogView::DeleteDelegate() { |
| 534 // If the dialog is being closed then notify the parent about it. | 541 // If the dialog is being closed then notify the parent about it. |
| 535 if (parent_) | 542 if (parent_) |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 626 content::BrowserThread::PostTask( | 633 content::BrowserThread::PostTask( |
| 627 content::BrowserThread::UI, FROM_HERE, | 634 content::BrowserThread::UI, FROM_HERE, |
| 628 base::Bind(callback_, source)); | 635 base::Bind(callback_, source)); |
| 629 callback_.Reset(); | 636 callback_.Reset(); |
| 630 } | 637 } |
| 631 | 638 |
| 632 // static | 639 // static |
| 633 scoped_ptr<DesktopMediaPicker> DesktopMediaPicker::Create() { | 640 scoped_ptr<DesktopMediaPicker> DesktopMediaPicker::Create() { |
| 634 return scoped_ptr<DesktopMediaPicker>(new DesktopMediaPickerViews()); | 641 return scoped_ptr<DesktopMediaPicker>(new DesktopMediaPickerViews()); |
| 635 } | 642 } |
| OLD | NEW |