OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/chrome_browser_main_chromeos.h" | 5 #include "chrome/browser/chromeos/chrome_browser_main_chromeos.h" |
6 | 6 |
7 #include "base/bind.h" | |
8 #include "base/callback.h" | |
7 #include "base/command_line.h" | 9 #include "base/command_line.h" |
8 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
9 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
10 #include "chrome/browser/chromeos/boot_times_loader.h" | 12 #include "chrome/browser/chromeos/boot_times_loader.h" |
11 #include "chrome/browser/chromeos/cros/cros_library.h" | 13 #include "chrome/browser/chromeos/cros/cros_library.h" |
12 #include "chrome/browser/chromeos/net/cros_network_change_notifier_factory.h" | 14 #include "chrome/browser/chromeos/net/cros_network_change_notifier_factory.h" |
15 #include "chrome/browser/chromeos/sensors_source_chromeos.h" | |
13 #include "chrome/browser/defaults.h" | 16 #include "chrome/browser/defaults.h" |
14 #include "chrome/common/chrome_switches.h" | 17 #include "chrome/common/chrome_switches.h" |
15 #include "content/common/main_function_params.h" | 18 #include "content/common/main_function_params.h" |
16 #include "net/base/network_change_notifier.h" | 19 #include "net/base/network_change_notifier.h" |
17 | 20 |
18 #include <gtk/gtk.h> | 21 #include <gtk/gtk.h> |
19 | 22 |
20 class MessageLoopObserver : public MessageLoopForUI::Observer { | 23 class MessageLoopObserver : public MessageLoopForUI::Observer { |
21 virtual void WillProcessEvent(GdkEvent* event) { | 24 virtual void WillProcessEvent(GdkEvent* event) { |
22 // On chromeos we want to map Alt-left click to right click. | 25 // On chromeos we want to map Alt-left click to right click. |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
82 if (!parameters().ui_task) { | 85 if (!parameters().ui_task) { |
83 bool use_stub = parameters().command_line_.HasSwitch(switches::kStubCros); | 86 bool use_stub = parameters().command_line_.HasSwitch(switches::kStubCros); |
84 chromeos::CrosLibrary::Initialize(use_stub); | 87 chromeos::CrosLibrary::Initialize(use_stub); |
85 } | 88 } |
86 // Replace the default NetworkChangeNotifierFactory with ChromeOS specific | 89 // Replace the default NetworkChangeNotifierFactory with ChromeOS specific |
87 // implementation. | 90 // implementation. |
88 net::NetworkChangeNotifier::SetFactory( | 91 net::NetworkChangeNotifier::SetFactory( |
89 new chromeos::CrosNetworkChangeNotifierFactory()); | 92 new chromeos::CrosNetworkChangeNotifierFactory()); |
90 } | 93 } |
91 | 94 |
95 // Queued in PostMainMessageLoopStart. Needs to run after the IO thread is | |
96 // available via BrowserThread, as this is used by SensorsSourceChromeos. | |
97 static void DoDeferredSensorsInit(sensors::SensorsSourceChromeos* source) { | |
98 if (!source->Init()) | |
99 LOG(WARNING) << "Failed to initialize sensors source."; | |
100 } | |
satorux1
2011/09/14 20:21:07
I think file-local functions are usually place at
cwolfe
2011/09/14 20:41:24
Done.
| |
101 | |
92 void ChromeBrowserMainPartsChromeos::PostMainMessageLoopStart() { | 102 void ChromeBrowserMainPartsChromeos::PostMainMessageLoopStart() { |
93 ChromeBrowserMainPartsPosix::PostMainMessageLoopStart(); | 103 ChromeBrowserMainPartsPosix::PostMainMessageLoopStart(); |
94 MessageLoopForUI* message_loop = MessageLoopForUI::current(); | 104 MessageLoopForUI* message_loop = MessageLoopForUI::current(); |
95 message_loop->AddObserver(g_message_loop_observer.Pointer()); | 105 message_loop->AddObserver(g_message_loop_observer.Pointer()); |
106 | |
107 if (parameters().command_line_.HasSwitch(switches::kEnableSensors)) { | |
108 sensors_source_ = new sensors::SensorsSourceChromeos(); | |
109 // This initialization needs to be performed after BrowserThread::FILE is | |
110 // started. Post it into the current (UI) message loop, so that will be | |
111 // deferred until after browser main. | |
112 message_loop->PostTask(FROM_HERE, | |
113 base::Bind(&DoDeferredSensorsInit, sensors_source_)); | |
114 } | |
96 } | 115 } |
OLD | NEW |