-
Notifications
You must be signed in to change notification settings - Fork 887
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
For Tor profile, return early for profile created and destroyed notif…
…ications in ExtensionAppShimHandler::Observe like off-the-record profiles since we're sharing AppLifetimeMonitor with its parent profile. Without this commit, we will hit DCHECK because it will try to add ExtensionAppShimHandler as the observer of AppLifetimeMonitor multiple times.
- Loading branch information
Showing
5 changed files
with
98 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
source_set("app_shim") { | ||
sources = [ | ||
"brave_extension_app_shim_handler_mac.cc", | ||
"brave_extension_app_shim_handler_mac.h", | ||
] | ||
deps = [ | ||
"//content/public/browser", | ||
] | ||
} |
43 changes: 43 additions & 0 deletions
43
browser/apps/app_shim/brave_extension_app_shim_handler_mac.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* Copyright (c) 2019 The Brave Authors. All rights reserved. | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at https://mozilla.org/MPL/2.0/. */ | ||
|
||
#include "brave/browser/apps/app_shim/brave_extension_app_shim_handler_mac.h" | ||
|
||
#include "brave/browser/profiles/profile_util.h" | ||
#include "chrome/browser/chrome_notification_types.h" | ||
#include "content/public/browser/notification_source.h" | ||
|
||
namespace apps { | ||
|
||
// Same as off-the-record profiles, we return early for Tor profile for | ||
// NOTIFICATION_PROFILE_CREATED and NOTIFICATION_PROFILE_DESTROYED cases | ||
// since ExtensionAppShimHandler is observing AppLifetimeMonitorFactory through | ||
// parent profiles. | ||
void BraveExtensionAppShimHandler::Observe( | ||
int type, | ||
const content::NotificationSource& source, | ||
const content::NotificationDetails& details) { | ||
switch (type) { | ||
case chrome::NOTIFICATION_PROFILE_CREATED: { | ||
Profile* profile = content::Source<Profile>(source).ptr(); | ||
if (brave::IsTorProfile(profile)) | ||
return; | ||
break; | ||
} | ||
case chrome::NOTIFICATION_PROFILE_DESTROYED: { | ||
Profile* profile = content::Source<Profile>(source).ptr(); | ||
if (brave::IsTorProfile(profile)) | ||
return; | ||
break; | ||
} | ||
default: { | ||
break; | ||
} | ||
} | ||
|
||
return ExtensionAppShimHandler::Observe(type, source, details); | ||
} | ||
|
||
} // namespace apps |
30 changes: 30 additions & 0 deletions
30
browser/apps/app_shim/brave_extension_app_shim_handler_mac.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* Copyright (c) 2019 The Brave Authors. All rights reserved. | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at https://mozilla.org/MPL/2.0/. */ | ||
|
||
#ifndef BRAVE_BROWSER_APPS_APP_SHIM_BRAVE_EXTENSION_APP_SHIM_HANDLER_MAC_H_ | ||
#define BRAVE_BROWSER_APPS_APP_SHIM_BRAVE_EXTENSION_APP_SHIM_HANDLER_MAC_H_ | ||
|
||
#include "chrome/browser/apps/app_shim/extension_app_shim_handler_mac.h" | ||
|
||
#include "content/public/browser/notification_observer.h" | ||
|
||
namespace apps { | ||
|
||
class BraveExtensionAppShimHandler : public ExtensionAppShimHandler { | ||
public: | ||
BraveExtensionAppShimHandler() = default; | ||
~BraveExtensionAppShimHandler() override = default; | ||
|
||
// content::NotificationObserver overrides: | ||
void Observe(int type, | ||
const content::NotificationSource& source, | ||
const content::NotificationDetails& details) override; | ||
|
||
DISALLOW_COPY_AND_ASSIGN(BraveExtensionAppShimHandler); | ||
}; | ||
|
||
} // namespace apps | ||
|
||
#endif // BRAVE_BROWSER_APPS_APP_SHIM_BRAVE_EXTENSION_APP_SHIM_HANDLER_MAC_H_ |
10 changes: 10 additions & 0 deletions
10
chromium_src/chrome/browser/apps/app_shim/app_shim_host_manager_mac.mm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* Copyright (c) 2019 The Brave Authors. All rights reserved. | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at https://mozilla.org/MPL/2.0/. */ | ||
|
||
#include "brave/browser/apps/app_shim/brave_extension_app_shim_handler_mac.h" | ||
|
||
#define ExtensionAppShimHandler BraveExtensionAppShimHandler | ||
#include "../../../../../../chrome/browser/apps/app_shim/app_shim_host_manager_mac.mm" | ||
#undef ExtensionAppShimHandler |