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

Side by Side Diff: chrome/browser/first_run/first_run.cc

Issue 9016036: Implement the new first run bubble, clean up old bubbles. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync and merge, fix SetShowFirstRunBubblePref and test, update copyright years. Created 8 years, 11 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 | Annotate | Revision Log
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 "chrome/browser/first_run/first_run.h" 5 #include "chrome/browser/first_run/first_run.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 if (IsOrganicFirstRun() && !local_state_file_exists) { 231 if (IsOrganicFirstRun() && !local_state_file_exists) {
232 // The home page string may be set in the preferences, but the user should 232 // The home page string may be set in the preferences, but the user should
233 // initially use Chrome with the NTP as home page in organic builds. 233 // initially use Chrome with the NTP as home page in organic builds.
234 profile->GetPrefs()->SetBoolean(prefs::kHomePageIsNewTabPage, true); 234 profile->GetPrefs()->SetBoolean(prefs::kHomePageIsNewTabPage, true);
235 ShowFirstRunDialog(profile, randomize_search_engine_experiment); 235 ShowFirstRunDialog(profile, randomize_search_engine_experiment);
236 } 236 }
237 237
238 if (make_chrome_default) 238 if (make_chrome_default)
239 ShellIntegration::SetAsDefaultBrowser(); 239 ShellIntegration::SetAsDefaultBrowser();
240 240
241 // Don't display the minimal bubble if there is no default search provider. 241 // Display the first run bubble if there is a default search provider.
242 TemplateURLService* search_engines_model = 242 TemplateURLService* template_url =
243 TemplateURLServiceFactory::GetForProfile(profile); 243 TemplateURLServiceFactory::GetForProfile(profile);
244 if (search_engines_model && 244 if (template_url && template_url->GetDefaultSearchProvider())
245 search_engines_model->GetDefaultSearchProvider()) {
246 SetShowFirstRunBubblePref(true); 245 SetShowFirstRunBubblePref(true);
247 // Set the first run bubble to minimal.
248 SetMinimalFirstRunBubblePref();
249 }
250 SetShowWelcomePagePref(); 246 SetShowWelcomePagePref();
251 SetPersonalDataManagerFirstRunPref(); 247 SetPersonalDataManagerFirstRunPref();
252 } 248 }
253 #endif // !defined(USE_AURA) 249 #endif // !defined(USE_AURA)
254 250
255 int ImportBookmarkFromFileIfNeeded(Profile* profile, 251 int ImportBookmarkFromFileIfNeeded(Profile* profile,
256 const CommandLine& cmdline) { 252 const CommandLine& cmdline) {
257 int return_code = true; 253 int return_code = true;
258 if (cmdline.HasSwitch(switches::kImportFromFile)) { 254 if (cmdline.HasSwitch(switches::kImportFromFile)) {
259 // Silently import preset bookmarks from file. 255 // Silently import preset bookmarks from file.
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 FilePath first_run_sentinel; 289 FilePath first_run_sentinel;
294 if (!internal::GetFirstRunSentinelFilePath(&first_run_sentinel)) 290 if (!internal::GetFirstRunSentinelFilePath(&first_run_sentinel))
295 return false; 291 return false;
296 return file_util::Delete(first_run_sentinel, false); 292 return file_util::Delete(first_run_sentinel, false);
297 } 293 }
298 294
299 bool SetShowFirstRunBubblePref(bool show_bubble) { 295 bool SetShowFirstRunBubblePref(bool show_bubble) {
300 PrefService* local_state = g_browser_process->local_state(); 296 PrefService* local_state = g_browser_process->local_state();
301 if (!local_state) 297 if (!local_state)
302 return false; 298 return false;
303 if (!local_state->HasPrefPath(prefs::kShouldShowFirstRunBubble)) 299 local_state->SetBoolean(prefs::kShouldShowFirstRunBubble, show_bubble);
304 local_state->SetBoolean(prefs::kShouldShowFirstRunBubble, show_bubble);
305 return true; 300 return true;
306 } 301 }
307 302
308 bool SetMinimalFirstRunBubblePref() {
309 PrefService* local_state = g_browser_process->local_state();
310 if (!local_state)
311 return false;
312 if (!local_state->FindPreference(prefs::kShouldUseMinimalFirstRunBubble)) {
313 local_state->RegisterBooleanPref(prefs::kShouldUseMinimalFirstRunBubble,
314 false);
315 local_state->SetBoolean(prefs::kShouldUseMinimalFirstRunBubble, true);
316 }
317 return true;
318 }
319
320 bool SetShowWelcomePagePref() { 303 bool SetShowWelcomePagePref() {
321 PrefService* local_state = g_browser_process->local_state(); 304 PrefService* local_state = g_browser_process->local_state();
322 if (!local_state) 305 if (!local_state)
323 return false; 306 return false;
324 if (!local_state->FindPreference(prefs::kShouldShowWelcomePage)) { 307 if (!local_state->FindPreference(prefs::kShouldShowWelcomePage)) {
325 local_state->RegisterBooleanPref(prefs::kShouldShowWelcomePage, false); 308 local_state->RegisterBooleanPref(prefs::kShouldShowWelcomePage, false);
326 local_state->SetBoolean(prefs::kShouldShowWelcomePage, true); 309 local_state->SetBoolean(prefs::kShouldShowWelcomePage, true);
327 } 310 }
328 return true; 311 return true;
329 } 312 }
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 VLOG(1) << "EULA : no collection"; 388 VLOG(1) << "EULA : no collection";
406 GoogleUpdateSettings::SetCollectStatsConsent(false); 389 GoogleUpdateSettings::SetCollectStatsConsent(false);
407 } else if (retcode == installer::EULA_ACCEPTED_OPT_IN) { 390 } else if (retcode == installer::EULA_ACCEPTED_OPT_IN) {
408 VLOG(1) << "EULA : collection consent"; 391 VLOG(1) << "EULA : collection consent";
409 GoogleUpdateSettings::SetCollectStatsConsent(true); 392 GoogleUpdateSettings::SetCollectStatsConsent(true);
410 } 393 }
411 } 394 }
412 } 395 }
413 #endif 396 #endif
414 397
415 if (prefs.GetBool(installer::master_preferences::kAltFirstRunBubble,
416 &value) && value) {
417 FirstRun::SetOEMFirstRunBubblePref();
418 }
419
420 FilePath user_prefs = GetDefaultPrefFilePath(true, user_data_dir); 398 FilePath user_prefs = GetDefaultPrefFilePath(true, user_data_dir);
421 if (user_prefs.empty()) 399 if (user_prefs.empty())
422 return true; 400 return true;
423 401
424 // The master prefs are regular prefs so we can just copy the file 402 // The master prefs are regular prefs so we can just copy the file
425 // to the default place and they just work. 403 // to the default place and they just work.
426 if (!file_util::CopyFile(master_prefs, user_prefs)) 404 if (!file_util::CopyFile(master_prefs, user_prefs))
427 return true; 405 return true;
428 406
429 #if defined(OS_WIN) 407 #if defined(OS_WIN)
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 } 567 }
590 } 568 }
591 569
592 return false; 570 return false;
593 } 571 }
594 572
595 // static 573 // static
596 bool FirstRun::ShouldShowSearchEngineSelector(const TemplateURLService* model) { 574 bool FirstRun::ShouldShowSearchEngineSelector(const TemplateURLService* model) {
597 return model && !model->is_default_search_managed(); 575 return model && !model->is_default_search_managed();
598 } 576 }
599
600 // static
601 bool FirstRun::SetOEMFirstRunBubblePref() {
602 PrefService* local_state = g_browser_process->local_state();
603 if (!local_state)
604 return false;
605 if (!local_state->FindPreference(prefs::kShouldUseOEMFirstRunBubble)) {
606 local_state->RegisterBooleanPref(prefs::kShouldUseOEMFirstRunBubble, false);
607 local_state->SetBoolean(prefs::kShouldUseOEMFirstRunBubble, true);
608 }
609 return true;
610 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698