| 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 #import "chrome/browser/ui/cocoa/first_run_dialog.h" | 5 #import "chrome/browser/ui/cocoa/first_run_dialog.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/mac/bundle_locations.h" | 8 #include "base/mac/bundle_locations.h" |
| 9 #import "base/mac/scoped_nsobject.h" | 9 #import "base/mac/scoped_nsobject.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| 11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
| 12 #include "base/strings/sys_string_conversions.h" | 12 #include "base/strings/sys_string_conversions.h" |
| 13 #include "chrome/browser/first_run/first_run.h" | 13 #include "chrome/browser/first_run/first_run.h" |
| 14 #include "chrome/browser/first_run/first_run_dialog.h" | 14 #include "chrome/browser/first_run/first_run_dialog.h" |
| 15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
| 16 #include "chrome/browser/search_engines/template_url_service_factory.h" | 16 #include "chrome/browser/search_engines/template_url_service_factory.h" |
| 17 #include "chrome/browser/shell_integration.h" | 17 #include "chrome/browser/shell_integration.h" |
| 18 #include "chrome/common/chrome_version_info.h" | 18 #include "chrome/common/chrome_version_info.h" |
| 19 #include "chrome/common/url_constants.h" | 19 #include "chrome/common/url_constants.h" |
| 20 #include "components/search_engines/template_url_service.h" | 20 #include "components/search_engines/template_url_service.h" |
| 21 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMUILocalizerAndLayoutTw
eaker.h" | 21 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMUILocalizerAndLayoutTw
eaker.h" |
| 22 #include "ui/base/l10n/l10n_util_mac.h" | 22 #include "ui/base/l10n/l10n_util_mac.h" |
| 23 #include "url/gurl.h" | 23 #include "url/gurl.h" |
| 24 | 24 |
| 25 #if defined(GOOGLE_CHROME_BUILD) | 25 #if defined(GOOGLE_CHROME_BUILD) |
| 26 #include "base/prefs/pref_service.h" | 26 #include "base/prefs/pref_service.h" |
| 27 #include "chrome/browser/browser_process.h" | 27 #include "chrome/browser/browser_process.h" |
| 28 #include "chrome/common/pref_names.h" | 28 #include "chrome/common/pref_names.h" |
| 29 #include "chrome/installer/util/google_update_settings.h" | 29 #include "chrome/installer/util/google_update_settings.h" |
| 30 #import "components/crash/app/breakpad_mac.h" | |
| 31 #endif | 30 #endif |
| 32 | 31 |
| 33 @interface FirstRunDialogController (PrivateMethods) | 32 @interface FirstRunDialogController (PrivateMethods) |
| 34 // Show the dialog. | 33 // Show the dialog. |
| 35 - (void)show; | 34 - (void)show; |
| 36 @end | 35 @end |
| 37 | 36 |
| 38 namespace { | 37 namespace { |
| 39 | 38 |
| 40 // Compare function for -[NSArray sortedArrayUsingFunction:context:] that | 39 // Compare function for -[NSArray sortedArrayUsingFunction:context:] that |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 [[FirstRunDialogController alloc] init]); | 92 [[FirstRunDialogController alloc] init]); |
| 94 | 93 |
| 95 [dialog.get() showWindow:nil]; | 94 [dialog.get() showWindow:nil]; |
| 96 dialog_shown = true; | 95 dialog_shown = true; |
| 97 | 96 |
| 98 // If the dialog asked the user to opt-in for stats and crash reporting, | 97 // If the dialog asked the user to opt-in for stats and crash reporting, |
| 99 // record the decision and enable the crash reporter if appropriate. | 98 // record the decision and enable the crash reporter if appropriate. |
| 100 bool stats_enabled = [dialog.get() statsEnabled]; | 99 bool stats_enabled = [dialog.get() statsEnabled]; |
| 101 GoogleUpdateSettings::SetCollectStatsConsent(stats_enabled); | 100 GoogleUpdateSettings::SetCollectStatsConsent(stats_enabled); |
| 102 | 101 |
| 103 // Breakpad is normally enabled very early in the startup process. However, | |
| 104 // on the first run it may not have been enabled due to the missing opt-in | |
| 105 // from the user. If the user agreed now, enable breakpad if necessary. | |
| 106 if (!breakpad::IsCrashReporterEnabled() && stats_enabled) { | |
| 107 breakpad::InitCrashReporter(std::string()); | |
| 108 breakpad::InitCrashProcessInfo(std::string()); | |
| 109 } | |
| 110 | |
| 111 // If selected set as default browser. | 102 // If selected set as default browser. |
| 112 BOOL make_default_browser = [dialog.get() makeDefaultBrowser]; | 103 BOOL make_default_browser = [dialog.get() makeDefaultBrowser]; |
| 113 if (make_default_browser) { | 104 if (make_default_browser) { |
| 114 bool success = ShellIntegration::SetAsDefaultBrowser(); | 105 bool success = ShellIntegration::SetAsDefaultBrowser(); |
| 115 DCHECK(success); | 106 DCHECK(success); |
| 116 } | 107 } |
| 117 } | 108 } |
| 118 #else // GOOGLE_CHROME_BUILD | 109 #else // GOOGLE_CHROME_BUILD |
| 119 // We don't show the dialog in Chromium. | 110 // We don't show the dialog in Chromium. |
| 120 #endif // GOOGLE_CHROME_BUILD | 111 #endif // GOOGLE_CHROME_BUILD |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 [NSApp stopModal]; | 278 [NSApp stopModal]; |
| 288 } | 279 } |
| 289 | 280 |
| 290 - (IBAction)learnMore:(id)sender { | 281 - (IBAction)learnMore:(id)sender { |
| 291 NSString* urlStr = base::SysUTF8ToNSString(chrome::kLearnMoreReportingURL); | 282 NSString* urlStr = base::SysUTF8ToNSString(chrome::kLearnMoreReportingURL); |
| 292 NSURL* learnMoreUrl = [NSURL URLWithString:urlStr]; | 283 NSURL* learnMoreUrl = [NSURL URLWithString:urlStr]; |
| 293 [[NSWorkspace sharedWorkspace] openURL:learnMoreUrl]; | 284 [[NSWorkspace sharedWorkspace] openURL:learnMoreUrl]; |
| 294 } | 285 } |
| 295 | 286 |
| 296 @end | 287 @end |
| OLD | NEW |