Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6795)

Unified Diff: chrome/test/base/testing_profile.h

Issue 556173002: Ensure incognito TestingProfiles are incognito for their whole lifetime. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix CrOS Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/test/base/testing_profile.h
diff --git a/chrome/test/base/testing_profile.h b/chrome/test/base/testing_profile.h
index bf55546ce92d59591fa0bbf6c208f70e475353ec..c89aa60c86450eb5cdc2ac84585be05283e8764f 100644
--- a/chrome/test/base/testing_profile.h
+++ b/chrome/test/base/testing_profile.h
@@ -97,9 +97,6 @@ class TestingProfile : public Profile {
// Sets the PrefService to be used by this profile.
void SetPrefService(scoped_ptr<PrefServiceSyncable> prefs);
- // Makes the Profile being built an incognito profile.
- void SetIncognito();
-
// Makes the Profile being built a guest profile.
void SetGuestSession();
@@ -113,6 +110,11 @@ class TestingProfile : public Profile {
// Creates the TestingProfile using previously-set settings.
scoped_ptr<TestingProfile> Build();
+ // Build an incognito profile, owned by |original_profile|. Note: unless you
+ // need customize the Builder, or access TestingProfile member functions,
sky 2014/09/12 15:33:29 to customize?
tapted 2014/09/15 05:05:17 Done.
+ // you can probably just call original_profile->GetOffTheRecordProfile().
sky 2014/09/12 15:33:29 'probably just call' -> use
tapted 2014/09/15 05:05:17 Done.
+ TestingProfile* BuildIncognito(TestingProfile* original_profile);
+
private:
// If true, Build() has already been called.
bool build_called_;
@@ -124,7 +126,6 @@ class TestingProfile : public Profile {
#endif
base::FilePath path_;
Delegate* delegate_;
- bool incognito_;
bool guest_session_;
std::string supervised_user_id_;
scoped_ptr<policy::PolicyService> policy_service_;
@@ -154,7 +155,7 @@ class TestingProfile : public Profile {
scoped_refptr<ExtensionSpecialStoragePolicy> extension_policy,
#endif
scoped_ptr<PrefServiceSyncable> prefs,
- bool incognito,
+ TestingProfile* incognito_parent,
sky 2014/09/12 15:33:29 incognito_parent is mildly confusing, in so far as
tapted 2014/09/15 05:05:17 Done.
bool guest_session,
const std::string& supervised_user_id,
scoped_ptr<policy::PolicyService> policy_service,
@@ -209,6 +210,10 @@ class TestingProfile : public Profile {
TestingPrefServiceSyncable* GetTestingPrefService();
+ // Used by some tests to provide an OffTheRecordProfileImpl instead of an
+ // instance of TestingProfile.
+ void SetOffTheRecordProfile(scoped_ptr<Profile> profile);
+
// content::BrowserContext
virtual base::FilePath GetPath() const OVERRIDE;
virtual scoped_refptr<base::SequencedTaskRunner> GetIOTaskRunner() OVERRIDE;
@@ -250,8 +255,6 @@ class TestingProfile : public Profile {
force_incognito_ = force_incognito;
}
- virtual void SetOffTheRecordProfile(scoped_ptr<Profile> profile);
- virtual void SetOriginalProfile(Profile* profile);
virtual Profile* GetOffTheRecordProfile() OVERRIDE;
virtual void DestroyOffTheRecordProfile() OVERRIDE {}
virtual bool HasOffTheRecordProfile() OVERRIDE;
@@ -349,18 +352,25 @@ class TestingProfile : public Profile {
// Creates a TestingPrefService and associates it with the TestingProfile.
void CreateTestingPrefService();
+ // Initializes |prefs_| for an incognito profile, derived from
+ // |original_profile_|.
+ void CreateIncognitoPrefService();
+
// Creates a ProfilePolicyConnector that the ProfilePolicyConnectorFactory
// maps to this profile.
void CreateProfilePolicyConnector();
+ // Called from the constructor of an OTR TestingProfile. Takes ownership of
+ // |incognito_profile|.
+ void SetTestingOffTheRecordProfile(Profile* incognito_profile);
+
// Internally, this is a TestURLRequestContextGetter that creates a dummy
// request context. Currently, only the CookieMonster is hooked up.
scoped_refptr<net::URLRequestContextGetter> extensions_request_context_;
- bool incognito_;
bool force_incognito_;
scoped_ptr<Profile> incognito_profile_;
- Profile* original_profile_;
+ TestingProfile* original_profile_;
bool guest_session_;

Powered by Google App Engine
This is Rietveld 408576698