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

Side by Side Diff: chrome/browser/chromeos/cros/synaptics_library.cc

Issue 3076029: Allow chrome for cros to be started with a username / password (Closed)
Patch Set: Only declare StubLogin on cros builds Created 10 years, 4 months 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
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/chromeos/cros/synaptics_library.h" 5 #include "chrome/browser/chromeos/cros/synaptics_library.h"
6 6
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "chrome/browser/chrome_thread.h" 8 #include "chrome/browser/chrome_thread.h"
9 #include "chrome/browser/chromeos/cros/cros_library.h" 9 #include "chrome/browser/chromeos/cros/cros_library.h"
10 10
11 namespace chromeos { 11 namespace chromeos {
12 // This class handles the interaction with the ChromeOS synaptics library APIs.
13 // Users can get an instance of this library class like this:
14 // SynapticsLibrary::Get()
15 // For a list of SynapticsPrameters, see chromeos_synaptics.h
16 // in third_party/cros or /usr/include/cros
17 class SynapticsLibraryImpl : public SynapticsLibrary {
18 public:
19 SynapticsLibraryImpl() {}
20 virtual ~SynapticsLibraryImpl() {}
12 21
13 void SynapticsLibraryImpl::SetBoolParameter(SynapticsParameter param, 22 void SetBoolParameter(SynapticsParameter param, bool value) {
14 bool value) { 23 SetParameter(param, value ? 1 : 0);
15 SetParameter(param, value ? 1 : 0); 24 }
16 }
17 25
18 void SynapticsLibraryImpl::SetRangeParameter(SynapticsParameter param, 26 void SetRangeParameter(SynapticsParameter param, int value) {
19 int value) { 27 if (value < 1)
20 if (value < 1) 28 value = 1;
21 value = 1; 29 if (value > 10)
22 if (value > 10) 30 value = 10;
23 value = 10; 31 SetParameter(param, value);
24 SetParameter(param, value); 32 }
25 }
26 33
27 void SynapticsLibraryImpl::SetParameter(SynapticsParameter param, int value) { 34 private:
28 if (CrosLibrary::Get()->EnsureLoaded()) { 35 // This helper methods calls into the libcros library to set the parameter.
29 // This calls SetSynapticsParameter in the cros library which is 36 // This call is run on the FILE thread.
30 // potentially time consuming. So we run this on the FILE thread. 37 void SetParameter(SynapticsParameter param, int value) {
31 ChromeThread::PostTask( 38 if (CrosLibrary::Get()->EnsureLoaded()) {
32 ChromeThread::FILE, FROM_HERE, 39 // This calls SetSynapticsParameter in the cros library which is
33 NewRunnableFunction(&SetSynapticsParameter, param, value)); 40 // potentially time consuming. So we run this on the FILE thread.
41 ChromeThread::PostTask(
42 ChromeThread::FILE, FROM_HERE,
43 NewRunnableFunction(&SetSynapticsParameter, param, value));
44 }
34 } 45 }
46
47 DISALLOW_COPY_AND_ASSIGN(SynapticsLibraryImpl);
48 };
49
50 class SynapticsLibraryStubImpl : public SynapticsLibrary {
51 public:
52 SynapticsLibraryStubImpl() {}
53 virtual ~SynapticsLibraryStubImpl() {}
54 void SetBoolParameter(SynapticsParameter param, bool value) {}
55 void SetRangeParameter(SynapticsParameter param, int value) {}
56
57 private:
58 DISALLOW_COPY_AND_ASSIGN(SynapticsLibraryStubImpl);
59 };
60
61 // static
62 SynapticsLibrary* SynapticsLibrary::GetImpl(bool stub) {
63 if (stub)
64 return new SynapticsLibraryStubImpl();
65 else
66 return new SynapticsLibraryImpl();
35 } 67 }
36 68
37 } // namespace chromeos 69 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/cros/synaptics_library.h ('k') | chrome/browser/chromeos/cros/syslogs_library.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698