Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4926)

Unified Diff: chrome/browser/extensions/api/desktop_capture/desktop_capture_api.cc

Issue 307453010: Fix a crash when chooseDesktopMedia is called with no target tab (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/extensions/api/desktop_capture/desktop_capture_apitest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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,
« no previous file with comments | « no previous file | chrome/browser/extensions/api/desktop_capture/desktop_capture_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698