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

Side by Side Diff: chrome/browser/ui/startup/startup_browser_creator_browsertest.cc

Issue 1304843004: Add source column to chrome://policy showing the origins of policies. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Moved policy source determiniation from providers to setting method. Created 5 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 unified diff | Download patch
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 <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 1580 matching lines...) Expand 10 before | Expand all | Expand 10 after
1591 browser()->profile()->GetPrefs()->SetBoolean( 1591 browser()->profile()->GetPrefs()->SetBoolean(
1592 prefs::kSignInPromoShowOnFirstRunAllowed, true); 1592 prefs::kSignInPromoShowOnFirstRunAllowed, true);
1593 1593
1594 // Set the following user policies: 1594 // Set the following user policies:
1595 // * RestoreOnStartup = RestoreOnStartupIsURLs 1595 // * RestoreOnStartup = RestoreOnStartupIsURLs
1596 // * RestoreOnStartupURLs = [ "files/title1.html" ] 1596 // * RestoreOnStartupURLs = [ "files/title1.html" ]
1597 policy_map_.Set( 1597 policy_map_.Set(
1598 policy::key::kRestoreOnStartup, 1598 policy::key::kRestoreOnStartup,
1599 policy::POLICY_LEVEL_MANDATORY, 1599 policy::POLICY_LEVEL_MANDATORY,
1600 policy::POLICY_SCOPE_USER, 1600 policy::POLICY_SCOPE_USER,
1601 POLICY_SOURCE_CLOUD,
1601 new base::FundamentalValue(SessionStartupPref::kPrefValueURLs), 1602 new base::FundamentalValue(SessionStartupPref::kPrefValueURLs),
1602 NULL); 1603 NULL);
1603 base::ListValue startup_urls; 1604 base::ListValue startup_urls;
1604 startup_urls.Append( 1605 startup_urls.Append(
1605 new base::StringValue(test_server()->GetURL("files/title1.html").spec())); 1606 new base::StringValue(test_server()->GetURL("files/title1.html").spec()));
1606 policy_map_.Set(policy::key::kRestoreOnStartupURLs, 1607 policy_map_.Set(policy::key::kRestoreOnStartupURLs,
1607 policy::POLICY_LEVEL_MANDATORY, policy::POLICY_SCOPE_USER, 1608 policy::POLICY_LEVEL_MANDATORY, policy::POLICY_SCOPE_USER,
1608 startup_urls.DeepCopy(), NULL); 1609 POLICY_SOURCE_CLOUD, startup_urls.DeepCopy(), nullptr);
1609 provider_.UpdateChromePolicy(policy_map_); 1610 provider_.UpdateChromePolicy(policy_map_);
1610 base::RunLoop().RunUntilIdle(); 1611 base::RunLoop().RunUntilIdle();
1611 1612
1612 // Do a process-startup browser launch. 1613 // Do a process-startup browser launch.
1613 base::CommandLine dummy(base::CommandLine::NO_PROGRAM); 1614 base::CommandLine dummy(base::CommandLine::NO_PROGRAM);
1614 StartupBrowserCreatorImpl launch(base::FilePath(), dummy, &browser_creator, 1615 StartupBrowserCreatorImpl launch(base::FilePath(), dummy, &browser_creator,
1615 chrome::startup::IS_FIRST_RUN); 1616 chrome::startup::IS_FIRST_RUN);
1616 ASSERT_TRUE(launch.Launch(browser()->profile(), std::vector<GURL>(), true, 1617 ASSERT_TRUE(launch.Launch(browser()->profile(), std::vector<GURL>(), true,
1617 browser()->host_desktop_type())); 1618 browser()->host_desktop_type()));
1618 1619
1619 // This should have created a new browser window. 1620 // This should have created a new browser window.
1620 Browser* new_browser = FindOneOtherBrowser(browser()); 1621 Browser* new_browser = FindOneOtherBrowser(browser());
1621 ASSERT_TRUE(new_browser); 1622 ASSERT_TRUE(new_browser);
1622 1623
1623 // Verify that the URL specified through policy is shown and no sync promo has 1624 // Verify that the URL specified through policy is shown and no sync promo has
1624 // been added. 1625 // been added.
1625 TabStripModel* tab_strip = new_browser->tab_strip_model(); 1626 TabStripModel* tab_strip = new_browser->tab_strip_model();
1626 ASSERT_EQ(1, tab_strip->count()); 1627 ASSERT_EQ(1, tab_strip->count());
1627 EXPECT_EQ("title1.html", 1628 EXPECT_EQ("title1.html",
1628 tab_strip->GetWebContentsAt(0)->GetURL().ExtractFileName()); 1629 tab_strip->GetWebContentsAt(0)->GetURL().ExtractFileName());
1629 } 1630 }
1630 #endif // defined(ENABLE_CONFIGURATION_POLICY) 1631 #endif // defined(ENABLE_CONFIGURATION_POLICY)
1631 1632
1632 #endif // !defined(OS_LINUX) || !defined(GOOGLE_CHROME_BUILD) || 1633 #endif // !defined(OS_LINUX) || !defined(GOOGLE_CHROME_BUILD) ||
1633 // defined(ENABLE_CONFIGURATION_POLICY) 1634 // defined(ENABLE_CONFIGURATION_POLICY)
1634 1635
1635 #endif // !defined(OS_CHROMEOS) 1636 #endif // !defined(OS_CHROMEOS)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698