| 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/combined_desktop_media_list.h" | 14 #include "chrome/browser/media/combined_desktop_media_list.h" |
| 15 #include "chrome/browser/media/desktop_media_list.h" | 15 #include "chrome/browser/media/desktop_media_list.h" |
| 16 #include "chrome/browser/ui/ash/ash_util.h" | |
| 17 #include "chrome/common/chrome_switches.h" | 16 #include "chrome/common/chrome_switches.h" |
| 18 #include "chrome/grit/generated_resources.h" | 17 #include "chrome/grit/generated_resources.h" |
| 19 #include "components/constrained_window/constrained_window_views.h" | 18 #include "components/constrained_window/constrained_window_views.h" |
| 20 #include "components/web_modal/web_contents_modal_dialog_manager.h" | 19 #include "components/web_modal/web_contents_modal_dialog_manager.h" |
| 21 #include "content/public/browser/browser_thread.h" | 20 #include "content/public/browser/browser_thread.h" |
| 22 #include "content/public/browser/render_frame_host.h" | 21 #include "content/public/browser/render_frame_host.h" |
| 23 #include "content/public/browser/web_contents_delegate.h" | 22 #include "content/public/browser/web_contents_delegate.h" |
| 24 #include "grit/components_strings.h" | 23 #include "grit/components_strings.h" |
| 25 #include "ui/aura/window_tree_host.h" | 24 #include "ui/aura/window_tree_host.h" |
| 26 #include "ui/base/l10n/l10n_util.h" | 25 #include "ui/base/l10n/l10n_util.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 52 const int kListItemHeight = | 51 const int kListItemHeight = |
| 53 kThumbnailMargin * 2 + kThumbnailHeight + kLabelHeight; | 52 kThumbnailMargin * 2 + kThumbnailHeight + kLabelHeight; |
| 54 const int kListColumns = 3; | 53 const int kListColumns = 3; |
| 55 const int kTotalListWidth = kListColumns * kListItemWidth; | 54 const int kTotalListWidth = kListColumns * kListItemWidth; |
| 56 | 55 |
| 57 const int kDesktopMediaSourceViewGroupId = 1; | 56 const int kDesktopMediaSourceViewGroupId = 1; |
| 58 | 57 |
| 59 const char kDesktopMediaSourceViewClassName[] = | 58 const char kDesktopMediaSourceViewClassName[] = |
| 60 "DesktopMediaPicker_DesktopMediaSourceView"; | 59 "DesktopMediaPicker_DesktopMediaSourceView"; |
| 61 | 60 |
| 61 #if !defined(USE_ASH) |
| 62 DesktopMediaID::Id AcceleratedWidgetToDesktopMediaId( | 62 DesktopMediaID::Id AcceleratedWidgetToDesktopMediaId( |
| 63 gfx::AcceleratedWidget accelerated_widget) { | 63 gfx::AcceleratedWidget accelerated_widget) { |
| 64 #if defined(OS_WIN) | 64 #if defined(OS_WIN) |
| 65 return reinterpret_cast<DesktopMediaID::Id>(accelerated_widget); | 65 return reinterpret_cast<DesktopMediaID::Id>(accelerated_widget); |
| 66 #else | 66 #else |
| 67 return static_cast<DesktopMediaID::Id>(accelerated_widget); | 67 return static_cast<DesktopMediaID::Id>(accelerated_widget); |
| 68 #endif | 68 #endif |
| 69 } | 69 } |
| 70 #endif |
| 70 | 71 |
| 71 int GetMediaListViewHeightForRows(size_t rows) { | 72 int GetMediaListViewHeightForRows(size_t rows) { |
| 72 return kListItemHeight * rows; | 73 return kListItemHeight * rows; |
| 73 } | 74 } |
| 74 | 75 |
| 75 } // namespace | 76 } // namespace |
| 76 | 77 |
| 77 DesktopMediaSourceView::DesktopMediaSourceView( | 78 DesktopMediaSourceView::DesktopMediaSourceView( |
| 78 DesktopMediaListView* parent, | 79 DesktopMediaListView* parent, |
| 79 DesktopMediaID source_id) | 80 DesktopMediaID source_id) |
| (...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 | 472 |
| 472 // If the picker is not modal to the calling web contents then it is displayed | 473 // If the picker is not modal to the calling web contents then it is displayed |
| 473 // in its own top-level window, so in that case it needs to be filtered out of | 474 // in its own top-level window, so in that case it needs to be filtered out of |
| 474 // the list of top-level windows available for capture, and to achieve that | 475 // the list of top-level windows available for capture, and to achieve that |
| 475 // the Id is passed to DesktopMediaList. | 476 // the Id is passed to DesktopMediaList. |
| 476 DesktopMediaID dialog_window_id; | 477 DesktopMediaID dialog_window_id; |
| 477 if (!modal_dialog) { | 478 if (!modal_dialog) { |
| 478 dialog_window_id = DesktopMediaID::RegisterAuraWindow( | 479 dialog_window_id = DesktopMediaID::RegisterAuraWindow( |
| 479 DesktopMediaID::TYPE_WINDOW, widget->GetNativeWindow()); | 480 DesktopMediaID::TYPE_WINDOW, widget->GetNativeWindow()); |
| 480 | 481 |
| 481 bool is_ash_window = false; | 482 // Set native window ID if the windows is outside Ash. |
| 482 #if defined(USE_ASH) | 483 #if !defined(USE_ASH) |
| 483 is_ash_window = chrome::IsNativeWindowInAsh(widget->GetNativeWindow()); | 484 dialog_window_id.id = AcceleratedWidgetToDesktopMediaId( |
| 485 widget->GetNativeWindow()->GetHost()->GetAcceleratedWidget()); |
| 484 #endif | 486 #endif |
| 485 | |
| 486 // Set native window ID if the windows is outside Ash. | |
| 487 if (!is_ash_window) { | |
| 488 dialog_window_id.id = AcceleratedWidgetToDesktopMediaId( | |
| 489 widget->GetNativeWindow()->GetHost()->GetAcceleratedWidget()); | |
| 490 } | |
| 491 } | 487 } |
| 492 | 488 |
| 493 sources_list_view_->StartUpdating(dialog_window_id); | 489 sources_list_view_->StartUpdating(dialog_window_id); |
| 494 } | 490 } |
| 495 | 491 |
| 496 DesktopMediaPickerDialogView::~DesktopMediaPickerDialogView() {} | 492 DesktopMediaPickerDialogView::~DesktopMediaPickerDialogView() {} |
| 497 | 493 |
| 498 void DesktopMediaPickerDialogView::DetachParent() { | 494 void DesktopMediaPickerDialogView::DetachParent() { |
| 499 parent_ = NULL; | 495 parent_ = NULL; |
| 500 } | 496 } |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 663 content::BrowserThread::PostTask( | 659 content::BrowserThread::PostTask( |
| 664 content::BrowserThread::UI, FROM_HERE, | 660 content::BrowserThread::UI, FROM_HERE, |
| 665 base::Bind(callback_, source)); | 661 base::Bind(callback_, source)); |
| 666 callback_.Reset(); | 662 callback_.Reset(); |
| 667 } | 663 } |
| 668 | 664 |
| 669 // static | 665 // static |
| 670 std::unique_ptr<DesktopMediaPicker> DesktopMediaPicker::Create() { | 666 std::unique_ptr<DesktopMediaPicker> DesktopMediaPicker::Create() { |
| 671 return std::unique_ptr<DesktopMediaPicker>(new DesktopMediaPickerViews()); | 667 return std::unique_ptr<DesktopMediaPicker>(new DesktopMediaPickerViews()); |
| 672 } | 668 } |
| OLD | NEW |