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

Side by Side Diff: chrome/browser/ui/cocoa/first_run_dialog.mm

Issue 2014353002: Make Mac and Linux first run dialogs use metrics APIs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comment. Created 4 years, 6 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
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 #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"
8 #include "base/mac/bundle_locations.h" 7 #include "base/mac/bundle_locations.h"
9 #import "base/mac/scoped_nsobject.h" 8 #import "base/mac/scoped_nsobject.h"
10 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
11 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
12 #include "base/strings/sys_string_conversions.h" 11 #include "base/strings/sys_string_conversions.h"
13 #include "chrome/browser/first_run/first_run.h" 12 #include "chrome/browser/first_run/first_run.h"
14 #include "chrome/browser/first_run/first_run_dialog.h" 13 #include "chrome/browser/first_run/first_run_dialog.h"
14 #include "chrome/browser/metrics/metrics_reporting_state.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/channel_info.h"
19 #include "chrome/common/url_constants.h" 18 #include "chrome/common/url_constants.h"
20 #include "components/metrics/metrics_pref_names.h"
21 #include "components/search_engines/template_url_service.h" 19 #include "components/search_engines/template_url_service.h"
22 #include "components/version_info/version_info.h"
23 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMUILocalizerAndLayoutTw eaker.h" 20 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMUILocalizerAndLayoutTw eaker.h"
24 #include "ui/base/l10n/l10n_util_mac.h" 21 #include "ui/base/l10n/l10n_util_mac.h"
25 #include "url/gurl.h" 22 #include "url/gurl.h"
26 23
27 #if defined(GOOGLE_CHROME_BUILD)
28 #include "chrome/browser/browser_process.h"
29 #include "chrome/common/pref_names.h"
30 #include "chrome/installer/util/google_update_settings.h"
31 #include "components/prefs/pref_service.h"
32 #endif
33
34 @interface FirstRunDialogController (PrivateMethods) 24 @interface FirstRunDialogController (PrivateMethods)
35 // Show the dialog. 25 // Show the dialog.
36 - (void)show; 26 - (void)show;
37 @end 27 @end
38 28
39 namespace { 29 namespace {
40 30
41 class FirstRunShowBridge : public base::RefCounted<FirstRunShowBridge> { 31 class FirstRunShowBridge : public base::RefCounted<FirstRunShowBridge> {
42 public: 32 public:
43 FirstRunShowBridge(FirstRunDialogController* controller); 33 FirstRunShowBridge(FirstRunDialogController* controller);
(...skipping 22 matching lines...) Expand all
66 // Show the first run UI. 56 // Show the first run UI.
67 // Returns true if the first run dialog was shown. 57 // Returns true if the first run dialog was shown.
68 bool ShowFirstRun(Profile* profile) { 58 bool ShowFirstRun(Profile* profile) {
69 bool dialog_shown = false; 59 bool dialog_shown = false;
70 #if defined(GOOGLE_CHROME_BUILD) 60 #if defined(GOOGLE_CHROME_BUILD)
71 // The purpose of the dialog is to ask the user to enable stats and crash 61 // The purpose of the dialog is to ask the user to enable stats and crash
72 // reporting. This setting may be controlled through configuration management 62 // reporting. This setting may be controlled through configuration management
73 // in enterprise scenarios. If that is the case, skip the dialog entirely, as 63 // in enterprise scenarios. If that is the case, skip the dialog entirely, as
74 // it's not worth bothering the user for only the default browser question 64 // it's not worth bothering the user for only the default browser question
75 // (which is likely to be forced in enterprise deployments anyway). 65 // (which is likely to be forced in enterprise deployments anyway).
76 const PrefService::Preference* metrics_reporting_pref = 66 if (!IsMetricsReportingPolicyManaged()) {
77 g_browser_process->local_state()->FindPreference(
78 metrics::prefs::kMetricsReportingEnabled);
79 if (!metrics_reporting_pref || !metrics_reporting_pref->IsManaged()) {
80 base::scoped_nsobject<FirstRunDialogController> dialog( 67 base::scoped_nsobject<FirstRunDialogController> dialog(
81 [[FirstRunDialogController alloc] init]); 68 [[FirstRunDialogController alloc] init]);
82 69
83 [dialog.get() showWindow:nil]; 70 [dialog.get() showWindow:nil];
84 dialog_shown = true; 71 dialog_shown = true;
85 72
86 // If the dialog asked the user to opt-in for stats and crash reporting, 73 // If the dialog asked the user to opt-in for stats and crash reporting,
87 // record the decision and enable the crash reporter if appropriate. 74 // record the decision and enable the crash reporter if appropriate.
88 bool stats_enabled = [dialog.get() statsEnabled]; 75 bool consent_given = [dialog.get() statsEnabled];
89 GoogleUpdateSettings::SetCollectStatsConsent(stats_enabled); 76 InitiateMetricsReportingChange(consent_given,
77 OnMetricsReportingCallbackType());
90 78
91 // If selected set as default browser. 79 // If selected set as default browser.
92 BOOL make_default_browser = [dialog.get() makeDefaultBrowser]; 80 BOOL make_default_browser = [dialog.get() makeDefaultBrowser];
93 if (make_default_browser) { 81 if (make_default_browser) {
94 bool success = shell_integration::SetAsDefaultBrowser(); 82 bool success = shell_integration::SetAsDefaultBrowser();
95 DCHECK(success); 83 DCHECK(success);
96 } 84 }
97 } 85 }
98 #else // GOOGLE_CHROME_BUILD 86 #else // GOOGLE_CHROME_BUILD
99 // We don't show the dialog in Chromium. 87 // We don't show the dialog in Chromium.
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 [NSApp stopModal]; 262 [NSApp stopModal];
275 } 263 }
276 264
277 - (IBAction)learnMore:(id)sender { 265 - (IBAction)learnMore:(id)sender {
278 NSString* urlStr = base::SysUTF8ToNSString(chrome::kLearnMoreReportingURL); 266 NSString* urlStr = base::SysUTF8ToNSString(chrome::kLearnMoreReportingURL);
279 NSURL* learnMoreUrl = [NSURL URLWithString:urlStr]; 267 NSURL* learnMoreUrl = [NSURL URLWithString:urlStr];
280 [[NSWorkspace sharedWorkspace] openURL:learnMoreUrl]; 268 [[NSWorkspace sharedWorkspace] openURL:learnMoreUrl];
281 } 269 }
282 270
283 @end 271 @end
OLDNEW
« no previous file with comments | « chrome/browser/first_run/first_run_internal_posix.cc ('k') | chrome/browser/ui/views/first_run_dialog.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698