blob: 79e8277aa4284eed68e62748b195cd52730b8095 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/first_run/first_run.h"
#import "base/scoped_nsobject.h"
#import "chrome/app/breakpad_mac.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profile.h"
#include "chrome/browser/search_engines/template_url_model.h"
#include "chrome/browser/shell_integration.h"
#import "chrome/browser/ui/cocoa/first_run_dialog.h"
#import "chrome/browser/ui/cocoa/search_engine_dialog_controller.h"
#include "chrome/common/pref_names.h"
#include "chrome/installer/util/google_update_constants.h"
#include "chrome/installer/util/google_update_settings.h"
namespace {
// Show the search engine selection dialog.
void ShowSearchEngineSelectionDialog(Profile* profile,
bool randomize_search_engine_experiment) {
scoped_nsobject<SearchEngineDialogController> dialog(
[[SearchEngineDialogController alloc] init]);
[dialog.get() setProfile:profile];
[dialog.get() setRandomize:randomize_search_engine_experiment];
[dialog.get() showWindow:nil];
}
// Show the first run UI.
void ShowFirstRun(Profile* profile) {
#if defined(GOOGLE_CHROME_BUILD)
// The purpose of the dialog is to ask the user to enable stats and crash
// reporting. This setting may be controlled through configuration management
// in enterprise scenarios. If that is the case, skip the dialog entirely, as
// it's not worth bothering the user for only the default browser question
// (which is likely to be forced in enterprise deployments anyway).
const PrefService::Preference* metrics_reporting_pref =
g_browser_process->local_state()->FindPreference(
prefs::kMetricsReportingEnabled);
if (!metrics_reporting_pref || !metrics_reporting_pref->IsManaged()) {
scoped_nsobject<FirstRunDialogController> dialog(
[[FirstRunDialogController alloc] init]);
[dialog.get() showWindow:nil];
// If the dialog asked the user to opt-in for stats and crash reporting,
// record the decision and enable the crash reporter if appropriate.
bool stats_enabled = [dialog.get() statsEnabled];
GoogleUpdateSettings::SetCollectStatsConsent(stats_enabled);
// Breakpad is normally enabled very early in the startup process. However,
// on the first run it may not have been enabled due to the missing opt-in
// from the user. If the user agreed now, enable breakpad if necessary.
if (!IsCrashReporterEnabled() && stats_enabled) {
InitCrashReporter();
InitCrashProcessInfo();
}
// If selected set as default browser.
BOOL make_default_browser = [dialog.get() makeDefaultBrowser];
if (make_default_browser) {
bool success = ShellIntegration::SetAsDefaultBrowser();
DCHECK(success);
}
}
#else // GOOGLE_CHROME_BUILD
// We don't show the dialog in Chromium.
#endif // GOOGLE_CHROME_BUILD
FirstRun::CreateSentinel();
// Set preference to show first run bubble and welcome page.
// Don't display the minimal bubble if there is no default search provider.
TemplateURLModel* search_engines_model = profile->GetTemplateURLModel();
if (search_engines_model &&
search_engines_model->GetDefaultSearchProvider()) {
FirstRun::SetShowFirstRunBubblePref(true);
}
FirstRun::SetShowWelcomePagePref();
}
} // namespace
// static
void FirstRun::ShowFirstRunDialog(Profile* profile,
bool randomize_search_engine_experiment) {
// If the default search is not managed via policy, ask the user to
// choose a default.
TemplateURLModel* model = profile->GetTemplateURLModel();
if (model && !model->is_default_search_managed()) {
ShowSearchEngineSelectionDialog(profile,
randomize_search_engine_experiment);
}
ShowFirstRun(profile);
}
bool FirstRun::ImportBookmarks(const FilePath& import_bookmarks_path) {
// http://crbug.com/48880
return false;
}
// static
bool FirstRun::IsOrganic() {
// We treat all installs as organic.
return true;
}
// static
void FirstRun::PlatformSetup() {
// Things that Windows does here (creating a desktop icon, for example) are
// not needed.
}
|