OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 // This code glues the RLZ library DLL with Chrome. It allows Chrome to work | 5 // This code glues the RLZ library DLL with Chrome. It allows Chrome to work |
6 // with or without the DLL being present. If the DLL is not present the | 6 // with or without the DLL being present. If the DLL is not present the |
7 // functions do nothing and just return false. | 7 // functions do nothing and just return false. |
8 | 8 |
9 #include "chrome/browser/rlz/rlz.h" | 9 #include "chrome/browser/rlz/rlz.h" |
10 | 10 |
11 #include <windows.h> | 11 #include <windows.h> |
12 #include <process.h> | 12 #include <process.h> |
13 | 13 |
14 #include <algorithm> | 14 #include <algorithm> |
15 | 15 |
16 #include "base/file_path.h" | 16 #include "base/file_path.h" |
17 #include "base/message_loop.h" | 17 #include "base/message_loop.h" |
18 #include "base/path_service.h" | 18 #include "base/path_service.h" |
19 #include "base/string_util.h" | 19 #include "base/string_util.h" |
20 #include "base/task.h" | 20 #include "base/task.h" |
21 #include "base/thread.h" | 21 #include "base/thread.h" |
| 22 #include "base/thread_restrictions.h" |
22 #include "base/utf_string_conversions.h" | 23 #include "base/utf_string_conversions.h" |
23 #include "chrome/browser/browser_process.h" | 24 #include "chrome/browser/browser_process.h" |
24 #include "chrome/browser/profile.h" | 25 #include "chrome/browser/profile.h" |
25 #include "chrome/browser/profile_manager.h" | 26 #include "chrome/browser/profile_manager.h" |
26 #include "chrome/browser/search_engines/template_url.h" | 27 #include "chrome/browser/search_engines/template_url.h" |
27 #include "chrome/browser/search_engines/template_url_model.h" | 28 #include "chrome/browser/search_engines/template_url_model.h" |
28 #include "chrome/common/chrome_paths.h" | 29 #include "chrome/common/chrome_paths.h" |
29 #include "chrome/common/env_vars.h" | 30 #include "chrome/common/env_vars.h" |
30 #include "chrome/common/notification_registrar.h" | 31 #include "chrome/common/notification_registrar.h" |
31 #include "chrome/common/notification_service.h" | 32 #include "chrome/common/notification_service.h" |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 // Performs late RLZ initialization and RLZ event recording for chrome. | 155 // Performs late RLZ initialization and RLZ event recording for chrome. |
155 // This task needs to run on the UI thread. | 156 // This task needs to run on the UI thread. |
156 class DelayedInitTask : public Task { | 157 class DelayedInitTask : public Task { |
157 public: | 158 public: |
158 explicit DelayedInitTask(bool first_run) | 159 explicit DelayedInitTask(bool first_run) |
159 : first_run_(first_run) { | 160 : first_run_(first_run) { |
160 } | 161 } |
161 virtual ~DelayedInitTask() { | 162 virtual ~DelayedInitTask() { |
162 } | 163 } |
163 virtual void Run() { | 164 virtual void Run() { |
| 165 // Needs to be evaluated. See http://crbug.com/62328/. |
| 166 base::ThreadRestrictions::ScopedAllowIO allow_io; |
| 167 |
164 // For non-interactive tests we don't do the rest of the initialization | 168 // For non-interactive tests we don't do the rest of the initialization |
165 // because sometimes the very act of loading the dll causes QEMU to crash. | 169 // because sometimes the very act of loading the dll causes QEMU to crash. |
166 if (::GetEnvironmentVariableW(ASCIIToWide(env_vars::kHeadless).c_str(), | 170 if (::GetEnvironmentVariableW(ASCIIToWide(env_vars::kHeadless).c_str(), |
167 NULL, 0)) { | 171 NULL, 0)) { |
168 return; | 172 return; |
169 } | 173 } |
170 // For organic brandcodes do not use rlz at all. Empty brandcode usually | 174 // For organic brandcodes do not use rlz at all. Empty brandcode usually |
171 // means a chromium install. This is ok. | 175 // means a chromium install. This is ok. |
172 std::wstring brand; | 176 std::wstring brand; |
173 if (!GoogleUpdateSettings::GetBrand(&brand) || brand.empty() || | 177 if (!GoogleUpdateSettings::GetBrand(&brand) || brand.empty() || |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 access_values_state = ACCESS_VALUES_FRESH; | 287 access_values_state = ACCESS_VALUES_FRESH; |
284 cached_ommibox_rlz.assign(*rlz); | 288 cached_ommibox_rlz.assign(*rlz); |
285 } | 289 } |
286 return true; | 290 return true; |
287 } | 291 } |
288 | 292 |
289 // static | 293 // static |
290 void RLZTracker::CleanupRlz() { | 294 void RLZTracker::CleanupRlz() { |
291 OmniBoxUsageObserver::DeleteInstance(); | 295 OmniBoxUsageObserver::DeleteInstance(); |
292 } | 296 } |
OLD | NEW |