| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/memory/ptr_util.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
| 14 #include "base/test/histogram_tester.h" | 15 #include "base/test/histogram_tester.h" |
| 15 #include "build/build_config.h" | 16 #include "build/build_config.h" |
| 16 #include "chrome/browser/browser_process.h" | 17 #include "chrome/browser/browser_process.h" |
| 17 #include "chrome/browser/extensions/extension_browsertest.h" | 18 #include "chrome/browser/extensions/extension_browsertest.h" |
| 18 #include "chrome/browser/extensions/extension_service.h" | 19 #include "chrome/browser/extensions/extension_service.h" |
| 19 #include "chrome/browser/extensions/extension_util.h" | 20 #include "chrome/browser/extensions/extension_util.h" |
| 20 #include "chrome/browser/extensions/launch_util.h" | 21 #include "chrome/browser/extensions/launch_util.h" |
| 21 #include "chrome/browser/first_run/first_run.h" | 22 #include "chrome/browser/first_run/first_run.h" |
| 22 #include "chrome/browser/infobars/infobar_service.h" | 23 #include "chrome/browser/infobars/infobar_service.h" |
| (...skipping 1541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1564 // } | 1565 // } |
| 1565 ASSERT_TRUE(embedded_test_server()->Start()); | 1566 ASSERT_TRUE(embedded_test_server()->Start()); |
| 1566 StartupBrowserCreator browser_creator; | 1567 StartupBrowserCreator browser_creator; |
| 1567 browser()->profile()->GetPrefs()->SetBoolean( | 1568 browser()->profile()->GetPrefs()->SetBoolean( |
| 1568 prefs::kSignInPromoShowOnFirstRunAllowed, true); | 1569 prefs::kSignInPromoShowOnFirstRunAllowed, true); |
| 1569 | 1570 |
| 1570 // Set the following user policies: | 1571 // Set the following user policies: |
| 1571 // * RestoreOnStartup = RestoreOnStartupIsURLs | 1572 // * RestoreOnStartup = RestoreOnStartupIsURLs |
| 1572 // * RestoreOnStartupURLs = [ "/title1.html" ] | 1573 // * RestoreOnStartupURLs = [ "/title1.html" ] |
| 1573 policy_map_.Set( | 1574 policy_map_.Set( |
| 1574 policy::key::kRestoreOnStartup, | 1575 policy::key::kRestoreOnStartup, policy::POLICY_LEVEL_MANDATORY, |
| 1575 policy::POLICY_LEVEL_MANDATORY, | 1576 policy::POLICY_SCOPE_USER, policy::POLICY_SOURCE_CLOUD, |
| 1576 policy::POLICY_SCOPE_USER, | 1577 base::WrapUnique( |
| 1577 policy::POLICY_SOURCE_CLOUD, | 1578 new base::FundamentalValue(SessionStartupPref::kPrefValueURLs)), |
| 1578 new base::FundamentalValue(SessionStartupPref::kPrefValueURLs), | 1579 nullptr); |
| 1579 NULL); | |
| 1580 base::ListValue startup_urls; | 1580 base::ListValue startup_urls; |
| 1581 startup_urls.Append(new base::StringValue( | 1581 startup_urls.Append(new base::StringValue( |
| 1582 embedded_test_server()->GetURL("/title1.html").spec())); | 1582 embedded_test_server()->GetURL("/title1.html").spec())); |
| 1583 policy_map_.Set(policy::key::kRestoreOnStartupURLs, | 1583 policy_map_.Set(policy::key::kRestoreOnStartupURLs, |
| 1584 policy::POLICY_LEVEL_MANDATORY, policy::POLICY_SCOPE_USER, | 1584 policy::POLICY_LEVEL_MANDATORY, policy::POLICY_SCOPE_USER, |
| 1585 policy::POLICY_SOURCE_CLOUD, startup_urls.DeepCopy(), | 1585 policy::POLICY_SOURCE_CLOUD, startup_urls.CreateDeepCopy(), |
| 1586 nullptr); | 1586 nullptr); |
| 1587 provider_.UpdateChromePolicy(policy_map_); | 1587 provider_.UpdateChromePolicy(policy_map_); |
| 1588 base::RunLoop().RunUntilIdle(); | 1588 base::RunLoop().RunUntilIdle(); |
| 1589 | 1589 |
| 1590 // Do a process-startup browser launch. | 1590 // Do a process-startup browser launch. |
| 1591 base::CommandLine dummy(base::CommandLine::NO_PROGRAM); | 1591 base::CommandLine dummy(base::CommandLine::NO_PROGRAM); |
| 1592 StartupBrowserCreatorImpl launch(base::FilePath(), dummy, &browser_creator, | 1592 StartupBrowserCreatorImpl launch(base::FilePath(), dummy, &browser_creator, |
| 1593 chrome::startup::IS_FIRST_RUN); | 1593 chrome::startup::IS_FIRST_RUN); |
| 1594 ASSERT_TRUE(launch.Launch(browser()->profile(), std::vector<GURL>(), true)); | 1594 ASSERT_TRUE(launch.Launch(browser()->profile(), std::vector<GURL>(), true)); |
| 1595 | 1595 |
| 1596 // This should have created a new browser window. | 1596 // This should have created a new browser window. |
| 1597 Browser* new_browser = FindOneOtherBrowser(browser()); | 1597 Browser* new_browser = FindOneOtherBrowser(browser()); |
| 1598 ASSERT_TRUE(new_browser); | 1598 ASSERT_TRUE(new_browser); |
| 1599 | 1599 |
| 1600 // Verify that the URL specified through policy is shown and no sync promo has | 1600 // Verify that the URL specified through policy is shown and no sync promo has |
| 1601 // been added. | 1601 // been added. |
| 1602 TabStripModel* tab_strip = new_browser->tab_strip_model(); | 1602 TabStripModel* tab_strip = new_browser->tab_strip_model(); |
| 1603 ASSERT_EQ(1, tab_strip->count()); | 1603 ASSERT_EQ(1, tab_strip->count()); |
| 1604 EXPECT_EQ("title1.html", | 1604 EXPECT_EQ("title1.html", |
| 1605 tab_strip->GetWebContentsAt(0)->GetURL().ExtractFileName()); | 1605 tab_strip->GetWebContentsAt(0)->GetURL().ExtractFileName()); |
| 1606 } | 1606 } |
| 1607 | 1607 |
| 1608 #endif // !defined(OS_CHROMEOS) | 1608 #endif // !defined(OS_CHROMEOS) |
| OLD | NEW |