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 1564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1575 } | 1575 } |
1576 #endif | 1576 #endif |
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 // BaseSettingChange instances are always created, even when Protector is | |
1586 // disabled, to report corresponding histograms. With Protector disabled, | |
1587 // the backup is updated to match the new setting value, otherwise histograms | |
1588 // would be reported on each run. | |
1589 // TODO(ivankr): move IsEnabled() check to ProtectorService::ShowChange(). | |
1590 | |
1591 // Check if backup is valid. | 1585 // Check if backup is valid. |
1592 if (!prefs_watcher->is_backup_valid()) { | 1586 if (!prefs_watcher->is_backup_valid()) { |
1593 scoped_ptr<BaseSettingChange> change( | 1587 scoped_ptr<BaseSettingChange> change( |
1594 protector::CreatePrefsBackupInvalidChange()); | 1588 protector::CreatePrefsBackupInvalidChange()); |
1595 if (protector::IsEnabled()) | 1589 protector_service->ShowChange(change.release()); |
1596 protector_service->ShowChange(change.release()); | |
1597 // Further checks make no sense. | 1590 // Further checks make no sense. |
1598 return; | 1591 return; |
1599 } | 1592 } |
1600 | 1593 |
1601 // Check for session startup (including pinned tabs) changes. | 1594 // Check for session startup (including pinned tabs) changes. |
1602 if (SessionStartupPref::DidStartupPrefChange(profile) || | 1595 if (SessionStartupPref::DidStartupPrefChange(profile) || |
1603 prefs_watcher->DidPrefChange(prefs::kPinnedTabs)) { | 1596 prefs_watcher->DidPrefChange(prefs::kPinnedTabs)) { |
1604 LOG(WARNING) << "Session startup settings have changed"; | 1597 LOG(WARNING) << "Session startup settings have changed"; |
1605 SessionStartupPref new_pref = SessionStartupPref::GetStartupPref(profile); | 1598 SessionStartupPref new_pref = SessionStartupPref::GetStartupPref(profile); |
1606 PinnedTabCodec::Tabs new_tabs = PinnedTabCodec::ReadPinnedTabs(profile); | 1599 PinnedTabCodec::Tabs new_tabs = PinnedTabCodec::ReadPinnedTabs(profile); |
1607 const base::Value* tabs_backup = | 1600 const base::Value* tabs_backup = |
1608 prefs_watcher->GetBackupForPref(prefs::kPinnedTabs); | 1601 prefs_watcher->GetBackupForPref(prefs::kPinnedTabs); |
1609 scoped_ptr<BaseSettingChange> change( | 1602 scoped_ptr<BaseSettingChange> change( |
1610 protector::CreateSessionStartupChange( | 1603 protector::CreateSessionStartupChange( |
1611 new_pref, | 1604 new_pref, |
1612 new_tabs, | 1605 new_tabs, |
1613 SessionStartupPref::GetStartupPrefBackup(profile), | 1606 SessionStartupPref::GetStartupPrefBackup(profile), |
1614 PinnedTabCodec::ReadPinnedTabs(tabs_backup))); | 1607 PinnedTabCodec::ReadPinnedTabs(tabs_backup))); |
1615 if (protector::IsEnabled()) { | 1608 protector_service->ShowChange(change.release()); |
1616 protector_service->ShowChange(change.release()); | |
1617 } else { | |
1618 SessionStartupPref::SetStartupPref(profile, new_pref); | |
1619 PinnedTabCodec::WritePinnedTabs(profile, new_tabs); | |
1620 } | |
1621 } | 1609 } |
1622 } | 1610 } |
1623 | 1611 |
1624 std::vector<GURL> BrowserInit::GetURLsFromCommandLine( | 1612 std::vector<GURL> BrowserInit::GetURLsFromCommandLine( |
1625 const CommandLine& command_line, | 1613 const CommandLine& command_line, |
1626 const FilePath& cur_dir, | 1614 const FilePath& cur_dir, |
1627 Profile* profile) { | 1615 Profile* profile) { |
1628 std::vector<GURL> urls; | 1616 std::vector<GURL> urls; |
1629 const CommandLine::StringVector& params = command_line.GetArgs(); | 1617 const CommandLine::StringVector& params = command_line.GetArgs(); |
1630 | 1618 |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1932 | 1920 |
1933 Profile* profile = ProfileManager::GetLastUsedProfile(); | 1921 Profile* profile = ProfileManager::GetLastUsedProfile(); |
1934 if (!profile) { | 1922 if (!profile) { |
1935 // We should only be able to get here if the profile already exists and | 1923 // We should only be able to get here if the profile already exists and |
1936 // has been created. | 1924 // has been created. |
1937 NOTREACHED(); | 1925 NOTREACHED(); |
1938 return; | 1926 return; |
1939 } | 1927 } |
1940 ProcessCmdLineImpl(cmd_line, cur_dir, false, profile, Profiles(), NULL, NULL); | 1928 ProcessCmdLineImpl(cmd_line, cur_dir, false, profile, Profiles(), NULL, NULL); |
1941 } | 1929 } |
OLD | NEW |