2016-08-04 14:37:53 +02:00
|
|
|
diff --git chrome/browser/profiles/incognito_helpers.cc chrome/browser/profiles/incognito_helpers.cc
|
2018-08-09 22:18:24 +02:00
|
|
|
index a319237928b8..82945e3d625d 100644
|
2016-08-04 14:37:53 +02:00
|
|
|
--- chrome/browser/profiles/incognito_helpers.cc
|
|
|
|
+++ chrome/browser/profiles/incognito_helpers.cc
|
2018-08-09 22:18:24 +02:00
|
|
|
@@ -8,20 +8,41 @@
|
2016-08-04 14:37:53 +02:00
|
|
|
|
|
|
|
namespace chrome {
|
2018-05-14 13:24:05 +02:00
|
|
|
|
2016-08-04 14:37:53 +02:00
|
|
|
+namespace {
|
|
|
|
+BrowserContextIncognitoHelper* g_helper = nullptr;
|
|
|
|
+} // namespace
|
|
|
|
+
|
|
|
|
+void SetBrowserContextIncognitoHelper(BrowserContextIncognitoHelper* helper) {
|
|
|
|
+ g_helper = helper;
|
|
|
|
+}
|
2018-05-14 13:24:05 +02:00
|
|
|
+
|
2016-08-04 14:37:53 +02:00
|
|
|
content::BrowserContext* GetBrowserContextRedirectedInIncognito(
|
|
|
|
content::BrowserContext* context) {
|
|
|
|
+ if (g_helper) {
|
|
|
|
+ content::BrowserContext* new_context =
|
|
|
|
+ g_helper->GetBrowserContextRedirectedInIncognito(context);
|
|
|
|
+ if (new_context)
|
|
|
|
+ return new_context;
|
|
|
|
+ }
|
|
|
|
+
|
2018-08-09 22:18:24 +02:00
|
|
|
return Profile::FromBrowserContext(context)->GetOriginalProfile();
|
2016-08-04 14:37:53 +02:00
|
|
|
}
|
|
|
|
|
2017-12-07 22:44:24 +01:00
|
|
|
const content::BrowserContext* GetBrowserContextRedirectedInIncognito(
|
|
|
|
const content::BrowserContext* context) {
|
2018-08-09 22:18:24 +02:00
|
|
|
- const Profile* profile = Profile::FromBrowserContext(
|
2017-12-07 22:44:24 +01:00
|
|
|
+ return GetBrowserContextRedirectedInIncognito(
|
2018-08-09 22:18:24 +02:00
|
|
|
const_cast<content::BrowserContext*>(context));
|
|
|
|
- return profile->GetOriginalProfile();
|
2017-12-07 22:44:24 +01:00
|
|
|
}
|
|
|
|
|
2016-08-04 14:37:53 +02:00
|
|
|
content::BrowserContext* GetBrowserContextOwnInstanceInIncognito(
|
|
|
|
content::BrowserContext* context) {
|
|
|
|
+ if (g_helper) {
|
|
|
|
+ content::BrowserContext* new_context =
|
|
|
|
+ g_helper->GetBrowserContextOwnInstanceInIncognito(context);
|
|
|
|
+ if (new_context)
|
|
|
|
+ return new_context;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
return context;
|
|
|
|
}
|
|
|
|
|
|
|
|
diff --git chrome/browser/profiles/incognito_helpers.h chrome/browser/profiles/incognito_helpers.h
|
2017-12-07 22:44:24 +01:00
|
|
|
index e8e76ce5b954..1dd338dd0142 100644
|
2016-08-04 14:37:53 +02:00
|
|
|
--- chrome/browser/profiles/incognito_helpers.h
|
|
|
|
+++ chrome/browser/profiles/incognito_helpers.h
|
|
|
|
@@ -11,6 +11,19 @@ class BrowserContext;
|
|
|
|
|
|
|
|
namespace chrome {
|
|
|
|
|
|
|
|
+class BrowserContextIncognitoHelper {
|
|
|
|
+ public:
|
|
|
|
+ virtual content::BrowserContext* GetBrowserContextRedirectedInIncognito(
|
|
|
|
+ content::BrowserContext* context) = 0;
|
|
|
|
+ virtual content::BrowserContext* GetBrowserContextOwnInstanceInIncognito(
|
|
|
|
+ content::BrowserContext* context) = 0;
|
|
|
|
+ protected:
|
|
|
|
+ virtual ~BrowserContextIncognitoHelper() {}
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+// Allow CEF to hook the below methods.
|
|
|
|
+void SetBrowserContextIncognitoHelper(BrowserContextIncognitoHelper* helper);
|
|
|
|
+
|
|
|
|
// Returns the original browser context even for Incognito contexts.
|
|
|
|
content::BrowserContext* GetBrowserContextRedirectedInIncognito(
|
|
|
|
content::BrowserContext* context);
|
2017-07-27 01:19:27 +02:00
|
|
|
diff --git chrome/browser/profiles/profile_manager.cc chrome/browser/profiles/profile_manager.cc
|
2018-11-30 23:21:07 +01:00
|
|
|
index cc62bbe4cf18..127cf4c982d6 100644
|
2017-07-27 01:19:27 +02:00
|
|
|
--- chrome/browser/profiles/profile_manager.cc
|
|
|
|
+++ chrome/browser/profiles/profile_manager.cc
|
2018-11-30 23:21:07 +01:00
|
|
|
@@ -380,7 +380,7 @@ ProfileManager::ProfileManager(const base::FilePath& user_data_dir)
|
2017-07-27 01:19:27 +02:00
|
|
|
chrome::NOTIFICATION_BROWSER_CLOSE_CANCELLED,
|
|
|
|
content::NotificationService::AllSources());
|
2017-09-06 23:40:58 +02:00
|
|
|
|
2017-07-27 01:19:27 +02:00
|
|
|
- if (ProfileShortcutManager::IsFeatureEnabled() && !user_data_dir_.empty())
|
|
|
|
+ if (!user_data_dir_.empty() && ProfileShortcutManager::IsFeatureEnabled())
|
|
|
|
profile_shortcut_manager_.reset(ProfileShortcutManager::Create(
|
|
|
|
this));
|
|
|
|
}
|
2016-07-18 23:22:22 +02:00
|
|
|
diff --git chrome/browser/profiles/profile_manager.h chrome/browser/profiles/profile_manager.h
|
2018-09-04 11:43:21 +02:00
|
|
|
index 8a62433e9107..5ae35bc2d16a 100644
|
2016-07-18 23:22:22 +02:00
|
|
|
--- chrome/browser/profiles/profile_manager.h
|
|
|
|
+++ chrome/browser/profiles/profile_manager.h
|
2018-05-20 15:51:42 +02:00
|
|
|
@@ -93,7 +93,7 @@ class ProfileManager : public content::NotificationObserver,
|
2016-08-04 14:37:53 +02:00
|
|
|
// acceptable. Returns null if creation of the new profile fails.
|
|
|
|
// TODO(bauerb): Migrate calls from other code to GetProfileByPath(), then
|
|
|
|
// make this method private.
|
|
|
|
- Profile* GetProfile(const base::FilePath& profile_dir);
|
|
|
|
+ virtual Profile* GetProfile(const base::FilePath& profile_dir);
|
|
|
|
|
|
|
|
// Returns total number of profiles available on this machine.
|
|
|
|
size_t GetNumberOfProfiles();
|
2018-09-04 11:43:21 +02:00
|
|
|
@@ -123,7 +123,7 @@ class ProfileManager : public content::NotificationObserver,
|
2016-07-18 23:22:22 +02:00
|
|
|
|
|
|
|
// Returns true if the profile pointer is known to point to an existing
|
|
|
|
// profile.
|
|
|
|
- bool IsValidProfile(const void* profile);
|
|
|
|
+ virtual bool IsValidProfile(const void* profile);
|
|
|
|
|
|
|
|
// Returns the directory where the first created profile is stored,
|
|
|
|
// relative to the user data directory currently in use.
|
2018-09-04 11:43:21 +02:00
|
|
|
@@ -132,7 +132,7 @@ class ProfileManager : public content::NotificationObserver,
|
2016-11-07 20:14:09 +01:00
|
|
|
// Get the Profile last used (the Profile to which owns the most recently
|
|
|
|
// focused window) with this Chrome build. If no signed profile has been
|
|
|
|
// stored in Local State, hand back the Default profile.
|
|
|
|
- Profile* GetLastUsedProfile(const base::FilePath& user_data_dir);
|
|
|
|
+ virtual Profile* GetLastUsedProfile(const base::FilePath& user_data_dir);
|
|
|
|
|
|
|
|
// Get the path of the last used profile, or if that's undefined, the default
|
|
|
|
// profile.
|