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

Side by Side Diff: chrome/browser/managed_mode/managed_mode_browsertest.cc

Issue 13820009: Create a ManagedModeNavigationObserver only for managed users. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix the other test. Created 7 years, 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/managed_mode/managed_mode_navigation_observer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/prefs/pref_service.h" 6 #include "base/prefs/pref_service.h"
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "chrome/browser/infobars/confirm_infobar_delegate.h" 9 #include "chrome/browser/infobars/confirm_infobar_delegate.h"
10 #include "chrome/browser/infobars/infobar.h" 10 #include "chrome/browser/infobars/infobar.h"
11 #include "chrome/browser/infobars/infobar_tab_helper.h" 11 #include "chrome/browser/infobars/infobar_tab_helper.h"
12 #include "chrome/browser/managed_mode/managed_mode.h" 12 #include "chrome/browser/managed_mode/managed_mode.h"
13 #include "chrome/browser/managed_mode/managed_mode_interstitial.h" 13 #include "chrome/browser/managed_mode/managed_mode_interstitial.h"
14 #include "chrome/browser/managed_mode/managed_mode_navigation_observer.h"
14 #include "chrome/browser/managed_mode/managed_user_service.h" 15 #include "chrome/browser/managed_mode/managed_user_service.h"
15 #include "chrome/browser/managed_mode/managed_user_service_factory.h" 16 #include "chrome/browser/managed_mode/managed_user_service_factory.h"
16 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/browser/ui/browser.h" 18 #include "chrome/browser/ui/browser.h"
18 #include "chrome/browser/ui/browser_navigator.h" 19 #include "chrome/browser/ui/browser_navigator.h"
19 #include "chrome/browser/ui/tabs/tab_strip_model.h" 20 #include "chrome/browser/ui/tabs/tab_strip_model.h"
20 #include "chrome/browser/ui/web_contents_modal_dialog_manager.h" 21 #include "chrome/browser/ui/web_contents_modal_dialog_manager.h"
21 #include "chrome/common/chrome_notification_types.h" 22 #include "chrome/common/chrome_notification_types.h"
22 #include "chrome/common/chrome_switches.h" 23 #include "chrome/common/chrome_switches.h"
23 #include "chrome/common/pref_names.h" 24 #include "chrome/common/pref_names.h"
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 InterstitialObserver observer(tab, loop_runner->QuitClosure()); 202 InterstitialObserver observer(tab, loop_runner->QuitClosure());
202 interstitial_page->DontProceed(); 203 interstitial_page->DontProceed();
203 loop_runner->Run(); 204 loop_runner->Run();
204 } 205 }
205 EXPECT_FALSE(IsPreviewInfobarPresent()); 206 EXPECT_FALSE(IsPreviewInfobarPresent());
206 EXPECT_FALSE(IsAlreadyAddedInfobarPresent()); 207 EXPECT_FALSE(IsAlreadyAddedInfobarPresent());
207 } 208 }
208 209
209 protected: 210 protected:
210 virtual void SetUpOnMainThread() OVERRIDE { 211 virtual void SetUpOnMainThread() OVERRIDE {
212 // Set up the ManagedModeNavigationObserver manually since the profile was
213 // not managed when the browser was created.
214 content::WebContents* web_contents =
215 browser()->tab_strip_model()->GetActiveWebContents();
216 ManagedModeNavigationObserver::CreateForWebContents(web_contents);
217
211 Profile* profile = browser()->profile(); 218 Profile* profile = browser()->profile();
212 managed_user_service_ = ManagedUserServiceFactory::GetForProfile(profile); 219 managed_user_service_ = ManagedUserServiceFactory::GetForProfile(profile);
213 profile->GetPrefs()->SetBoolean(prefs::kProfileIsManaged, true); 220 profile->GetPrefs()->SetBoolean(prefs::kProfileIsManaged, true);
214 managed_user_service_->Init(); 221 managed_user_service_->Init();
215 } 222 }
216 223
217 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 224 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
218 // Enable the test server and remap all URLs to it. 225 // Enable the test server and remap all URLs to it.
219 ASSERT_TRUE(test_server()->Start()); 226 ASSERT_TRUE(test_server()->Start());
220 std::string host_port = test_server()->host_port_pair().ToString(); 227 std::string host_port = test_server()->host_port_pair().ToString();
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 interstitial_page->GetDelegateForTesting(); 614 interstitial_page->GetDelegateForTesting();
608 615
609 // Simulate the click on the "preview" button. 616 // Simulate the click on the "preview" button.
610 delegate->CommandReceived("\"preview\""); 617 delegate->CommandReceived("\"preview\"");
611 WebContentsModalDialogManager* web_contents_modal_dialog_manager = 618 WebContentsModalDialogManager* web_contents_modal_dialog_manager =
612 WebContentsModalDialogManager::FromWebContents(tab); 619 WebContentsModalDialogManager::FromWebContents(tab);
613 EXPECT_TRUE(web_contents_modal_dialog_manager->IsShowingDialog()); 620 EXPECT_TRUE(web_contents_modal_dialog_manager->IsShowingDialog());
614 } 621 }
615 622
616 } // namespace 623 } // namespace
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/managed_mode/managed_mode_navigation_observer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698