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

Unified Diff: chrome/browser/renderer_context_menu/spelling_menu_observer_browsertest.cc

Issue 556173002: Ensure incognito TestingProfiles are incognito for their whole lifetime. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: respond to comments 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/browser/renderer_context_menu/spelling_menu_observer_browsertest.cc
diff --git a/chrome/browser/renderer_context_menu/spelling_menu_observer_browsertest.cc b/chrome/browser/renderer_context_menu/spelling_menu_observer_browsertest.cc
index 943d68952784ff989b0c5a86005d5f28812d1bce..3b4a8414267f8ea3335e942d7b407c527a6d5448 100644
--- a/chrome/browser/renderer_context_menu/spelling_menu_observer_browsertest.cc
+++ b/chrome/browser/renderer_context_menu/spelling_menu_observer_browsertest.cc
@@ -81,7 +81,10 @@ class MockRenderViewContextMenu : public RenderViewContextMenuProxy {
// A dummy profile used in this test. Call GetPrefs() when a test needs to
// change this profile and use PrefService methods.
- scoped_ptr<TestingProfile> profile_;
+ scoped_ptr<TestingProfile> original_profile_;
+
+ // Either |original_profile_| or its incognito profile.
+ Profile* profile_;
// A list of menu items added by the SpellingMenuObserver class.
std::vector<MockMenuItem> items_;
@@ -91,10 +94,9 @@ class MockRenderViewContextMenu : public RenderViewContextMenuProxy {
MockRenderViewContextMenu::MockRenderViewContextMenu(bool incognito)
: observer_(NULL) {
- TestingProfile::Builder builder;
- if (incognito)
- builder.SetIncognito();
- profile_ = builder.Build();
+ original_profile_ = TestingProfile::Builder().Build();
+ profile_ = incognito ? original_profile_->GetOffTheRecordProfile()
+ : original_profile_.get();
}
MockRenderViewContextMenu::~MockRenderViewContextMenu() {
@@ -170,7 +172,7 @@ WebContents* MockRenderViewContextMenu::GetWebContents() const {
}
content::BrowserContext* MockRenderViewContextMenu::GetBrowserContext() const {
- return profile_.get();
+ return profile_;
}
size_t MockRenderViewContextMenu::GetMenuSize() const {
« no previous file with comments | « chrome/browser/profiles/profile_manager_unittest.cc ('k') | chrome/browser/search/hotword_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698