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

Side by Side Diff: chrome/browser/google/google_util_chromeos.cc

Issue 11412067: [rlz,cros] RLZ glue for ChromeOS. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years 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 | Annotate | Revision Log
OLDNEW
(Empty)
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.
4
5 #include "base/basictypes.h"
6 #include "base/bind.h"
7 #include "base/file_path.h"
8 #include "base/file_util.h"
9 #include "base/logging.h"
10 #include "base/string_util.h"
11 #include "base/task_runner_util.h"
12 #include "base/threading/worker_pool.h"
13 #include "chrome/browser/browser_process.h"
14 #include "chrome/browser/prefs/pref_service.h"
15 #include "chrome/common/pref_names.h"
16 #include "content/public/browser/browser_thread.h"
17
18 namespace google_util {
19 namespace chromeos {
20
21 namespace {
22
23 // Path to file that stores the RLZ brand code on ChromeOS.
24 const char kRLZBrandFilePath[] =
25 FILE_PATH_LITERAL("/opt/oem/etc/BRAND_CODE");
26
27 // Reads the brand code from file |kRLZBrandFilePath|.
28 std::string ReadBrandFromFile() {
29 std::string brand;
30 FilePath brand_file_path(kRLZBrandFilePath);
31 if (!file_util::ReadFileToString(brand_file_path, &brand))
32 LOG(WARNING) << "Brand code file missing: " << brand_file_path.value();
33 TrimWhitespace(brand, TRIM_ALL, &brand);
34 return brand;
35 }
36
37 // Sets the brand code to |brand|.
38 void SetBrand(const base::Closure& callback, const std::string& brand) {
39 g_browser_process->local_state()->SetString(prefs::kRLZBrand, brand);
40 callback.Run();
41 }
42
43 } // namespace
44
45 std::string GetBrand() {
46 DCHECK(
47 !content::BrowserThread::IsWellKnownThread(content::BrowserThread::UI) ||
48 content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
49 DCHECK(g_browser_process->local_state());
50 return g_browser_process->local_state()->GetString(prefs::kRLZBrand);
51 }
52
53 void SetBrandFromFile(const base::Closure& callback) {
54 base::PostTaskAndReplyWithResult(
55 base::WorkerPool::GetTaskRunner(false /* task_is_slow */),
56 FROM_HERE,
57 base::Bind(&ReadBrandFromFile),
58 base::Bind(&SetBrand, callback));
59 }
60
61 } // namespace chromeos
62 } // namespace google_util
OLDNEW
« no previous file with comments | « chrome/browser/google/google_util_chromeos.h ('k') | chrome/browser/resources/chromeos/login/oobe.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698