diff options
author | gyzhou <gyzhou@chromium.org> | 2016-02-18 13:10:35 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-02-18 21:12:10 +0000 |
commit | 7e69f2820196c6663e2af02924b68e51c4072039 (patch) | |
tree | 9623252fb1e2fc94e83f311d863cf9b4094a2bb0 | |
parent | 723b5eeb4486ac293b6574cfce33a4fb1012e09d (diff) | |
download | chromium_src-7e69f2820196c6663e2af02924b68e51c4072039.zip chromium_src-7e69f2820196c6663e2af02924b68e51c4072039.tar.gz chromium_src-7e69f2820196c6663e2af02924b68e51c4072039.tar.bz2 |
Add a flag for tab desktop capture and enable tab capture for desktop media picker.
BUG=557222
Review URL: https://codereview.chromium.org/1688973003
Cr-Commit-Position: refs/heads/master@{#376257}
-rw-r--r-- | chrome/app/generated_resources.grd | 6 | ||||
-rw-r--r-- | chrome/browser/about_flags.cc | 12 | ||||
-rw-r--r-- | chrome/browser/extensions/api/desktop_capture/desktop_capture_base.cc | 62 | ||||
-rw-r--r-- | chrome/browser/ui/views/desktop_media_picker_views.cc | 3 | ||||
-rw-r--r-- | chrome/common/extensions/docs/examples/api/desktopCapture/app.js | 4 | ||||
-rw-r--r-- | extensions/common/switches.cc | 3 | ||||
-rw-r--r-- | extensions/common/switches.h | 1 | ||||
-rw-r--r-- | tools/metrics/histograms/histograms.xml | 1 |
8 files changed, 64 insertions, 28 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index 8d2fa83..491a7d2 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd @@ -5993,6 +5993,12 @@ Keep your key file in a safe place. You will need it to create new versions of y <message name="IDS_FLAG_ENABLE_AUDIO_FOR_DESKTOP_SHARE_DESCRIPTION" desc="Description for the flag to enable Audio Sharing."> With this flag on, desktop share picker window will let the user to choose whether to share audio. </message> + <message name="IDS_FLAG_ENABLE_TAB_FOR_DESKTOP_SHARE" desc="Title for the flag to enable tab for desktop share."> + Enable tab For Desktop Share. + </message> + <message name="IDS_FLAG_ENABLE_TAB_FOR_DESKTOP_SHARE_DESCRIPTION" desc="Description for the flag to enable tab for desktop share."> + Enables user to chose a tab for desktop share. + </message> <message name="IDS_TRACE_UPLOAD_URL_CHOICE_OTHER"> Other </message> diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc index b78f557..5ee9e72 100644 --- a/chrome/browser/about_flags.cc +++ b/chrome/browser/about_flags.cc @@ -1788,9 +1788,9 @@ const FeatureEntry kFeatureEntries[] = { IDS_FLAGS_ENABLE_WEBFONTS_INTERVENTION_DESCRIPTION, kOsAll, FEATURE_VALUE_TYPE(features::kWebFontsIntervention)}, {"enable-webfonts-intervention-trigger", - IDS_FLAGS_ENABLE_WEBFONTS_INTERVENTION_TRIGGER_NAME, - IDS_FLAGS_ENABLE_WEBFONTS_INTERVENTION_TRIGGER_DESCRIPTION, kOsAll, - SINGLE_VALUE_TYPE(switches::kEnableWebFontsInterventionTrigger)}, + IDS_FLAGS_ENABLE_WEBFONTS_INTERVENTION_TRIGGER_NAME, + IDS_FLAGS_ENABLE_WEBFONTS_INTERVENTION_TRIGGER_DESCRIPTION, kOsAll, + SINGLE_VALUE_TYPE(switches::kEnableWebFontsInterventionTrigger)}, {"enable-grouped-history", IDS_FLAGS_ENABLE_GROUPED_HISTORY_NAME, IDS_FLAGS_ENABLE_GROUPED_HISTORY_DESCRIPTION, kOsDesktop, SINGLE_VALUE_TYPE(switches::kHistoryEnableGroupByDomain)}, @@ -1817,7 +1817,11 @@ const FeatureEntry kFeatureEntries[] = { IDS_FLAG_ENABLE_AUDIO_FOR_DESKTOP_SHARE_DESCRIPTION, kOsAll, SINGLE_VALUE_TYPE(switches::kEnableAudioSupportForDesktopShare)}, - +#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)} +#endif // NOTE: Adding new command-line switches requires adding corresponding // entries to enum "LoginCustomFlags" in histograms.xml. See note in // histograms.xml and don't forget to run AboutFlagsHistogramTest unit test. 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 7bc5da4..4e0903d 100644 --- a/chrome/browser/extensions/api/desktop_capture/desktop_capture_base.cc +++ b/chrome/browser/extensions/api/desktop_capture/desktop_capture_base.cc @@ -11,10 +11,12 @@ #include "base/strings/utf_string_conversions.h" #include "build/build_config.h" #include "chrome/browser/extensions/extension_tab_util.h" +#include "chrome/browser/media/combined_desktop_media_list.h" #include "chrome/browser/media/desktop_media_list_ash.h" #include "chrome/browser/media/desktop_streams_registry.h" #include "chrome/browser/media/media_capture_devices_dispatcher.h" #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 "content/public/browser/render_frame_host.h" #include "content/public/browser/render_process_host.h" @@ -31,7 +33,6 @@ namespace { const char kInvalidSourceNameError[] = "Invalid source type specified."; const char kEmptySourcesListError[] = "At least one source type must be specified."; -const char kTabCaptureNotSupportedError[] = "Tab capture is not supported yet."; DesktopCaptureChooseDesktopMediaFunctionBase::PickerFactory* g_picker_factory = NULL; @@ -78,7 +79,7 @@ bool DesktopCaptureChooseDesktopMediaFunctionBase::Execute( bool show_screens = false; bool show_windows = false; - + bool show_tabs = false; bool request_audio = false; for (auto source_type : sources) { @@ -96,8 +97,11 @@ bool DesktopCaptureChooseDesktopMediaFunctionBase::Execute( break; case api::desktop_capture::DESKTOP_CAPTURE_SOURCE_TYPE_TAB: - error_ = kTabCaptureNotSupportedError; - return false; + if (base::CommandLine::ForCurrentProcess()->HasSwitch( + extensions::switches::kEnableTabForDesktopShare)) { + show_tabs = true; + } + break; case api::desktop_capture::DESKTOP_CAPTURE_SOURCE_TYPE_AUDIO: bool has_flag = base::CommandLine::ForCurrentProcess()->HasSwitch( @@ -107,7 +111,7 @@ bool DesktopCaptureChooseDesktopMediaFunctionBase::Execute( } } - if (!show_screens && !show_windows) { + if (!show_screens && !show_windows && !show_tabs) { error_ = kEmptySourcesListError; return false; } @@ -120,24 +124,39 @@ bool DesktopCaptureChooseDesktopMediaFunctionBase::Execute( show_screens, show_windows); picker_ = g_picker_factory->CreatePicker(); } else { + std::vector<scoped_ptr<DesktopMediaList>> media_lists; + // Create a screens/windows list and push it into media_lists. + if (show_screens || show_windows) { #if defined(USE_ASH) - if (chrome::IsNativeWindowInAsh(parent_window)) { - media_list.reset(new DesktopMediaListAsh( - (show_screens ? DesktopMediaListAsh::SCREENS : 0) | - (show_windows ? DesktopMediaListAsh::WINDOWS : 0))); - } + if (chrome::IsNativeWindowInAsh(parent_window)) { + media_lists.push_back(make_scoped_ptr(new DesktopMediaListAsh( + (show_screens ? DesktopMediaListAsh::SCREENS : 0) | + (show_windows ? DesktopMediaListAsh::WINDOWS : 0)))); + } #endif - if (!media_list) { - webrtc::DesktopCaptureOptions options = - webrtc::DesktopCaptureOptions::CreateDefault(); - options.set_disable_effects(false); - scoped_ptr<webrtc::ScreenCapturer> screen_capturer( - show_screens ? webrtc::ScreenCapturer::Create(options) : NULL); - scoped_ptr<webrtc::WindowCapturer> window_capturer( - show_windows ? webrtc::WindowCapturer::Create(options) : NULL); - - media_list.reset(new NativeDesktopMediaList(std::move(screen_capturer), - std::move(window_capturer))); + if (!media_list) { + webrtc::DesktopCaptureOptions options = + webrtc::DesktopCaptureOptions::CreateDefault(); + options.set_disable_effects(false); + scoped_ptr<webrtc::ScreenCapturer> screen_capturer( + show_screens ? webrtc::ScreenCapturer::Create(options) : NULL); + scoped_ptr<webrtc::WindowCapturer> window_capturer( + show_windows ? webrtc::WindowCapturer::Create(options) : NULL); + + media_lists.push_back(make_scoped_ptr(new NativeDesktopMediaList( + std::move(screen_capturer), std::move(window_capturer)))); + } + } + + if (show_tabs) + media_lists.push_back(make_scoped_ptr(new TabDesktopMediaList())); + + DCHECK(!media_lists.empty()); + + if (media_lists.size() == 1) { + media_list = std::move(media_lists[0]); + } else { + media_list.reset(new CombinedDesktopMediaList(media_lists)); } // DesktopMediaPicker is implemented only for Windows, OSX and @@ -149,6 +168,7 @@ bool DesktopCaptureChooseDesktopMediaFunctionBase::Execute( return false; #endif } + DesktopMediaPicker::DoneCallback callback = base::Bind( &DesktopCaptureChooseDesktopMediaFunctionBase::OnPickerDialogResults, this); diff --git a/chrome/browser/ui/views/desktop_media_picker_views.cc b/chrome/browser/ui/views/desktop_media_picker_views.cc index 0200536..a87cd56 100644 --- a/chrome/browser/ui/views/desktop_media_picker_views.cc +++ b/chrome/browser/ui/views/desktop_media_picker_views.cc @@ -523,7 +523,8 @@ bool DesktopMediaPickerDialogView::Accept() { audio_share_checkbox_->enabled() && audio_share_checkbox_->checked(); - if (parent_) + // TYPE_WEB_CONTENTS/tab is not fully supported yet. + if (parent_ && source.type != DesktopMediaID::TYPE_WEB_CONTENTS) parent_->NotifyDialogResult(source); // Return true to close the window. diff --git a/chrome/common/extensions/docs/examples/api/desktopCapture/app.js b/chrome/common/extensions/docs/examples/api/desktopCapture/app.js index 7d5ba99..a6d8e47 100644 --- a/chrome/common/extensions/docs/examples/api/desktopCapture/app.js +++ b/chrome/common/extensions/docs/examples/api/desktopCapture/app.js @@ -4,7 +4,7 @@ 'use strict'; -const DESKTOP_MEDIA = ['screen', 'window', 'audio']; +const DESKTOP_MEDIA = ['screen', 'window', 'tab', 'audio']; var pending_request_id = null; var pc1 = null; @@ -79,7 +79,7 @@ function gotStream(stream) { pc1.addStream(stream); - pc1.createOffer(onCreateOfferSuccess); + pc1.createOffer(onCreateOfferSuccess, function() {}); } function onCreateOfferSuccess(desc) { diff --git a/extensions/common/switches.cc b/extensions/common/switches.cc index 41e1d27..77e5ad1 100644 --- a/extensions/common/switches.cc +++ b/extensions/common/switches.cc @@ -54,6 +54,9 @@ const char kEnableMojoSerialService[] = "enable-mojo-serial-service"; // Enables extensions to hide bookmarks UI elements. const char kEnableOverrideBookmarksUI[] = "enable-override-bookmarks-ui"; +// Enables tab for desktop sharing. +const char kEnableTabForDesktopShare[] = "enable-tab-for-desktop-share"; + // Allows the ErrorConsole to collect runtime and manifest errors, and display // them in the chrome:extensions page. const char kErrorConsole[] = "error-console"; diff --git a/extensions/common/switches.h b/extensions/common/switches.h index 7c891d8..af2a0f4 100644 --- a/extensions/common/switches.h +++ b/extensions/common/switches.h @@ -23,6 +23,7 @@ extern const char kEnableExtensionActionRedesign[]; extern const char kEnableMojoSerialService[]; extern const char kEnableOverrideBookmarksUI[]; extern const char kEnableBLEAdvertising[]; +extern const char kEnableTabForDesktopShare[]; extern const char kErrorConsole[]; extern const char kExtensionActionRedesign[]; extern const char kExtensionProcess[]; diff --git a/tools/metrics/histograms/histograms.xml b/tools/metrics/histograms/histograms.xml index 6183664..d1f6c58 100644 --- a/tools/metrics/histograms/histograms.xml +++ b/tools/metrics/histograms/histograms.xml @@ -71126,6 +71126,7 @@ To add a new entry, add it with any value and run test to compute valid value. <int value="121858954" label="enable-supervised-user-safesites"/> <int value="125934378" label="enable-password-link"/> <int value="147373243" label="enable-deferred-image-decoding"/> + <int value="157217034" label="enable-tab-for-desktop-share"/> <int value="178337215" label="enable-md-history"/> <int value="180074362" label="memory-pressure-thresholds"/> <int value="203776499" label="enable-virtual-keyboard-overscroll"/> |