| OLD | NEW |
| 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 <algorithm> | 5 #include <algorithm> |
| 6 #include <string> | 6 #include <string> |
| 7 | 7 |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
| (...skipping 1213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1224 command_line->AppendSwitch(switches::kForceFirstRun); | 1224 command_line->AppendSwitch(switches::kForceFirstRun); |
| 1225 } | 1225 } |
| 1226 | 1226 |
| 1227 void StartupBrowserCreatorFirstRunTest::SetUpInProcessBrowserTestFixture() { | 1227 void StartupBrowserCreatorFirstRunTest::SetUpInProcessBrowserTestFixture() { |
| 1228 #if defined(ENABLE_CONFIGURATION_POLICY) | 1228 #if defined(ENABLE_CONFIGURATION_POLICY) |
| 1229 #if defined(OS_LINUX) && defined(GOOGLE_CHROME_BUILD) | 1229 #if defined(OS_LINUX) && defined(GOOGLE_CHROME_BUILD) |
| 1230 // Set a policy that prevents the first-run dialog from being shown. | 1230 // Set a policy that prevents the first-run dialog from being shown. |
| 1231 policy_map_.Set(policy::key::kMetricsReportingEnabled, | 1231 policy_map_.Set(policy::key::kMetricsReportingEnabled, |
| 1232 policy::POLICY_LEVEL_MANDATORY, | 1232 policy::POLICY_LEVEL_MANDATORY, |
| 1233 policy::POLICY_SCOPE_USER, | 1233 policy::POLICY_SCOPE_USER, |
| 1234 policy::POLICY_SOURCE_CLOUD, |
| 1234 new base::FundamentalValue(false), | 1235 new base::FundamentalValue(false), |
| 1235 NULL); | 1236 NULL); |
| 1236 provider_.UpdateChromePolicy(policy_map_); | 1237 provider_.UpdateChromePolicy(policy_map_); |
| 1237 #endif // defined(OS_LINUX) && defined(GOOGLE_CHROME_BUILD) | 1238 #endif // defined(OS_LINUX) && defined(GOOGLE_CHROME_BUILD) |
| 1238 | 1239 |
| 1239 EXPECT_CALL(provider_, IsInitializationComplete(_)) | 1240 EXPECT_CALL(provider_, IsInitializationComplete(_)) |
| 1240 .WillRepeatedly(Return(true)); | 1241 .WillRepeatedly(Return(true)); |
| 1241 policy::BrowserPolicyConnector::SetPolicyProviderForTesting(&provider_); | 1242 policy::BrowserPolicyConnector::SetPolicyProviderForTesting(&provider_); |
| 1242 #endif // defined(ENABLE_CONFIGURATION_POLICY) | 1243 #endif // defined(ENABLE_CONFIGURATION_POLICY) |
| 1243 } | 1244 } |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1591 browser()->profile()->GetPrefs()->SetBoolean( | 1592 browser()->profile()->GetPrefs()->SetBoolean( |
| 1592 prefs::kSignInPromoShowOnFirstRunAllowed, true); | 1593 prefs::kSignInPromoShowOnFirstRunAllowed, true); |
| 1593 | 1594 |
| 1594 // Set the following user policies: | 1595 // Set the following user policies: |
| 1595 // * RestoreOnStartup = RestoreOnStartupIsURLs | 1596 // * RestoreOnStartup = RestoreOnStartupIsURLs |
| 1596 // * RestoreOnStartupURLs = [ "files/title1.html" ] | 1597 // * RestoreOnStartupURLs = [ "files/title1.html" ] |
| 1597 policy_map_.Set( | 1598 policy_map_.Set( |
| 1598 policy::key::kRestoreOnStartup, | 1599 policy::key::kRestoreOnStartup, |
| 1599 policy::POLICY_LEVEL_MANDATORY, | 1600 policy::POLICY_LEVEL_MANDATORY, |
| 1600 policy::POLICY_SCOPE_USER, | 1601 policy::POLICY_SCOPE_USER, |
| 1602 policy::POLICY_SOURCE_CLOUD, |
| 1601 new base::FundamentalValue(SessionStartupPref::kPrefValueURLs), | 1603 new base::FundamentalValue(SessionStartupPref::kPrefValueURLs), |
| 1602 NULL); | 1604 NULL); |
| 1603 base::ListValue startup_urls; | 1605 base::ListValue startup_urls; |
| 1604 startup_urls.Append( | 1606 startup_urls.Append( |
| 1605 new base::StringValue(test_server()->GetURL("files/title1.html").spec())); | 1607 new base::StringValue(test_server()->GetURL("files/title1.html").spec())); |
| 1606 policy_map_.Set(policy::key::kRestoreOnStartupURLs, | 1608 policy_map_.Set(policy::key::kRestoreOnStartupURLs, |
| 1607 policy::POLICY_LEVEL_MANDATORY, policy::POLICY_SCOPE_USER, | 1609 policy::POLICY_LEVEL_MANDATORY, policy::POLICY_SCOPE_USER, |
| 1608 startup_urls.DeepCopy(), NULL); | 1610 policy::POLICY_SOURCE_CLOUD, startup_urls.DeepCopy(), |
| 1611 nullptr); |
| 1609 provider_.UpdateChromePolicy(policy_map_); | 1612 provider_.UpdateChromePolicy(policy_map_); |
| 1610 base::RunLoop().RunUntilIdle(); | 1613 base::RunLoop().RunUntilIdle(); |
| 1611 | 1614 |
| 1612 // Do a process-startup browser launch. | 1615 // Do a process-startup browser launch. |
| 1613 base::CommandLine dummy(base::CommandLine::NO_PROGRAM); | 1616 base::CommandLine dummy(base::CommandLine::NO_PROGRAM); |
| 1614 StartupBrowserCreatorImpl launch(base::FilePath(), dummy, &browser_creator, | 1617 StartupBrowserCreatorImpl launch(base::FilePath(), dummy, &browser_creator, |
| 1615 chrome::startup::IS_FIRST_RUN); | 1618 chrome::startup::IS_FIRST_RUN); |
| 1616 ASSERT_TRUE(launch.Launch(browser()->profile(), std::vector<GURL>(), true, | 1619 ASSERT_TRUE(launch.Launch(browser()->profile(), std::vector<GURL>(), true, |
| 1617 browser()->host_desktop_type())); | 1620 browser()->host_desktop_type())); |
| 1618 | 1621 |
| 1619 // This should have created a new browser window. | 1622 // This should have created a new browser window. |
| 1620 Browser* new_browser = FindOneOtherBrowser(browser()); | 1623 Browser* new_browser = FindOneOtherBrowser(browser()); |
| 1621 ASSERT_TRUE(new_browser); | 1624 ASSERT_TRUE(new_browser); |
| 1622 | 1625 |
| 1623 // Verify that the URL specified through policy is shown and no sync promo has | 1626 // Verify that the URL specified through policy is shown and no sync promo has |
| 1624 // been added. | 1627 // been added. |
| 1625 TabStripModel* tab_strip = new_browser->tab_strip_model(); | 1628 TabStripModel* tab_strip = new_browser->tab_strip_model(); |
| 1626 ASSERT_EQ(1, tab_strip->count()); | 1629 ASSERT_EQ(1, tab_strip->count()); |
| 1627 EXPECT_EQ("title1.html", | 1630 EXPECT_EQ("title1.html", |
| 1628 tab_strip->GetWebContentsAt(0)->GetURL().ExtractFileName()); | 1631 tab_strip->GetWebContentsAt(0)->GetURL().ExtractFileName()); |
| 1629 } | 1632 } |
| 1630 #endif // defined(ENABLE_CONFIGURATION_POLICY) | 1633 #endif // defined(ENABLE_CONFIGURATION_POLICY) |
| 1631 | 1634 |
| 1632 #endif // !defined(OS_LINUX) || !defined(GOOGLE_CHROME_BUILD) || | 1635 #endif // !defined(OS_LINUX) || !defined(GOOGLE_CHROME_BUILD) || |
| 1633 // defined(ENABLE_CONFIGURATION_POLICY) | 1636 // defined(ENABLE_CONFIGURATION_POLICY) |
| 1634 | 1637 |
| 1635 #endif // !defined(OS_CHROMEOS) | 1638 #endif // !defined(OS_CHROMEOS) |
| OLD | NEW |