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 #include "base/mac/mac_util.h" | 9 #include "base/mac/mac_util.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 } | 71 } |
72 | 72 |
73 void FirstRunShowBridge::ShowDialog() { | 73 void FirstRunShowBridge::ShowDialog() { |
74 [controller_ show]; | 74 [controller_ show]; |
75 MessageLoop::current()->QuitNow(); | 75 MessageLoop::current()->QuitNow(); |
76 } | 76 } |
77 | 77 |
78 FirstRunShowBridge::~FirstRunShowBridge() {} | 78 FirstRunShowBridge::~FirstRunShowBridge() {} |
79 | 79 |
80 // Show the first run UI. | 80 // Show the first run UI. |
81 void ShowFirstRun(Profile* profile) { | 81 // Returns true if the first run dialog was shown. |
| 82 bool ShowFirstRun(Profile* profile) { |
| 83 bool dialog_shown = false; |
82 #if defined(GOOGLE_CHROME_BUILD) | 84 #if defined(GOOGLE_CHROME_BUILD) |
83 // The purpose of the dialog is to ask the user to enable stats and crash | 85 // The purpose of the dialog is to ask the user to enable stats and crash |
84 // reporting. This setting may be controlled through configuration management | 86 // reporting. This setting may be controlled through configuration management |
85 // in enterprise scenarios. If that is the case, skip the dialog entirely, as | 87 // in enterprise scenarios. If that is the case, skip the dialog entirely, as |
86 // it's not worth bothering the user for only the default browser question | 88 // it's not worth bothering the user for only the default browser question |
87 // (which is likely to be forced in enterprise deployments anyway). | 89 // (which is likely to be forced in enterprise deployments anyway). |
88 const PrefService::Preference* metrics_reporting_pref = | 90 const PrefService::Preference* metrics_reporting_pref = |
89 g_browser_process->local_state()->FindPreference( | 91 g_browser_process->local_state()->FindPreference( |
90 prefs::kMetricsReportingEnabled); | 92 prefs::kMetricsReportingEnabled); |
91 if (!metrics_reporting_pref || !metrics_reporting_pref->IsManaged()) { | 93 if (!metrics_reporting_pref || !metrics_reporting_pref->IsManaged()) { |
92 scoped_nsobject<FirstRunDialogController> dialog( | 94 scoped_nsobject<FirstRunDialogController> dialog( |
93 [[FirstRunDialogController alloc] init]); | 95 [[FirstRunDialogController alloc] init]); |
94 | 96 |
95 [dialog.get() showWindow:nil]; | 97 [dialog.get() showWindow:nil]; |
| 98 dialog_shown = true; |
96 | 99 |
97 // If the dialog asked the user to opt-in for stats and crash reporting, | 100 // If the dialog asked the user to opt-in for stats and crash reporting, |
98 // record the decision and enable the crash reporter if appropriate. | 101 // record the decision and enable the crash reporter if appropriate. |
99 bool stats_enabled = [dialog.get() statsEnabled]; | 102 bool stats_enabled = [dialog.get() statsEnabled]; |
100 GoogleUpdateSettings::SetCollectStatsConsent(stats_enabled); | 103 GoogleUpdateSettings::SetCollectStatsConsent(stats_enabled); |
101 | 104 |
102 // Breakpad is normally enabled very early in the startup process. However, | 105 // Breakpad is normally enabled very early in the startup process. However, |
103 // on the first run it may not have been enabled due to the missing opt-in | 106 // on the first run it may not have been enabled due to the missing opt-in |
104 // from the user. If the user agreed now, enable breakpad if necessary. | 107 // from the user. If the user agreed now, enable breakpad if necessary. |
105 if (!IsCrashReporterEnabled() && stats_enabled) { | 108 if (!IsCrashReporterEnabled() && stats_enabled) { |
(...skipping 16 matching lines...) Expand all Loading... |
122 | 125 |
123 // Set preference to show first run bubble and welcome page. | 126 // Set preference to show first run bubble and welcome page. |
124 // Only display the bubble if there is a default search provider. | 127 // Only display the bubble if there is a default search provider. |
125 TemplateURLService* search_engines_model = | 128 TemplateURLService* search_engines_model = |
126 TemplateURLServiceFactory::GetForProfile(profile); | 129 TemplateURLServiceFactory::GetForProfile(profile); |
127 if (search_engines_model && | 130 if (search_engines_model && |
128 search_engines_model->GetDefaultSearchProvider()) { | 131 search_engines_model->GetDefaultSearchProvider()) { |
129 first_run::SetShowFirstRunBubblePref(first_run::FIRST_RUN_BUBBLE_SHOW); | 132 first_run::SetShowFirstRunBubblePref(first_run::FIRST_RUN_BUBBLE_SHOW); |
130 } | 133 } |
131 first_run::SetShouldShowWelcomePage(); | 134 first_run::SetShouldShowWelcomePage(); |
| 135 |
| 136 return dialog_shown; |
132 } | 137 } |
133 | 138 |
134 // True when the stats checkbox should be checked by default. This is only | 139 // True when the stats checkbox should be checked by default. This is only |
135 // the case when the canary is running. | 140 // the case when the canary is running. |
136 bool StatsCheckboxDefault() { | 141 bool StatsCheckboxDefault() { |
137 return chrome::VersionInfo::GetChannel() == | 142 return chrome::VersionInfo::GetChannel() == |
138 chrome::VersionInfo::CHANNEL_CANARY; | 143 chrome::VersionInfo::CHANNEL_CANARY; |
139 } | 144 } |
140 | 145 |
141 } // namespace | 146 } // namespace |
142 | 147 |
143 namespace first_run { | 148 namespace first_run { |
144 | 149 |
145 void ShowFirstRunDialog(Profile* profile) { | 150 bool ShowFirstRunDialog(Profile* profile) { |
146 ShowFirstRun(profile); | 151 return ShowFirstRun(profile); |
147 } | 152 } |
148 | 153 |
149 } // namespace first_run | 154 } // namespace first_run |
150 | 155 |
151 @implementation FirstRunDialogController | 156 @implementation FirstRunDialogController |
152 | 157 |
153 @synthesize statsEnabled = statsEnabled_; | 158 @synthesize statsEnabled = statsEnabled_; |
154 @synthesize makeDefaultBrowser = makeDefaultBrowser_; | 159 @synthesize makeDefaultBrowser = makeDefaultBrowser_; |
155 | 160 |
156 - (id)init { | 161 - (id)init { |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 [NSApp stopModal]; | 291 [NSApp stopModal]; |
287 } | 292 } |
288 | 293 |
289 - (IBAction)learnMore:(id)sender { | 294 - (IBAction)learnMore:(id)sender { |
290 NSString* urlStr = base::SysUTF8ToNSString(chrome::kLearnMoreReportingURL); | 295 NSString* urlStr = base::SysUTF8ToNSString(chrome::kLearnMoreReportingURL); |
291 NSURL* learnMoreUrl = [NSURL URLWithString:urlStr]; | 296 NSURL* learnMoreUrl = [NSURL URLWithString:urlStr]; |
292 [[NSWorkspace sharedWorkspace] openURL:learnMoreUrl]; | 297 [[NSWorkspace sharedWorkspace] openURL:learnMoreUrl]; |
293 } | 298 } |
294 | 299 |
295 @end | 300 @end |
OLD | NEW |