Skip to content

Commit

Permalink
Merge pull request #5205 from brave/fix_ipfs_extension_crash
Browse files Browse the repository at this point in the history
Fixed crash when user tries to install ipfs extension from setting
  • Loading branch information
simonhong authored Apr 10, 2020
2 parents 1d1ba4c + 4cb815f commit 4ec1c13
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions browser/ui/webui/settings/brave_default_extensions_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
#include "chrome/browser/media/router/media_router_feature.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/lifetime/application_lifetime.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
#include "components/flags_ui/flags_ui_constants.h"
Expand Down Expand Up @@ -274,9 +277,15 @@ void BraveDefaultExtensionsHandler::SetIPFSCompanionEnabled(
extensions::ExtensionSystem::Get(profile_)->extension_service();
if (enabled) {
if (!IsExtensionInstalled(ipfs_companion_extension_id)) {
// Using FindLastActiveWithProfile() here will be fine. Of course, it can
// return NULL but only return NULL when there was no activated window
// with |profile_| so far. But, it's impossible at here because user can't
// request ipfs install request w/o activating browser.
scoped_refptr<extensions::WebstoreInstallWithPrompt> installer =
new extensions::WebstoreInstallWithPrompt(
ipfs_companion_extension_id, profile_,
chrome::FindLastActiveWithProfile(profile_)->window()->
GetNativeWindow(),
base::BindOnce(&BraveDefaultExtensionsHandler::OnInstallResult,
weak_ptr_factory_.GetWeakPtr(),
kIPFSCompanionEnabled));
Expand Down

0 comments on commit 4ec1c13

Please sign in to comment.