Fix a crash when chooseDesktopMedia is called with no target tab
commit2115dd3283dbb02f8f7b78fad021297f8e4ebae5
authortbarzic@chromium.org <tbarzic@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>
Wed, 4 Jun 2014 11:20:21 +0000 (4 11:20 +0000)
committertbarzic@chromium.org <tbarzic@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>
Wed, 4 Jun 2014 11:20:21 +0000 (4 11:20 +0000)
treed356b7cc527fc25885180a740fb13d8bc16bedc8
parent8bf3b101dbadf9679db6a2466b25eec1832c0651
Fix a crash when chooseDesktopMedia is called with no target tab

DesktopMediaPicker was getting created with web_contents returned by
web_contents(), which is part of WebContentsObserver interface,
and which does not get set when the target tab is not specified.

Also, fix handling of a case when the method is called when there are
no web contents to attach the picker dialog to.

BUG=375576,364050
TEST=from a extension with desktopCapture permission:
chrome.desktopCapture.chooseDesktopMedia(['screen'], undefined, function())
does not crash

Review URL: https://codereview.chromium.org/307453010

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@274771 0039d316-1c4b-4281-b951-d872f2087c98
chrome/browser/extensions/api/desktop_capture/desktop_capture_api.cc
chrome/browser/ui/views/desktop_media_picker_views.cc