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 #include "chrome/browser/chrome_browser_main_linux.h" | 5 #include "chrome/browser/chrome_browser_main_linux.h" |
6 | 6 |
7 #include "base/message_loop_proxy.h" | |
8 #include "chrome/browser/storage_monitor/media_transfer_protocol_device_observer
_linux.h" | |
9 #include "chrome/common/chrome_switches.h" | |
10 #include "device/media_transfer_protocol/media_transfer_protocol_manager.h" | |
11 | |
12 #if !defined(OS_CHROMEOS) | 7 #if !defined(OS_CHROMEOS) |
13 #include "chrome/browser/storage_monitor/removable_device_notifications_linux.h" | 8 #include "chrome/browser/storage_monitor/removable_device_notifications_linux.h" |
14 #include "content/public/browser/browser_thread.h" | 9 #include "content/public/browser/browser_thread.h" |
15 #endif | 10 #endif |
16 | 11 |
17 #if defined(USE_LINUX_BREAKPAD) | 12 #if defined(USE_LINUX_BREAKPAD) |
18 #include <stdlib.h> | 13 #include <stdlib.h> |
19 | 14 |
20 #include "base/command_line.h" | 15 #include "base/command_line.h" |
21 #include "base/linux_util.h" | 16 #include "base/linux_util.h" |
22 #include "base/prefs/pref_service.h" | 17 #include "base/prefs/pref_service.h" |
23 #include "chrome/app/breakpad_linux.h" | 18 #include "chrome/app/breakpad_linux.h" |
| 19 #include "chrome/common/chrome_switches.h" |
24 #include "chrome/common/env_vars.h" | 20 #include "chrome/common/env_vars.h" |
25 #include "chrome/common/pref_names.h" | 21 #include "chrome/common/pref_names.h" |
26 | 22 |
27 #if defined(OS_CHROMEOS) | 23 #if defined(OS_CHROMEOS) |
28 #include "chrome/browser/chromeos/settings/cros_settings.h" | 24 #include "chrome/browser/chromeos/settings/cros_settings.h" |
29 #include "chrome/browser/chromeos/settings/cros_settings_names.h" | 25 #include "chrome/browser/chromeos/settings/cros_settings_names.h" |
30 #include "chrome/common/chrome_version_info.h" | 26 #include "chrome/common/chrome_version_info.h" |
31 #endif | 27 #endif |
32 | 28 |
33 #endif // defined(USE_LINUX_BREAKPAD) | 29 #endif // defined(USE_LINUX_BREAKPAD) |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 } | 97 } |
102 | 98 |
103 return breakpad_enabled; | 99 return breakpad_enabled; |
104 } | 100 } |
105 #endif // defined(USE_LINUX_BREAKPAD) | 101 #endif // defined(USE_LINUX_BREAKPAD) |
106 | 102 |
107 } // namespace | 103 } // namespace |
108 | 104 |
109 ChromeBrowserMainPartsLinux::ChromeBrowserMainPartsLinux( | 105 ChromeBrowserMainPartsLinux::ChromeBrowserMainPartsLinux( |
110 const content::MainFunctionParams& parameters) | 106 const content::MainFunctionParams& parameters) |
111 : ChromeBrowserMainPartsPosix(parameters), | 107 : ChromeBrowserMainPartsPosix(parameters) { |
112 initialized_media_transfer_protocol_manager_(false) { | |
113 } | 108 } |
114 | 109 |
115 ChromeBrowserMainPartsLinux::~ChromeBrowserMainPartsLinux() { | 110 ChromeBrowserMainPartsLinux::~ChromeBrowserMainPartsLinux() { |
116 if (initialized_media_transfer_protocol_manager_) | |
117 device::MediaTransferProtocolManager::Shutdown(); | |
118 } | 111 } |
119 | 112 |
120 void ChromeBrowserMainPartsLinux::PreProfileInit() { | 113 void ChromeBrowserMainPartsLinux::PreProfileInit() { |
121 #if defined(USE_LINUX_BREAKPAD) | 114 #if defined(USE_LINUX_BREAKPAD) |
122 #if !defined(OS_CHROMEOS) | 115 #if !defined(OS_CHROMEOS) |
123 // Needs to be called after we have chrome::DIR_USER_DATA and | 116 // Needs to be called after we have chrome::DIR_USER_DATA and |
124 // g_browser_process. This happens in PreCreateThreads. | 117 // g_browser_process. This happens in PreCreateThreads. |
125 content::BrowserThread::PostTask(content::BrowserThread::FILE, | 118 content::BrowserThread::PostTask(content::BrowserThread::FILE, |
126 FROM_HERE, | 119 FROM_HERE, |
127 base::Bind(&GetLinuxDistroCallback)); | 120 base::Bind(&GetLinuxDistroCallback)); |
128 #endif | 121 #endif |
129 | 122 |
130 if (IsCrashReportingEnabled(local_state())) | 123 if (IsCrashReportingEnabled(local_state())) |
131 InitCrashReporter(); | 124 InitCrashReporter(); |
132 #endif | 125 #endif |
133 | 126 |
134 #if !defined(OS_CHROMEOS) | 127 #if !defined(OS_CHROMEOS) |
135 const base::FilePath kDefaultMtabPath("/etc/mtab"); | 128 const base::FilePath kDefaultMtabPath("/etc/mtab"); |
136 removable_device_notifications_linux_ = | 129 removable_device_notifications_linux_ = |
137 new chrome::RemovableDeviceNotificationsLinux(kDefaultMtabPath); | 130 new chrome::RemovableDeviceNotificationsLinux(kDefaultMtabPath); |
138 removable_device_notifications_linux_->Init(); | |
139 #endif | 131 #endif |
140 | 132 |
141 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kTestType)) { | |
142 scoped_refptr<base::MessageLoopProxy> loop_proxy; | |
143 #if !defined(OS_CHROMEOS) | |
144 loop_proxy = content::BrowserThread::GetMessageLoopProxyForThread( | |
145 content::BrowserThread::FILE); | |
146 #endif | |
147 device::MediaTransferProtocolManager::Initialize(loop_proxy); | |
148 initialized_media_transfer_protocol_manager_ = true; | |
149 } | |
150 | |
151 ChromeBrowserMainPartsPosix::PreProfileInit(); | 133 ChromeBrowserMainPartsPosix::PreProfileInit(); |
152 } | 134 } |
153 | 135 |
154 void ChromeBrowserMainPartsLinux::PostProfileInit() { | 136 void ChromeBrowserMainPartsLinux::PostProfileInit() { |
155 // TODO(gbillock): Make this owned by RemovableDeviceNotificationsLinux. | 137 #if !defined(OS_CHROMEOS) |
156 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kTestType)) { | 138 removable_device_notifications_linux_->Init(); |
157 media_transfer_protocol_device_observer_.reset( | 139 #endif |
158 new chrome::MediaTransferProtocolDeviceObserverLinux()); | |
159 media_transfer_protocol_device_observer_->SetNotifications( | |
160 chrome::StorageMonitor::GetInstance()->receiver()); | |
161 } | |
162 | 140 |
163 ChromeBrowserMainPartsPosix::PostProfileInit(); | 141 ChromeBrowserMainPartsPosix::PostProfileInit(); |
164 } | 142 } |
165 | 143 |
166 void ChromeBrowserMainPartsLinux::PostMainMessageLoopRun() { | 144 void ChromeBrowserMainPartsLinux::PostMainMessageLoopRun() { |
167 #if !defined(OS_CHROMEOS) | 145 #if !defined(OS_CHROMEOS) |
168 // Release it now. Otherwise the FILE thread would be gone when we try to | 146 // Release it now. Otherwise the FILE thread would be gone when we try to |
169 // release it in the dtor and Valgrind would report a leak on almost ever | 147 // release it in the dtor and Valgrind would report a leak on almost ever |
170 // single browser_test. | 148 // single browser_test. |
171 removable_device_notifications_linux_ = NULL; | 149 removable_device_notifications_linux_ = NULL; |
172 #endif | 150 #endif |
173 | 151 |
174 media_transfer_protocol_device_observer_.reset(); | |
175 | |
176 ChromeBrowserMainPartsPosix::PostMainMessageLoopRun(); | 152 ChromeBrowserMainPartsPosix::PostMainMessageLoopRun(); |
177 } | 153 } |
OLD | NEW |