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 "chrome/browser/ui/browser_init.h" | 5 #include "chrome/browser/ui/browser_init.h" |
6 | 6 |
7 #include <algorithm> // For max(). | 7 #include <algorithm> // For max(). |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 1566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1577 return false; | 1577 return false; |
1578 } | 1578 } |
1579 | 1579 |
1580 void BrowserInit::LaunchWithProfile::CheckPreferencesBackup(Profile* profile) { | 1580 void BrowserInit::LaunchWithProfile::CheckPreferencesBackup(Profile* profile) { |
1581 ProtectorService* protector_service = | 1581 ProtectorService* protector_service = |
1582 ProtectorServiceFactory::GetForProfile(profile); | 1582 ProtectorServiceFactory::GetForProfile(profile); |
1583 ProtectedPrefsWatcher* prefs_watcher = protector_service->GetPrefsWatcher(); | 1583 ProtectedPrefsWatcher* prefs_watcher = protector_service->GetPrefsWatcher(); |
1584 | 1584 |
1585 // Check if backup is valid. | 1585 // Check if backup is valid. |
1586 if (!prefs_watcher->is_backup_valid()) { | 1586 if (!prefs_watcher->is_backup_valid()) { |
1587 scoped_ptr<BaseSettingChange> change( | 1587 protector_service->ShowChange(protector::CreatePrefsBackupInvalidChange()); |
1588 protector::CreatePrefsBackupInvalidChange()); | |
1589 protector_service->ShowChange(change.release()); | |
1590 // Further checks make no sense. | 1588 // Further checks make no sense. |
1591 return; | 1589 return; |
1592 } | 1590 } |
1593 | 1591 |
1594 // Check for session startup (including pinned tabs) changes. | 1592 // Check for session startup (including pinned tabs) changes. |
1595 if (SessionStartupPref::DidStartupPrefChange(profile) || | 1593 if (SessionStartupPref::DidStartupPrefChange(profile) || |
1596 prefs_watcher->DidPrefChange(prefs::kPinnedTabs)) { | 1594 prefs_watcher->DidPrefChange(prefs::kPinnedTabs)) { |
1597 LOG(WARNING) << "Session startup settings have changed"; | 1595 LOG(WARNING) << "Session startup settings have changed"; |
1598 SessionStartupPref new_pref = SessionStartupPref::GetStartupPref(profile); | 1596 SessionStartupPref new_pref = SessionStartupPref::GetStartupPref(profile); |
1599 PinnedTabCodec::Tabs new_tabs = PinnedTabCodec::ReadPinnedTabs(profile); | 1597 PinnedTabCodec::Tabs new_tabs = PinnedTabCodec::ReadPinnedTabs(profile); |
1600 const base::Value* tabs_backup = | 1598 const base::Value* tabs_backup = |
1601 prefs_watcher->GetBackupForPref(prefs::kPinnedTabs); | 1599 prefs_watcher->GetBackupForPref(prefs::kPinnedTabs); |
1602 scoped_ptr<BaseSettingChange> change( | 1600 protector_service->ShowChange(protector::CreateSessionStartupChange( |
1603 protector::CreateSessionStartupChange( | 1601 new_pref, |
1604 new_pref, | 1602 new_tabs, |
1605 new_tabs, | 1603 SessionStartupPref::GetStartupPrefBackup(profile), |
1606 SessionStartupPref::GetStartupPrefBackup(profile), | 1604 PinnedTabCodec::ReadPinnedTabs(tabs_backup))); |
1607 PinnedTabCodec::ReadPinnedTabs(tabs_backup))); | 1605 } |
1608 protector_service->ShowChange(change.release()); | 1606 |
| 1607 // Check for homepage changes. |
| 1608 if (prefs_watcher->DidPrefChange(prefs::kHomePage) || |
| 1609 prefs_watcher->DidPrefChange(prefs::kHomePageIsNewTabPage) || |
| 1610 prefs_watcher->DidPrefChange(prefs::kShowHomeButton)) { |
| 1611 LOG(WARNING) << "Homepage has changed"; |
| 1612 PrefService* prefs = profile->GetPrefs(); |
| 1613 std::string backup_homepage; |
| 1614 bool backup_homepage_is_ntp; |
| 1615 bool backup_show_home_button; |
| 1616 if (!prefs_watcher->GetBackupForPref(prefs::kHomePage)-> |
| 1617 GetAsString(&backup_homepage) || |
| 1618 !prefs_watcher->GetBackupForPref(prefs::kHomePageIsNewTabPage)-> |
| 1619 GetAsBoolean(&backup_homepage_is_ntp) || |
| 1620 !prefs_watcher->GetBackupForPref(prefs::kShowHomeButton)-> |
| 1621 GetAsBoolean(&backup_show_home_button)) { |
| 1622 NOTREACHED(); |
| 1623 } |
| 1624 protector_service->ShowChange(protector::CreateHomepageChange( |
| 1625 // New: |
| 1626 prefs->GetString(prefs::kHomePage), |
| 1627 prefs->GetBoolean(prefs::kHomePageIsNewTabPage), |
| 1628 prefs->GetBoolean(prefs::kShowHomeButton), |
| 1629 // Backup: |
| 1630 backup_homepage, |
| 1631 backup_homepage_is_ntp, |
| 1632 backup_show_home_button)); |
1609 } | 1633 } |
1610 } | 1634 } |
1611 | 1635 |
1612 std::vector<GURL> BrowserInit::GetURLsFromCommandLine( | 1636 std::vector<GURL> BrowserInit::GetURLsFromCommandLine( |
1613 const CommandLine& command_line, | 1637 const CommandLine& command_line, |
1614 const FilePath& cur_dir, | 1638 const FilePath& cur_dir, |
1615 Profile* profile) { | 1639 Profile* profile) { |
1616 std::vector<GURL> urls; | 1640 std::vector<GURL> urls; |
1617 const CommandLine::StringVector& params = command_line.GetArgs(); | 1641 const CommandLine::StringVector& params = command_line.GetArgs(); |
1618 | 1642 |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1920 | 1944 |
1921 Profile* profile = ProfileManager::GetLastUsedProfile(); | 1945 Profile* profile = ProfileManager::GetLastUsedProfile(); |
1922 if (!profile) { | 1946 if (!profile) { |
1923 // We should only be able to get here if the profile already exists and | 1947 // We should only be able to get here if the profile already exists and |
1924 // has been created. | 1948 // has been created. |
1925 NOTREACHED(); | 1949 NOTREACHED(); |
1926 return; | 1950 return; |
1927 } | 1951 } |
1928 ProcessCmdLineImpl(cmd_line, cur_dir, false, profile, Profiles(), NULL, NULL); | 1952 ProcessCmdLineImpl(cmd_line, cur_dir, false, profile, Profiles(), NULL, NULL); |
1929 } | 1953 } |
OLD | NEW |