Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2009 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/browser/first_run.h" | 5 #include "chrome/browser/first_run.h" |
| 6 | 6 |
| 7 #import "base/scoped_nsobject.h" | 7 #import "base/scoped_nsobject.h" |
| 8 #include "base/sys_string_conversions.h" | 8 #include "base/sys_string_conversions.h" |
| 9 #import "chrome/app/breakpad_mac.h" | 9 #import "chrome/app/breakpad_mac.h" |
| 10 #import "chrome/browser/cocoa/first_run_dialog.h" | 10 #import "chrome/browser/cocoa/first_run_dialog.h" |
| 11 #include "chrome/browser/importer/importer.h" | |
| 11 #include "chrome/browser/metrics/user_metrics.h" | 12 #include "chrome/browser/metrics/user_metrics.h" |
| 12 #include "chrome/browser/shell_integration.h" | 13 #include "chrome/browser/shell_integration.h" |
| 13 #include "chrome/installer/util/google_update_constants.h" | 14 #include "chrome/installer/util/google_update_constants.h" |
| 14 #include "chrome/installer/util/google_update_settings.h" | 15 #include "chrome/installer/util/google_update_settings.h" |
| 15 | 16 |
| 16 // static | 17 // static |
| 17 bool FirstRun::IsChromeFirstRun() { | 18 bool FirstRun::IsChromeFirstRun() { |
| 18 #if defined(GOOGLE_CHROME_BUILD) | 19 #if defined(GOOGLE_CHROME_BUILD) |
| 19 // Use presence of kRegUsageStatsField key as an indicator of whether or not | 20 // Use presence of kRegUsageStatsField key as an indicator of whether or not |
| 20 // this is the first run. | 21 // this is the first run. |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 39 // opted-into stats. | 40 // opted-into stats. |
| 40 // TODO: The behavior we probably want here is to enable Breakpad on first run | 41 // TODO: The behavior we probably want here is to enable Breakpad on first run |
| 41 // but display a confirmation dialog before sending a crash report so we | 42 // but display a confirmation dialog before sending a crash report so we |
| 42 // respect a user's privacy while still getting any crashes that might happen | 43 // respect a user's privacy while still getting any crashes that might happen |
| 43 // before this point. Then remove the need for that dialog here. | 44 // before this point. Then remove the need for that dialog here. |
| 44 DCHECK(IsCrashReporterDisabled()); | 45 DCHECK(IsCrashReporterDisabled()); |
| 45 | 46 |
| 46 scoped_nsobject<FirstRunDialogController> dialog( | 47 scoped_nsobject<FirstRunDialogController> dialog( |
| 47 [[FirstRunDialogController alloc] init]); | 48 [[FirstRunDialogController alloc] init]); |
| 48 | 49 |
| 50 scoped_refptr<ImporterHost> importer_host(new ImporterHost()); | |
| 51 | |
| 52 // Set list of browsers we know how to import. | |
| 53 ssize_t profiles_count = importer_host->GetAvailableProfileCount(); | |
| 54 | |
| 55 // TODO(jeremy): Test on newly created account. | |
| 56 // TODO(jeremy): Correctly handle case where no browsers to import from | |
| 57 // are detected. | |
| 58 NSMutableArray *browsers = [NSMutableArray arrayWithCapacity:profiles_count]; | |
| 59 for (int i = 0; i < profiles_count; ++i) { | |
| 60 std::wstring profile = importer_host->GetSourceProfileNameAt(i); | |
| 61 [browsers addObject:base::SysWideToNSString(profile)]; | |
| 62 } | |
| 63 [dialog.get() setBrowserImportList:browsers]; | |
| 64 | |
| 49 // FirstRunDialogController will call exit if "Cancel" is clicked. | 65 // FirstRunDialogController will call exit if "Cancel" is clicked. |
| 50 [dialog.get() showWindow:nil]; | 66 [dialog.get() showWindow:nil]; |
| 51 | 67 |
| 52 // If user clicked cancel, bail. | 68 // If user clicked cancel, bail - browser_main will return if we haven't |
| 69 // turned off the first run flag when this function returns. | |
| 53 if ([dialog.get() userDidCancel]) { | 70 if ([dialog.get() userDidCancel]) { |
| 54 return false; | 71 return false; |
| 55 } | 72 } |
| 56 | 73 |
| 57 BOOL stats_enabled = [dialog.get() statsEnabled]; | 74 BOOL stats_enabled = [dialog.get() statsEnabled]; |
| 58 | 75 |
| 59 // Breakpad is normally enabled very early in the startup process, | 76 // Breakpad is normally enabled very early in the startup process, |
| 60 // however, on the first run it's off by default. If the user opts-in to | 77 // however, on the first run it's off by default. If the user opts-in to |
| 61 // stats, enable breakpad. | 78 // stats, enable breakpad. |
| 62 if (stats_enabled) { | 79 if (stats_enabled) { |
| 63 InitCrashReporter(); | 80 InitCrashReporter(); |
| 64 InitCrashProcessInfo(); | 81 InitCrashProcessInfo(); |
| 65 } | 82 } |
| 66 | 83 |
| 67 GoogleUpdateSettings::SetCollectStatsConsent(stats_enabled); | 84 GoogleUpdateSettings::SetCollectStatsConsent(stats_enabled); |
| 68 | 85 |
| 86 // If selected set as default browser. | |
| 69 BOOL make_default_browser = [dialog.get() makeDefaultBrowser]; | 87 BOOL make_default_browser = [dialog.get() makeDefaultBrowser]; |
| 70 if (make_default_browser) { | 88 if (make_default_browser) { |
| 71 bool success = ShellIntegration::SetAsDefaultBrowser(); | 89 bool success = ShellIntegration::SetAsDefaultBrowser(); |
| 72 DCHECK(success); | 90 DCHECK(success); |
| 73 } | 91 } |
| 74 | 92 |
| 75 // TODO(jeremy): Import Bookmarks. | 93 // Import bookmarks. |
| 94 // Utility class that does the actual import. | |
|
kuchhal
2009/07/29 20:28:09
Not sure if this comment makes sense. ProfileInfo
| |
| 95 const ProfileInfo& source_profile = importer_host->GetSourceProfileInfoAt( | |
| 96 [dialog.get() browserImportSelectedIndex]); | |
| 97 int items = SEARCH_ENGINES + HISTORY + FAVORITES + HOME_PAGE + PASSWORDS; | |
| 98 // TODO(port): Call StartImportingWithUI here instead and launch | |
| 99 // a new process that does the actual import. | |
| 100 importer_host->StartImportSettings(source_profile, profile, items, | |
| 101 new ProfileWriter(profile), true); | |
|
kuchhal
2009/07/29 20:28:09
reduce indentation by one space.
| |
| 76 | 102 |
| 77 #endif // defined(GOOGLE_CHROME_BUILD) | 103 #endif // defined(GOOGLE_CHROME_BUILD) |
| 78 return true; | 104 return true; |
| 79 } | 105 } |
| OLD | NEW |