| 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 2614f56088103a2849e8d0ee12042d020ab0c801..c25113269666246d927a05a0d28cb06e1b794849 100644
|
| --- a/chrome/browser/ui/views/desktop_media_picker_views.cc
|
| +++ b/chrome/browser/ui/views/desktop_media_picker_views.cc
|
| @@ -11,14 +11,19 @@
|
| #include "base/command_line.h"
|
| #include "base/strings/utf_string_conversions.h"
|
| #include "build/build_config.h"
|
| +#include "chrome/browser/content_settings/host_content_settings_map_factory.h"
|
| #include "chrome/browser/media/desktop_media_list.h"
|
| +#include "chrome/browser/profiles/profile.h"
|
| #include "chrome/browser/ui/ash/ash_util.h"
|
| #include "chrome/common/chrome_switches.h"
|
| #include "chrome/grit/generated_resources.h"
|
| #include "components/constrained_window/constrained_window_views.h"
|
| +#include "components/content_settings/core/browser/host_content_settings_map.h"
|
| +#include "components/content_settings/core/common/content_settings.h"
|
| #include "components/web_modal/web_contents_modal_dialog_manager.h"
|
| #include "content/public/browser/browser_thread.h"
|
| #include "content/public/browser/web_contents_delegate.h"
|
| +#include "content/public/common/content_switches.h"
|
| #include "grit/components_strings.h"
|
| #include "ui/aura/window_tree_host.h"
|
| #include "ui/base/l10n/l10n_util.h"
|
| @@ -28,6 +33,7 @@
|
| #include "ui/native_theme/native_theme.h"
|
| #include "ui/views/background.h"
|
| #include "ui/views/bubble/bubble_frame_view.h"
|
| +#include "ui/views/controls/button/checkbox.h"
|
| #include "ui/views/controls/image_view.h"
|
| #include "ui/views/controls/label.h"
|
| #include "ui/views/controls/scroll_view.h"
|
| @@ -390,6 +396,7 @@ DesktopMediaPickerDialogView::DesktopMediaPickerDialogView(
|
| const base::string16& target_name,
|
| scoped_ptr<DesktopMediaList> media_list)
|
| : parent_(parent),
|
| + parent_web_contents_(parent_web_contents),
|
| app_name_(app_name),
|
| label_(new views::Label()),
|
| scroll_view_(views::ScrollView::CreateScrollViewWithBorder()),
|
| @@ -405,6 +412,30 @@ DesktopMediaPickerDialogView::DesktopMediaPickerDialogView(
|
| label_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
|
| AddChildView(label_);
|
|
|
| + audio_support_ = base::CommandLine::ForCurrentProcess()->HasSwitch(
|
| + switches::kEnableAudioSupportForDesktopShare);
|
| +
|
| + if (audio_support_) {
|
| + checkbox_ = new views::Checkbox(
|
| + l10n_util::GetStringUTF16(IDS_DESKTOP_MEDIA_PICKER_ALLOW_AUDIO));
|
| + checkbox_->SetElideBehavior(gfx::ELIDE_MIDDLE);
|
| + AddChildView(checkbox_);
|
| +
|
| + Profile* profile =
|
| + Profile::FromBrowserContext(parent_web_contents_->GetBrowserContext());
|
| +
|
| + const GURL origin(parent_web_contents->GetLastCommittedURL().GetOrigin());
|
| +
|
| + ContentSetting result =
|
| + HostContentSettingsMapFactory::GetForProfile(profile)
|
| + ->GetContentSetting(
|
| + origin, origin,
|
| + ContentSettingsType::CONTENT_SETTINGS_TYPE_DESKTOP_AUDIO_SHARE,
|
| + std::string());
|
| +
|
| + checkbox_->SetChecked(result == ContentSetting::CONTENT_SETTING_ALLOW);
|
| + }
|
| +
|
| scroll_view_->SetContents(list_view_);
|
| scroll_view_->ClipHeightTo(
|
| GetMediaListViewHeightForRows(1), GetMediaListViewHeightForRows(2));
|
| @@ -461,9 +492,12 @@ gfx::Size DesktopMediaPickerDialogView::GetPreferredSize() const {
|
| size_t label_height =
|
| label_->GetHeightForWidth(kDialogViewWidth - title_insets.height() * 2);
|
|
|
| + size_t checkbox_height =
|
| + audio_support_ ? checkbox_->GetPreferredSize().height() : 0;
|
| +
|
| return gfx::Size(kDialogViewWidth,
|
| views::kPanelVertMargin * 2 + label_height +
|
| - views::kPanelVerticalSpacing +
|
| + checkbox_height + views::kPanelVerticalSpacing +
|
| scroll_view_->GetPreferredSize().height());
|
| }
|
|
|
| @@ -478,6 +512,14 @@ void DesktopMediaPickerDialogView::Layout() {
|
| label_->GetHeightForWidth(rect.width()));
|
| label_->SetBoundsRect(label_rect);
|
|
|
| + if (audio_support_) {
|
| + gfx::Rect checkbox_rect(rect.x(),
|
| + label_rect.bottom() + views::kPanelVertMargin,
|
| + checkbox_->GetPreferredSize().width(),
|
| + checkbox_->GetPreferredSize().height());
|
| + checkbox_->SetBoundsRect(checkbox_rect);
|
| + }
|
| +
|
| int scroll_view_top = label_rect.bottom() + views::kPanelVerticalSpacing;
|
| scroll_view_->SetBounds(
|
| rect.x(), scroll_view_top,
|
| @@ -519,6 +561,25 @@ bool DesktopMediaPickerDialogView::Accept() {
|
| if (selection)
|
| source = selection->source_id();
|
|
|
| + if (audio_support_) {
|
| + Profile* profile =
|
| + Profile::FromBrowserContext(parent_web_contents_->GetBrowserContext());
|
| +
|
| + GURL origin(parent_web_contents_->GetLastCommittedURL().GetOrigin());
|
| +
|
| + ContentSettingsPattern pattern =
|
| + ContentSettingsPattern::FromURLNoWildcard(origin);
|
| +
|
| + ContentSetting result = checkbox_->checked()
|
| + ? ContentSetting::CONTENT_SETTING_ALLOW
|
| + : ContentSetting::CONTENT_SETTING_BLOCK;
|
| +
|
| + HostContentSettingsMapFactory::GetForProfile(profile)->SetContentSetting(
|
| + pattern, pattern,
|
| + ContentSettingsType::CONTENT_SETTINGS_TYPE_DESKTOP_AUDIO_SHARE,
|
| + std::string(), result);
|
| + }
|
| +
|
| if (parent_)
|
| parent_->NotifyDialogResult(source);
|
|
|
|
|