Chromium Code Reviews| Index: chrome/browser/extensions/api/desktop_capture/desktop_capture_api.cc |
| diff --git a/chrome/browser/extensions/api/desktop_capture/desktop_capture_api.cc b/chrome/browser/extensions/api/desktop_capture/desktop_capture_api.cc |
| index b9362800c0e881fec90e1e8b2a5c137637378515..905a9623bd757ed5352231ddbf25a91229c65e27 100644 |
| --- a/chrome/browser/extensions/api/desktop_capture/desktop_capture_api.cc |
| +++ b/chrome/browser/extensions/api/desktop_capture/desktop_capture_api.cc |
| @@ -37,6 +37,7 @@ const char kInvalidTabIdError[] = "Invalid tab specified."; |
| const char kTabUrlChangedError[] = "URL for the specified tab has changed."; |
| const char kTabUrlNotSecure[] = |
| "URL scheme for the specified tab is not secure."; |
| +const char kNoTabsAvailableError[] = "No tabs available."; |
| DesktopCaptureChooseDesktopMediaFunction::PickerFactory* g_picker_factory = |
| NULL; |
| @@ -89,7 +90,8 @@ bool DesktopCaptureChooseDesktopMediaFunction::RunAsync() { |
| render_view_host()->GetProcess()->GetID(), request_id_, this); |
| gfx::NativeWindow parent_window; |
| - content::RenderViewHost* render_view; |
| + content::RenderViewHost* render_view = NULL; |
| + content::WebContents* web_contents = NULL; |
| base::string16 target_name; |
| if (params->target_tab) { |
| if (!params->target_tab->url) { |
| @@ -112,7 +114,6 @@ bool DesktopCaptureChooseDesktopMediaFunction::RunAsync() { |
| return false; |
| } |
| - content::WebContents* web_contents = NULL; |
| if (!ExtensionTabUtil::GetTabById(*(params->target_tab->id), GetProfile(), |
| true, NULL, NULL, &web_contents, NULL)) { |
| error_ = kInvalidTabIdError; |
| @@ -135,9 +136,16 @@ bool DesktopCaptureChooseDesktopMediaFunction::RunAsync() { |
| origin_ = GetExtension()->url(); |
| target_name = base::UTF8ToUTF16(GetExtension()->name()); |
| render_view = render_view_host(); |
| - parent_window = |
| - GetAssociatedWebContents()->GetTopLevelNativeWindow(); |
| + |
| + web_contents = GetAssociatedWebContents(); |
| + if (!web_contents) { |
| + error_ = kNoTabsAvailableError; |
|
zel
2014/05/28 04:06:34
I still think we could support this scenario as we
Sergey Ulanov
2014/06/01 01:31:38
I agree. I think in this case we should pass null
tbarzic
2014/06/03 01:18:51
We still need to select the parent_window to use i
|
| + return false; |
| + } |
| + |
| + parent_window = web_contents->GetTopLevelNativeWindow(); |
| } |
| + |
| render_process_id_ = render_view->GetProcess()->GetID(); |
| render_view_id_ = render_view->GetRoutingID(); |
| @@ -208,7 +216,7 @@ bool DesktopCaptureChooseDesktopMediaFunction::RunAsync() { |
| DesktopMediaPicker::DoneCallback callback = base::Bind( |
| &DesktopCaptureChooseDesktopMediaFunction::OnPickerDialogResults, this); |
| - picker_->Show(web_contents(), |
| + picker_->Show(web_contents, |
| parent_window, parent_window, |
| base::UTF8ToUTF16(GetExtension()->name()), |
| target_name, |