Remove no longer needed toolbar layer method.
[chromium-blink-merge.git] / chrome / browser / chrome_browser_main.h
blob1258b75605e29bbd9b23eaf750f406033623ec22
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_CHROME_BROWSER_MAIN_H_
6 #define CHROME_BROWSER_CHROME_BROWSER_MAIN_H_
8 #include "base/basictypes.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/metrics/field_trial.h"
11 #include "base/tracked_objects.h"
12 #include "chrome/browser/chrome_browser_field_trials.h"
13 #include "chrome/browser/chrome_process_singleton.h"
14 #include "chrome/browser/first_run/first_run.h"
15 #include "chrome/browser/process_singleton.h"
16 #include "chrome/browser/ui/startup/startup_browser_creator.h"
17 #include "content/public/browser/browser_main_parts.h"
18 #include "content/public/common/main_function_params.h"
20 class BrowserProcessImpl;
21 class ChromeBrowserMainExtraParts;
22 class FieldTrialSynchronizer;
23 class MetricsService;
24 class PrefService;
25 class ProcessPowerCollector;
26 class Profile;
27 class StartupBrowserCreator;
28 class StartupTimeBomb;
29 class ShutdownWatcherHelper;
30 class ThreeDAPIObserver;
32 namespace chrome_browser {
33 // For use by ShowMissingLocaleMessageBox.
34 #if defined(OS_WIN)
35 extern const char kMissingLocaleDataTitle[];
36 #endif
38 #if defined(OS_WIN)
39 extern const char kMissingLocaleDataMessage[];
40 #endif
43 namespace metrics {
44 class TrackingSynchronizer;
47 class ChromeBrowserMainParts : public content::BrowserMainParts {
48 public:
49 ~ChromeBrowserMainParts() override;
51 // Add additional ChromeBrowserMainExtraParts.
52 virtual void AddParts(ChromeBrowserMainExtraParts* parts);
54 protected:
55 explicit ChromeBrowserMainParts(
56 const content::MainFunctionParams& parameters);
58 // content::BrowserMainParts overrides.
59 // These are called in-order by content::BrowserMainLoop.
60 // Each stage calls the same stages in any ChromeBrowserMainExtraParts added
61 // with AddParts() from ChromeContentBrowserClient::CreateBrowserMainParts.
62 void PreEarlyInitialization() override;
63 void PostEarlyInitialization() override;
64 void ToolkitInitialized() override;
65 void PreMainMessageLoopStart() override;
66 void PostMainMessageLoopStart() override;
67 int PreCreateThreads() override;
68 void PreMainMessageLoopRun() override;
69 bool MainMessageLoopRun(int* result_code) override;
70 void PostMainMessageLoopRun() override;
71 void PostDestroyThreads() override;
73 // Additional stages for ChromeBrowserMainExtraParts. These stages are called
74 // in order from PreMainMessageLoopRun(). See implementation for details.
75 virtual void PreProfileInit();
76 virtual void PostProfileInit();
77 virtual void PreBrowserStart();
78 virtual void PostBrowserStart();
80 // Displays a warning message that we can't find any locale data files.
81 virtual void ShowMissingLocaleMessageBox() = 0;
83 const content::MainFunctionParams& parameters() const {
84 return parameters_;
86 const base::CommandLine& parsed_command_line() const {
87 return parsed_command_line_;
89 const base::FilePath& user_data_dir() const {
90 return user_data_dir_;
93 Profile* profile() { return profile_; }
95 const PrefService* local_state() const { return local_state_; }
97 private:
98 // Methods for |SetupMetricsAndFieldTrials()| --------------------------------
100 // Constructs metrics service and does related initialization, including
101 // creation of field trials. Call only after labs have been converted to
102 // switches.
103 void SetupMetricsAndFieldTrials();
105 // Starts recording of metrics. This can only be called after we have a file
106 // thread.
107 void StartMetricsRecording();
109 // Record time from process startup to present time in an UMA histogram.
110 void RecordBrowserStartupTime();
112 // Records a time value to an UMA histogram in the context of the
113 // PreReadExperiment field-trial. This also reports to the appropriate
114 // sub-histogram (_PreRead(Enabled|Disabled)).
115 void RecordPreReadExperimentTime(const char* name, base::TimeDelta time);
117 // Methods for Main Message Loop -------------------------------------------
119 int PreCreateThreadsImpl();
120 int PreMainMessageLoopRunImpl();
122 // Members initialized on construction ---------------------------------------
124 const content::MainFunctionParams parameters_;
125 const base::CommandLine& parsed_command_line_;
126 int result_code_;
128 // Create StartupTimeBomb object for watching jank during startup.
129 scoped_ptr<StartupTimeBomb> startup_watcher_;
131 // Create ShutdownWatcherHelper object for watching jank during shutdown.
132 // Please keep |shutdown_watcher| as the first object constructed, and hence
133 // it is destroyed last.
134 scoped_ptr<ShutdownWatcherHelper> shutdown_watcher_;
136 // Statistical testing infrastructure for the entire browser. NULL until
137 // SetupMetricsAndFieldTrials is called.
138 scoped_ptr<base::FieldTrialList> field_trial_list_;
140 ChromeBrowserFieldTrials browser_field_trials_;
142 #if !defined(OS_ANDROID) && !defined(OS_IOS)
143 // A monitor for attributing power consumption to origins.
144 scoped_ptr<ProcessPowerCollector> process_power_collector_;
145 #endif
147 // Vector of additional ChromeBrowserMainExtraParts.
148 // Parts are deleted in the inverse order they are added.
149 std::vector<ChromeBrowserMainExtraParts*> chrome_extra_parts_;
151 // Members initialized after / released before main_message_loop_ ------------
153 scoped_ptr<BrowserProcessImpl> browser_process_;
154 scoped_refptr<metrics::TrackingSynchronizer> tracking_synchronizer_;
155 #if !defined(OS_ANDROID)
156 // Browser creation happens on the Java side in Android.
157 scoped_ptr<StartupBrowserCreator> browser_creator_;
159 // Android doesn't support multiple browser processes, so it doesn't implement
160 // ProcessSingleton.
161 scoped_ptr<ChromeProcessSingleton> process_singleton_;
163 // Android's first run is done in Java instead of native.
164 scoped_ptr<first_run::MasterPrefs> master_prefs_;
165 #endif
166 Profile* profile_;
167 bool run_message_loop_;
168 ProcessSingleton::NotifyResult notify_result_;
169 scoped_ptr<ThreeDAPIObserver> three_d_observer_;
171 // Initialized in SetupMetricsAndFieldTrials.
172 scoped_refptr<FieldTrialSynchronizer> field_trial_synchronizer_;
174 // Members initialized in PreMainMessageLoopRun, needed in
175 // PreMainMessageLoopRunThreadsCreated.
176 PrefService* local_state_;
177 base::FilePath user_data_dir_;
179 // Members needed across shutdown methods.
180 bool restart_last_session_;
182 DISALLOW_COPY_AND_ASSIGN(ChromeBrowserMainParts);
185 #endif // CHROME_BROWSER_CHROME_BROWSER_MAIN_H_