From 85ce71fd37de5c52cd536a17a94db6d2fbead34d Mon Sep 17 00:00:00 2001 From: qiangchen Date: Fri, 1 Apr 2016 12:10:01 -0700 Subject: [PATCH] Bring Audio Share and Tab Share Default On Desktop share with audio and Desktop share using a chrome tab as source are two new functionality developed. Previously the functionalities are behind the flags --enable-audio-support-for-desktop-share --enable-tab-for-desktop-share This CL changes the flags to be disable flags, namely: --disable-audio-support-for-desktop-share --disable-tab-for-desktop-share In another word, we bring the functionalities on by default. BUG=597539,597540 Review URL: https://codereview.chromium.org/1838623002 Cr-Commit-Position: refs/heads/master@{#384656} --- chrome/app/generated_resources.grd | 16 ++++++++-------- chrome/browser/about_flags.cc | 16 +++++++++------- .../desktop_capture/desktop_capture_apitest.cc | 5 +---- .../api/desktop_capture/desktop_capture_base.cc | 12 ++++++++++-- .../media/desktop_capture_access_handler.cc | 8 +++++--- .../renderer_host/media/media_stream_manager.cc | 4 ++-- content/public/browser/desktop_media_id.cc | 16 ++++++++++------ content/public/common/content_switches.cc | 4 ++-- content/public/common/content_switches.h | 2 +- extensions/common/switches.cc | 5 +++-- extensions/common/switches.h | 3 ++- tools/metrics/histograms/histograms.xml | 2 ++ 12 files changed, 55 insertions(+), 38 deletions(-) diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index 81b7a189e65d8d..632173413c0d83 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd @@ -6002,17 +6002,17 @@ Keep your key file in a safe place. You will need it to create new versions of y This is to be used in conjunction with the enable-navigation-tracing flag. Please select the label that best describes the recorded traces. This will choose the destination the traces are uploaded to. If you are not sure, select other. If left empty, no traces will be uploaded. - - Enable Audio For Desktop Share + + Disable Audio For Desktop Share - - With this flag on, desktop share picker window will let the user to choose whether to share audio. + + With this flag on, desktop share picker window will not let the user choose whether to share audio. - - Enable tab For Desktop Share. + + Desktop Share with tab source - - Enables user to chose a tab for desktop share. + + This flag controls whether users can choose a tab for desktop share. Other diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc index 665d78fa6ff2d8..0bb490fcf54a0f 100644 --- a/chrome/browser/about_flags.cc +++ b/chrome/browser/about_flags.cc @@ -1775,14 +1775,16 @@ const FeatureEntry kFeatureEntries[] = { {"enable-scroll-anchoring", IDS_FLAGS_ENABLE_SCROLL_ANCHORING_NAME, IDS_FLAGS_ENABLE_SCROLL_ANCHORING_DESCRIPTION, kOsAll, FEATURE_VALUE_TYPE(features::kScrollAnchoring)}, - {"enable-audio-support-for-desktop-share", - IDS_FLAG_ENABLE_AUDIO_FOR_DESKTOP_SHARE, - IDS_FLAG_ENABLE_AUDIO_FOR_DESKTOP_SHARE_DESCRIPTION, kOsAll, - SINGLE_VALUE_TYPE(switches::kEnableAudioSupportForDesktopShare)}, + {"disable-audio-support-for-desktop-share", + IDS_FLAG_DISABLE_AUDIO_FOR_DESKTOP_SHARE, + IDS_FLAG_DISABLE_AUDIO_FOR_DESKTOP_SHARE_DESCRIPTION, kOsAll, + SINGLE_VALUE_TYPE(switches::kDisableAudioSupportForDesktopShare)}, #if defined(ENABLE_EXTENSIONS) - {"enable-tab-for-desktop-share", IDS_FLAG_ENABLE_TAB_FOR_DESKTOP_SHARE, - IDS_FLAG_ENABLE_TAB_FOR_DESKTOP_SHARE_DESCRIPTION, kOsAll, - SINGLE_VALUE_TYPE(extensions::switches::kEnableTabForDesktopShare)}, + {"tab-for-desktop-share", IDS_FLAG_DISABLE_TAB_FOR_DESKTOP_SHARE, + IDS_FLAG_DISABLE_TAB_FOR_DESKTOP_SHARE_DESCRIPTION, kOsAll, + ENABLE_DISABLE_VALUE_TYPE( + extensions::switches::kEnableTabForDesktopShare, + extensions::switches::kDisableTabForDesktopShare)}, #endif #if defined(OS_ANDROID) {"enable-ntp-snippets", IDS_FLAGS_ENABLE_NTP_SNIPPETS_NAME, diff --git a/chrome/browser/extensions/api/desktop_capture/desktop_capture_apitest.cc b/chrome/browser/extensions/api/desktop_capture/desktop_capture_apitest.cc index 7315d2fb072abc..39b63128146547 100644 --- a/chrome/browser/extensions/api/desktop_capture/desktop_capture_apitest.cc +++ b/chrome/browser/extensions/api/desktop_capture/desktop_capture_apitest.cc @@ -161,12 +161,9 @@ class DesktopCaptureApiTest : public ExtensionApiTest { #define MAYBE_ChooseDesktopMedia ChooseDesktopMedia #endif IN_PROC_BROWSER_TEST_F(DesktopCaptureApiTest, MAYBE_ChooseDesktopMedia) { - // For tab and audio share, we need to turn on the flag, because the - // functionality is currently behind the flags. + // For tabshare, we need to turn on the flag. base::CommandLine::ForCurrentProcess()->AppendSwitch( extensions::switches::kEnableTabForDesktopShare); - base::CommandLine::ForCurrentProcess()->AppendSwitch( - extensions::switches::kEnableDesktopCaptureAudio); // Each element in the following array corresponds to one test in // chrome/test/data/extensions/api_test/desktop_capture/test.js . diff --git a/chrome/browser/extensions/api/desktop_capture/desktop_capture_base.cc b/chrome/browser/extensions/api/desktop_capture/desktop_capture_base.cc index d30e2408c888c0..617e6f0de07063 100644 --- a/chrome/browser/extensions/api/desktop_capture/desktop_capture_base.cc +++ b/chrome/browser/extensions/api/desktop_capture/desktop_capture_base.cc @@ -18,6 +18,8 @@ #include "chrome/browser/media/native_desktop_media_list.h" #include "chrome/browser/media/tab_desktop_media_list.h" #include "chrome/browser/ui/ash/ash_util.h" +#include "chrome/common/channel_info.h" +#include "components/version_info/version_info.h" #include "content/public/browser/render_frame_host.h" #include "content/public/browser/render_process_host.h" #include "content/public/browser/web_contents.h" @@ -100,13 +102,19 @@ bool DesktopCaptureChooseDesktopMediaFunctionBase::Execute( if (base::CommandLine::ForCurrentProcess()->HasSwitch( extensions::switches::kEnableTabForDesktopShare)) { show_tabs = true; + } else if (base::CommandLine::ForCurrentProcess()->HasSwitch( + extensions::switches::kDisableTabForDesktopShare)) { + show_tabs = false; + } else { + const version_info::Channel channel = chrome::GetChannel(); + show_tabs = (channel != version_info::Channel::STABLE); } break; case api::desktop_capture::DESKTOP_CAPTURE_SOURCE_TYPE_AUDIO: bool has_flag = base::CommandLine::ForCurrentProcess()->HasSwitch( - extensions::switches::kEnableDesktopCaptureAudio); - request_audio = has_flag; + extensions::switches::kDisableDesktopCaptureAudio); + request_audio = !has_flag; break; } } diff --git a/chrome/browser/media/desktop_capture_access_handler.cc b/chrome/browser/media/desktop_capture_access_handler.cc index a9aa1bfb6be375..62d5cc122c2fb4 100644 --- a/chrome/browser/media/desktop_capture_access_handler.cc +++ b/chrome/browser/media/desktop_capture_access_handler.cc @@ -366,10 +366,12 @@ void DesktopCaptureAccessHandler::HandleRequest( loopback_audio_supported) || media_id.type == content::DesktopMediaID::TYPE_WEB_CONTENTS; - const bool has_flag = base::CommandLine::ForCurrentProcess()->HasSwitch( - extensions::switches::kEnableDesktopCaptureAudio); + const bool check_audio_permission = + !base::CommandLine::ForCurrentProcess()->HasSwitch( + extensions::switches::kDisableDesktopCaptureAudio); const bool capture_audio = - (has_flag ? audio_permitted : true) && audio_requested && audio_supported; + (check_audio_permission ? audio_permitted : true) && audio_requested && + audio_supported; ui = GetDevicesForDesktopCapture(&devices, media_id, capture_audio, true, GetApplicationTitle(web_contents, extension), diff --git a/content/browser/renderer_host/media/media_stream_manager.cc b/content/browser/renderer_host/media/media_stream_manager.cc index 64d32f06112ac6..d2e6068524c676 100644 --- a/content/browser/renderer_host/media/media_stream_manager.cc +++ b/content/browser/renderer_host/media/media_stream_manager.cc @@ -99,8 +99,8 @@ void ParseStreamType(const StreamControls& controls, *audio_type = MEDIA_NO_SERVICE; *video_type = MEDIA_NO_SERVICE; const bool audio_support_flag_for_desktop_share = - base::CommandLine::ForCurrentProcess()->HasSwitch( - switches::kEnableAudioSupportForDesktopShare); + !base::CommandLine::ForCurrentProcess()->HasSwitch( + switches::kDisableAudioSupportForDesktopShare); if (controls.audio.requested) { if (!controls.audio.stream_source.empty()) { // This is tab or screen capture. diff --git a/content/public/browser/desktop_media_id.cc b/content/public/browser/desktop_media_id.cc index 77e8208c6cbf0c..8a20598af67f82 100644 --- a/content/public/browser/desktop_media_id.cc +++ b/content/public/browser/desktop_media_id.cc @@ -98,21 +98,25 @@ aura::Window* DesktopMediaID::GetAuraWindowById(const DesktopMediaID& id) { bool DesktopMediaID::operator<(const DesktopMediaID& other) const { #if defined(USE_AURA) - return std::tie(type, id, aura_id, web_contents_id) < - std::tie(other.type, other.id, other.aura_id, other.web_contents_id); + return std::tie(type, id, aura_id, web_contents_id, audio_share) < + std::tie(other.type, other.id, other.aura_id, other.web_contents_id, + other.audio_share); #else - return std::tie(type, id, web_contents_id) < - std::tie(other.type, other.id, other.web_contents_id); + return std::tie(type, id, web_contents_id, audio_share) < + std::tie(other.type, other.id, other.web_contents_id, + other.audio_share); #endif } bool DesktopMediaID::operator==(const DesktopMediaID& other) const { #if defined(USE_AURA) return type == other.type && id == other.id && aura_id == other.aura_id && - web_contents_id == other.web_contents_id; + web_contents_id == other.web_contents_id && + audio_share == other.audio_share; #else return type == other.type && id == other.id && - web_contents_id == other.web_contents_id; + web_contents_id == other.web_contents_id && + audio_share == other.audio_share; #endif } diff --git a/content/public/common/content_switches.cc b/content/public/common/content_switches.cc index d38c8bd5dad704..1b09d220ce3b7e 100644 --- a/content/public/common/content_switches.cc +++ b/content/public/common/content_switches.cc @@ -970,8 +970,8 @@ const char kEnableAggressiveDOMStorageFlushing[] = "enable-aggressive-domstorage-flushing"; // Enable audio for desktop share. -const char kEnableAudioSupportForDesktopShare[] = - "enable-audio-support-for-desktop-share"; +const char kDisableAudioSupportForDesktopShare[] = + "disable-audio-support-for-desktop-share"; #if defined(OS_CHROMEOS) // Disables panel fitting (used for mirror mode). diff --git a/content/public/common/content_switches.h b/content/public/common/content_switches.h index b907fcfc73f0e7..b69d6c887e61f8 100644 --- a/content/public/common/content_switches.h +++ b/content/public/common/content_switches.h @@ -36,6 +36,7 @@ CONTENT_EXPORT extern const char kDisableAccelerated2dCanvas[]; CONTENT_EXPORT extern const char kDisableAcceleratedJpegDecoding[]; CONTENT_EXPORT extern const char kDisableAcceleratedMjpegDecode[]; CONTENT_EXPORT extern const char kDisableAcceleratedVideoDecode[]; +CONTENT_EXPORT extern const char kDisableAudioSupportForDesktopShare[]; extern const char kDisableBackingStoreLimit[]; CONTENT_EXPORT extern const char kDisableBackgroundingOccludedWindowsForTesting[]; @@ -103,7 +104,6 @@ CONTENT_EXPORT extern const char kDomAutomationController[]; CONTENT_EXPORT extern const char kDownloadProcess[]; extern const char kEnable2dCanvasClipAntialiasing[]; CONTENT_EXPORT extern const char kEnableAggressiveDOMStorageFlushing[]; -CONTENT_EXPORT extern const char kEnableAudioSupportForDesktopShare[]; CONTENT_EXPORT extern const char kEnablePreferCompositingToLCDText[]; CONTENT_EXPORT extern const char kEnableBlinkFeatures[]; CONTENT_EXPORT extern const char kEnableBrowserSideNavigation[]; diff --git a/extensions/common/switches.cc b/extensions/common/switches.cc index 77e5ad16b528d4..9f60f9619f67ac 100644 --- a/extensions/common/switches.cc +++ b/extensions/common/switches.cc @@ -31,8 +31,8 @@ const char kEnableAppWindowControls[] = "enable-app-window-controls"; // Enable BLE Advertisiing in apps. const char kEnableBLEAdvertising[] = "enable-ble-advertising-in-apps"; -const char kEnableDesktopCaptureAudio[] = - "enable-audio-support-for-desktop-share"; +const char kDisableDesktopCaptureAudio[] = + "disable-audio-support-for-desktop-share"; // Hack so that feature switch can work with about_flags. See // kEnableScriptsRequireAction. @@ -55,6 +55,7 @@ const char kEnableMojoSerialService[] = "enable-mojo-serial-service"; const char kEnableOverrideBookmarksUI[] = "enable-override-bookmarks-ui"; // Enables tab for desktop sharing. +const char kDisableTabForDesktopShare[] = "disable-tab-for-desktop-share"; const char kEnableTabForDesktopShare[] = "enable-tab-for-desktop-share"; // Allows the ErrorConsole to collect runtime and manifest errors, and display diff --git a/extensions/common/switches.h b/extensions/common/switches.h index af2a0f44600e17..a812c12d62f7ea 100644 --- a/extensions/common/switches.h +++ b/extensions/common/switches.h @@ -13,10 +13,11 @@ namespace switches { extern const char kAllowHTTPBackgroundPage[]; extern const char kAllowLegacyExtensionManifests[]; +extern const char kDisableDesktopCaptureAudio[]; +extern const char kDisableTabForDesktopShare[]; extern const char kEmbeddedExtensionOptions[]; extern const char kEnableAppsShowOnFirstPaint[]; extern const char kEnableAppWindowControls[]; -extern const char kEnableDesktopCaptureAudio[]; extern const char kEnableEmbeddedExtensionOptions[]; extern const char kEnableExperimentalExtensionApis[]; extern const char kEnableExtensionActionRedesign[]; diff --git a/tools/metrics/histograms/histograms.xml b/tools/metrics/histograms/histograms.xml index 4cfec7ee31a33f..aa42626dc1ab81 100644 --- a/tools/metrics/histograms/histograms.xml +++ b/tools/metrics/histograms/histograms.xml @@ -74393,6 +74393,7 @@ To add a new entry, add it with any value and run test to compute valid value. + @@ -74562,6 +74563,7 @@ To add a new entry, add it with any value and run test to compute valid value. +