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" |
11 #import "base/memory/scoped_nsobject.h" | 11 #import "base/memory/scoped_nsobject.h" |
12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
13 #include "base/sys_string_conversions.h" | 13 #include "base/sys_string_conversions.h" |
14 #include "chrome/browser/first_run/first_run.h" | 14 #include "chrome/browser/first_run/first_run.h" |
15 #include "chrome/browser/first_run/first_run_dialog.h" | 15 #include "chrome/browser/first_run/first_run_dialog.h" |
16 #include "chrome/browser/google/google_util.h" | 16 #include "chrome/browser/google/google_util.h" |
17 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
18 #include "chrome/browser/search_engines/template_url_service.h" | 18 #include "chrome/browser/search_engines/template_url_service.h" |
19 #include "chrome/browser/search_engines/template_url_service_factory.h" | 19 #include "chrome/browser/search_engines/template_url_service_factory.h" |
20 #include "chrome/browser/shell_integration.h" | 20 #include "chrome/browser/shell_integration.h" |
21 #import "chrome/browser/ui/cocoa/search_engine_dialog_controller.h" | |
22 #include "chrome/common/chrome_version_info.h" | 21 #include "chrome/common/chrome_version_info.h" |
23 #include "chrome/common/url_constants.h" | 22 #include "chrome/common/url_constants.h" |
24 #include "googleurl/src/gurl.h" | 23 #include "googleurl/src/gurl.h" |
25 #include "grit/locale_settings.h" | 24 #include "grit/locale_settings.h" |
26 #import "third_party/GTM/AppKit/GTMUILocalizerAndLayoutTweaker.h" | 25 #import "third_party/GTM/AppKit/GTMUILocalizerAndLayoutTweaker.h" |
27 #include "ui/base/l10n/l10n_util_mac.h" | 26 #include "ui/base/l10n/l10n_util_mac.h" |
28 | 27 |
29 #if defined(GOOGLE_CHROME_BUILD) | 28 #if defined(GOOGLE_CHROME_BUILD) |
30 #import "chrome/app/breakpad_mac.h" | 29 #import "chrome/app/breakpad_mac.h" |
31 #include "chrome/browser/browser_process.h" | 30 #include "chrome/browser/browser_process.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 | 64 |
66 FirstRunShowBridge::FirstRunShowBridge( | 65 FirstRunShowBridge::FirstRunShowBridge( |
67 FirstRunDialogController* controller) : controller_(controller) { | 66 FirstRunDialogController* controller) : controller_(controller) { |
68 } | 67 } |
69 | 68 |
70 void FirstRunShowBridge::ShowDialog() { | 69 void FirstRunShowBridge::ShowDialog() { |
71 [controller_ show]; | 70 [controller_ show]; |
72 MessageLoop::current()->QuitNow(); | 71 MessageLoop::current()->QuitNow(); |
73 } | 72 } |
74 | 73 |
75 // Show the search engine selection dialog. | |
76 void ShowSearchEngineSelectionDialog(Profile* profile, | |
77 bool randomize_search_engine_experiment) { | |
78 scoped_nsobject<SearchEngineDialogController> dialog( | |
79 [[SearchEngineDialogController alloc] init]); | |
80 [dialog.get() setProfile:profile]; | |
81 [dialog.get() setRandomize:randomize_search_engine_experiment]; | |
82 | |
83 [dialog.get() showWindow:nil]; | |
84 } | |
85 | |
86 // Show the first run UI. | 74 // Show the first run UI. |
87 void ShowFirstRun(Profile* profile) { | 75 void ShowFirstRun(Profile* profile) { |
88 #if defined(GOOGLE_CHROME_BUILD) | 76 #if defined(GOOGLE_CHROME_BUILD) |
89 // The purpose of the dialog is to ask the user to enable stats and crash | 77 // The purpose of the dialog is to ask the user to enable stats and crash |
90 // reporting. This setting may be controlled through configuration management | 78 // reporting. This setting may be controlled through configuration management |
91 // in enterprise scenarios. If that is the case, skip the dialog entirely, as | 79 // in enterprise scenarios. If that is the case, skip the dialog entirely, as |
92 // it's not worth bothering the user for only the default browser question | 80 // it's not worth bothering the user for only the default browser question |
93 // (which is likely to be forced in enterprise deployments anyway). | 81 // (which is likely to be forced in enterprise deployments anyway). |
94 const PrefService::Preference* metrics_reporting_pref = | 82 const PrefService::Preference* metrics_reporting_pref = |
95 g_browser_process->local_state()->FindPreference( | 83 g_browser_process->local_state()->FindPreference( |
(...skipping 24 matching lines...) Expand all Loading... |
120 DCHECK(success); | 108 DCHECK(success); |
121 } | 109 } |
122 } | 110 } |
123 #else // GOOGLE_CHROME_BUILD | 111 #else // GOOGLE_CHROME_BUILD |
124 // We don't show the dialog in Chromium. | 112 // We don't show the dialog in Chromium. |
125 #endif // GOOGLE_CHROME_BUILD | 113 #endif // GOOGLE_CHROME_BUILD |
126 | 114 |
127 first_run::CreateSentinel(); | 115 first_run::CreateSentinel(); |
128 | 116 |
129 // Set preference to show first run bubble and welcome page. | 117 // Set preference to show first run bubble and welcome page. |
130 // Don't display the minimal bubble if there is no default search provider. | 118 // Only display the bubble if there is a default search provider. |
131 TemplateURLService* search_engines_model = | 119 TemplateURLService* search_engines_model = |
132 TemplateURLServiceFactory::GetForProfile(profile); | 120 TemplateURLServiceFactory::GetForProfile(profile); |
133 if (search_engines_model && | 121 if (search_engines_model && |
134 search_engines_model->GetDefaultSearchProvider()) { | 122 search_engines_model->GetDefaultSearchProvider()) { |
135 first_run::SetShowFirstRunBubblePref(true); | 123 first_run::SetShowFirstRunBubblePref(true); |
136 } | 124 } |
137 first_run::SetShowWelcomePagePref(); | 125 first_run::SetShowWelcomePagePref(); |
138 } | 126 } |
139 | 127 |
140 // True when the stats checkbox should be checked by default. This is only | 128 // True when the stats checkbox should be checked by default. This is only |
141 // the case when the canary is running. | 129 // the case when the canary is running. |
142 bool StatsCheckboxDefault() { | 130 bool StatsCheckboxDefault() { |
143 return chrome::VersionInfo::GetChannel() == | 131 return chrome::VersionInfo::GetChannel() == |
144 chrome::VersionInfo::CHANNEL_CANARY; | 132 chrome::VersionInfo::CHANNEL_CANARY; |
145 } | 133 } |
146 | 134 |
147 } // namespace | 135 } // namespace |
148 | 136 |
149 namespace first_run { | 137 namespace first_run { |
150 | 138 |
151 void ShowFirstRunDialog(Profile* profile, | 139 void ShowFirstRunDialog(Profile* profile) { |
152 bool randomize_search_engine_experiment) { | |
153 // If the default search is not managed via policy, ask the user to | |
154 // choose a default. | |
155 TemplateURLService* model = TemplateURLServiceFactory::GetForProfile(profile); | |
156 if (first_run::ShouldShowSearchEngineSelector(model)) { | |
157 ShowSearchEngineSelectionDialog(profile, | |
158 randomize_search_engine_experiment); | |
159 } | |
160 ShowFirstRun(profile); | 140 ShowFirstRun(profile); |
161 } | 141 } |
162 | 142 |
163 } // namespace first_run | 143 } // namespace first_run |
164 | 144 |
165 @implementation FirstRunDialogController | 145 @implementation FirstRunDialogController |
166 | 146 |
167 @synthesize statsEnabled = statsEnabled_; | 147 @synthesize statsEnabled = statsEnabled_; |
168 @synthesize makeDefaultBrowser = makeDefaultBrowser_; | 148 @synthesize makeDefaultBrowser = makeDefaultBrowser_; |
169 | 149 |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 | 281 |
302 - (IBAction)learnMore:(id)sender { | 282 - (IBAction)learnMore:(id)sender { |
303 GURL url = google_util::AppendGoogleLocaleParam( | 283 GURL url = google_util::AppendGoogleLocaleParam( |
304 GURL(chrome::kLearnMoreReportingURL)); | 284 GURL(chrome::kLearnMoreReportingURL)); |
305 NSString* urlStr = base::SysUTF8ToNSString(url.spec());; | 285 NSString* urlStr = base::SysUTF8ToNSString(url.spec());; |
306 NSURL* learnMoreUrl = [NSURL URLWithString:urlStr]; | 286 NSURL* learnMoreUrl = [NSURL URLWithString:urlStr]; |
307 [[NSWorkspace sharedWorkspace] openURL:learnMoreUrl]; | 287 [[NSWorkspace sharedWorkspace] openURL:learnMoreUrl]; |
308 } | 288 } |
309 | 289 |
310 @end | 290 @end |
OLD | NEW |