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

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/ui/views/desktop_media_picker_views.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..91f5c768c201b7200ceb5ba0ea0f956d1da82e10 100644
--- a/chrome/browser/extensions/api/desktop_capture/desktop_capture_api.cc
+++ b/chrome/browser/extensions/api/desktop_capture/desktop_capture_api.cc
@@ -4,6 +4,7 @@
#include "chrome/browser/extensions/api/desktop_capture/desktop_capture_api.h"
+#include "ash/shell.h"
#include "base/command_line.h"
#include "base/compiler_specific.h"
#include "base/strings/utf_string_conversions.h"
@@ -13,6 +14,7 @@
#include "chrome/browser/media/media_capture_devices_dispatcher.h"
#include "chrome/browser/media/native_desktop_media_list.h"
#include "chrome/browser/ui/ash/ash_util.h"
+#include "chrome/browser/ui/host_desktop.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/extensions/api/tabs.h"
#include "content/public/browser/render_process_host.h"
@@ -88,8 +90,9 @@ bool DesktopCaptureChooseDesktopMediaFunction::RunAsync() {
DesktopCaptureRequestsRegistry::GetInstance()->AddRequest(
render_view_host()->GetProcess()->GetID(), request_id_, this);
- gfx::NativeWindow parent_window;
- content::RenderViewHost* render_view;
+ gfx::NativeWindow parent_window = NULL;
+ 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 +115,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 +137,18 @@ 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) {
+ parent_window = web_contents->GetTopLevelNativeWindow();
+ } else {
+#if defined(USE_ASH)
+ if (chrome::GetActiveDesktop() == chrome::HOST_DESKTOP_TYPE_ASH)
+ parent_window = ash::Shell::GetPrimaryRootWindow();
sky 2014/06/03 22:07:20 Why is the primary root the right one here? And as
tbarzic 2014/06/03 22:25:33 the primary root is used only when there is no web
+#endif
+ }
}
+
render_process_id_ = render_view->GetProcess()->GetID();
render_view_id_ = render_view->GetRoutingID();
@@ -208,7 +219,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/ui/views/desktop_media_picker_views.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698