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

Unified Diff: chrome/browser/chromeos/extensions/echo_private_api.cc

Issue 1139603003: Fix crash in echoPrivate.getUserConsent when there are no browser windows (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 5 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/extensions/echo_private_api.cc
diff --git a/chrome/browser/chromeos/extensions/echo_private_api.cc b/chrome/browser/chromeos/extensions/echo_private_api.cc
index 6b3e6cfbef1c4638f1fbea8fc8c8a6db577c71b4..1aa9a89707eb1fe28605ba50ba701ab7d6b69f7c 100644
--- a/chrome/browser/chromeos/extensions/echo_private_api.cc
+++ b/chrome/browser/chromeos/extensions/echo_private_api.cc
@@ -20,11 +20,11 @@
#include "chrome/browser/chromeos/settings/cros_settings.h"
#include "chrome/browser/chromeos/ui/echo_dialog_view.h"
#include "chrome/browser/ui/browser.h"
-#include "chrome/browser/ui/browser_window.h"
#include "chrome/common/extensions/api/echo_private.h"
#include "chrome/common/pref_names.h"
#include "chromeos/system/statistics_provider.h"
#include "content/public/browser/browser_thread.h"
+#include "content/public/browser/web_contents.h"
#include "extensions/common/extension.h"
namespace echo_api = extensions::api::echo_private;
@@ -240,6 +240,13 @@ void EchoPrivateGetUserConsentFunction::OnRedeemOffersAllowedChecked(
return;
}
+ content::WebContents* web_contents = GetAssociatedWebContents();
+ if (!web_contents) {
+ error_ = "No web contents.";
+ SendResponse(false);
+ return;
+ }
+
// Add ref to ensure the function stays around until the dialog listener is
// called. The reference is release in |Finalize|.
AddRef();
@@ -253,7 +260,7 @@ void EchoPrivateGetUserConsentFunction::OnRedeemOffersAllowedChecked(
} else {
dialog->InitForDisabledEcho();
}
- dialog->Show(GetCurrentBrowser()->window()->GetNativeWindow());
+ dialog->Show(web_contents->GetTopLevelNativeWindow());
// If there is a dialog_shown_callback_, invoke it with the created dialog.
if (!dialog_shown_callback_.is_null())
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698