Skip to content

Commit

Permalink
Fix: nw2 close event on remote URL
Browse files Browse the repository at this point in the history
  • Loading branch information
rogerwang committed Jun 14, 2020
1 parent 532fb4f commit a869974
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
1 change: 1 addition & 0 deletions chrome/browser/extensions/api/tabs/tabs_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,7 @@ ExtensionFunction::ResponseAction WindowsCreateFunction::Run() {
extension() && extension()->is_nwjs_app() /* trusted_source */, window_bounds, window_profile,
user_gesture());
}
create_params.extension_id = extension_id;
create_params.windows_key = windows_key;
create_params.frameless = frameless;
create_params.alpha_enabled = transparent;
Expand Down
14 changes: 8 additions & 6 deletions chrome/browser/ui/browser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,7 @@ Browser* Browser::Create(const CreateParams& params) {

Browser::Browser(const CreateParams& params)
: nw_menu_(nullptr),
extension_id_(params.extension_id),
create_params_(params),
frameless_(params.frameless),
alpha_enabled_(params.alpha_enabled),
Expand Down Expand Up @@ -722,12 +723,7 @@ Browser::~Browser() {
}

bool Browser::NWCanClose(bool user_force) {
WebContents* web_contents = tab_strip_model_->GetActiveWebContents();
if (!web_contents)
return true;
const extensions::Extension* extension =
extensions::ProcessManager::Get(profile_)
->GetExtensionForWebContents(web_contents);
const extensions::Extension* extension = GetExtension();
if (!extension)
return true;
//content::RenderFrameHost* rfh = web_contents->GetMainFrame();
Expand Down Expand Up @@ -756,6 +752,12 @@ bool Browser::NWCanClose(bool user_force) {
return true;
}

const extensions::Extension* Browser::GetExtension() const {
return extensions::ExtensionRegistry::Get(profile_)
->enabled_extensions()
.GetByID(extension_id_);
}

///////////////////////////////////////////////////////////////////////////////
// Getters & Setters

Expand Down
3 changes: 3 additions & 0 deletions chrome/browser/ui/browser.h
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ class Browser : public TabStripModelObserver,

static CreateParams CreateForDevTools(Profile* profile);

std::string extension_id;
bool frameless = false;
bool alpha_enabled = false;
bool always_on_top = false;
Expand Down Expand Up @@ -311,9 +312,11 @@ class Browser : public TabStripModelObserver,
// TODO(tbarzic): Make the constructor non-public once browser construction
// instances are replaced with Create(). https://crbug.com/916859.
nw::Menu* nw_menu_;
std::string extension_id_;
explicit Browser(const CreateParams& params);
~Browser() override;

const extensions::Extension* GetExtension() const;
bool NWCanClose(bool user_force = false);

// Set overrides for the initial window bounds and maximized state.
Expand Down

0 comments on commit a869974

Please sign in to comment.