OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/installer/util/master_preferences.h" |
5 | 6 |
6 #include "base/file_util.h" | 7 #include "base/file_util.h" |
7 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/path_service.h" |
8 #include "chrome/common/json_value_serializer.h" | 10 #include "chrome/common/json_value_serializer.h" |
9 #include "chrome/installer/util/master_preferences.h" | |
10 | 11 |
11 namespace { | 12 namespace { |
12 | 13 |
13 DictionaryValue* ReadJSONPrefs(const std::string& data) { | 14 DictionaryValue* ReadJSONPrefs(const std::string& data) { |
14 JSONStringValueSerializer json(data); | 15 JSONStringValueSerializer json(data); |
15 scoped_ptr<Value> root(json.Deserialize(NULL)); | 16 scoped_ptr<Value> root(json.Deserialize(NULL)); |
16 if (!root.get()) | 17 if (!root.get()) |
17 return NULL; | 18 return NULL; |
18 if (!root->IsType(Value::TYPE_DICTIONARY)) | 19 if (!root->IsType(Value::TYPE_DICTIONARY)) |
19 return NULL; | 20 return NULL; |
(...skipping 23 matching lines...) Expand all Loading... |
43 // Boolean pref that triggers skipping the first run dialogs. | 44 // Boolean pref that triggers skipping the first run dialogs. |
44 const wchar_t kDistroSkipFirstRunPref[] = L"skip_first_run_ui"; | 45 const wchar_t kDistroSkipFirstRunPref[] = L"skip_first_run_ui"; |
45 // Boolean pref that triggers loading the welcome page. | 46 // Boolean pref that triggers loading the welcome page. |
46 const wchar_t kDistroShowWelcomePage[] = L"show_welcome_page"; | 47 const wchar_t kDistroShowWelcomePage[] = L"show_welcome_page"; |
47 // Boolean pref that triggers silent import of the default search engine. | 48 // Boolean pref that triggers silent import of the default search engine. |
48 const wchar_t kDistroImportSearchPref[] = L"import_search_engine"; | 49 const wchar_t kDistroImportSearchPref[] = L"import_search_engine"; |
49 // Boolean pref that triggers silent import of the default browser history. | 50 // Boolean pref that triggers silent import of the default browser history. |
50 const wchar_t kDistroImportHistoryPref[] = L"import_history"; | 51 const wchar_t kDistroImportHistoryPref[] = L"import_history"; |
51 // Boolean pref that triggers silent import of the default browser bookmarks. | 52 // Boolean pref that triggers silent import of the default browser bookmarks. |
52 const wchar_t kDistroImportBookmarksPref[] = L"import_bookmarks"; | 53 const wchar_t kDistroImportBookmarksPref[] = L"import_bookmarks"; |
| 54 // RLZ ping delay in seconds |
| 55 const wchar_t kDistroPingDelay[] = L"ping_delay"; |
53 // Register Chrome as default browser for the current user. | 56 // Register Chrome as default browser for the current user. |
54 const wchar_t kMakeChromeDefaultForUser[] = L"make_chrome_default_for_user"; | 57 const wchar_t kMakeChromeDefaultForUser[] = L"make_chrome_default_for_user"; |
55 // The following boolean prefs have the same semantics as the corresponding | 58 // The following boolean prefs have the same semantics as the corresponding |
56 // setup command line switches. See chrome/installer/util/util_constants.cc | 59 // setup command line switches. See chrome/installer/util/util_constants.cc |
57 // for more info. | 60 // for more info. |
58 // Create Desktop and QuickLaunch shortcuts. | 61 // Create Desktop and QuickLaunch shortcuts. |
59 const wchar_t kCreateAllShortcuts[] = L"create_all_shortcuts"; | 62 const wchar_t kCreateAllShortcuts[] = L"create_all_shortcuts"; |
60 // Prevent installer from launching Chrome after a successful first install. | 63 // Prevent installer from launching Chrome after a successful first install. |
61 const wchar_t kDoNotLaunchChrome[] = L"do_not_launch_chrome"; | 64 const wchar_t kDoNotLaunchChrome[] = L"do_not_launch_chrome"; |
62 // Register Chrome as default browser on the system. | 65 // Register Chrome as default browser on the system. |
63 const wchar_t kMakeChromeDefault[] = L"make_chrome_default"; | 66 const wchar_t kMakeChromeDefault[] = L"make_chrome_default"; |
64 // Install Chrome to system wise location. | 67 // Install Chrome to system wise location. |
65 const wchar_t kSystemLevel[] = L"system_level"; | 68 const wchar_t kSystemLevel[] = L"system_level"; |
66 // Run installer in verbose mode. | 69 // Run installer in verbose mode. |
67 const wchar_t kVerboseLogging[] = L"verbose_logging"; | 70 const wchar_t kVerboseLogging[] = L"verbose_logging"; |
68 // Show EULA dialog and install only if accepted. | 71 // Show EULA dialog and install only if accepted. |
69 const wchar_t kRequireEula[] = L"require_eula"; | 72 const wchar_t kRequireEula[] = L"require_eula"; |
70 // Use alternate shortcut text for the main shortcut. | 73 // Use alternate shortcut text for the main shortcut. |
71 const wchar_t kAltShortcutText[] = L"alternate_shortcut_text"; | 74 const wchar_t kAltShortcutText[] = L"alternate_shortcut_text"; |
72 // Use alternate smaller first run info bubble. | 75 // Use alternate smaller first run info bubble. |
73 const wchar_t kAltFirstRunBubble[] = L"oem_bubble"; | 76 const wchar_t kAltFirstRunBubble[] = L"oem_bubble"; |
74 // Boolean pref that triggers silent import of the default browser homepage. | 77 // Boolean pref that triggers silent import of the default browser homepage. |
75 const wchar_t kDistroImportHomePagePref[] = L"import_home_page"; | 78 const wchar_t kDistroImportHomePagePref[] = L"import_home_page"; |
76 | 79 |
| 80 bool GetDistributionPingDelay(const FilePath& master_prefs_path, |
| 81 int& delay) { |
| 82 FilePath master_prefs = master_prefs_path; |
| 83 if (master_prefs.empty()) { |
| 84 if (!PathService::Get(base::DIR_EXE, &master_prefs)) |
| 85 return false; |
| 86 master_prefs = master_prefs.Append(installer_util::kDefaultMasterPrefs); |
| 87 } |
| 88 |
| 89 if (!file_util::PathExists(master_prefs)) |
| 90 return false; |
| 91 |
| 92 scoped_ptr<DictionaryValue> json_root( |
| 93 GetPrefsFromFile(master_prefs.ToWStringHack())); |
| 94 if (!json_root.get()) |
| 95 return false; |
| 96 |
| 97 DictionaryValue* distro = NULL; |
| 98 if (!json_root->GetDictionary(L"distribution", &distro) || |
| 99 !distro->GetInteger(kDistroPingDelay, &delay)) |
| 100 return false; |
| 101 |
| 102 return true; |
| 103 } |
| 104 |
77 int ParseDistributionPreferences(const std::wstring& master_prefs_path) { | 105 int ParseDistributionPreferences(const std::wstring& master_prefs_path) { |
78 if (!file_util::PathExists(master_prefs_path)) | 106 if (!file_util::PathExists(master_prefs_path)) |
79 return MASTER_PROFILE_NOT_FOUND; | 107 return MASTER_PROFILE_NOT_FOUND; |
80 LOG(INFO) << "master profile found"; | 108 LOG(INFO) << "master profile found"; |
81 | 109 |
82 scoped_ptr<DictionaryValue> json_root(GetPrefsFromFile(master_prefs_path)); | 110 scoped_ptr<DictionaryValue> json_root(GetPrefsFromFile(master_prefs_path)); |
83 if (!json_root.get()) | 111 if (!json_root.get()) |
84 return MASTER_PROFILE_ERROR; | 112 return MASTER_PROFILE_ERROR; |
85 | 113 |
86 int parse_result = 0; | 114 int parse_result = 0; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 if (!tabs_list->Get(i, &entry) || !entry->GetAsString(&tab_entry)) { | 163 if (!tabs_list->Get(i, &entry) || !entry->GetAsString(&tab_entry)) { |
136 NOTREACHED(); | 164 NOTREACHED(); |
137 break; | 165 break; |
138 } | 166 } |
139 launch_tabs.push_back(tab_entry); | 167 launch_tabs.push_back(tab_entry); |
140 } | 168 } |
141 return launch_tabs; | 169 return launch_tabs; |
142 } | 170 } |
143 | 171 |
144 } // installer_util | 172 } // installer_util |
OLD | NEW |