Skip to content

Commit

Permalink
Fixed crash when user tries to install ipfs extension from setting
Browse files Browse the repository at this point in the history
When extension install is requested, install dialog is launched.
So far, we requsted un-parented install dialog.
On linux, custom frame is not allowed for un-parented dialog.
Only platform-native frame is used for it. The problem was
install dialog tries to set title to custom frame. So, seg fault
happened only on linux. And Windows with classic theme will have
same issue. On macOS and Windows with aero, crash doesn't happen.
But, un-parented dialog has title area that looks ugly.
  • Loading branch information
simonhong committed Apr 9, 2020
1 parent ed2647e commit 4cb815f
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 4cb815f

Please sign in to comment.