| 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 #include "chrome/browser/chromeos/browser_main_chromeos.h" | 5 #include "chrome/browser/chromeos/browser_main_chromeos.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" |
| 7 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
| 8 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "chrome/browser/chromeos/boot_times_loader.h" |
| 11 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 12 #include "chrome/browser/chromeos/net/cros_network_change_notifier_factory.h" |
| 13 #include "chrome/common/chrome_switches.h" |
| 14 #include "content/common/main_function_params.h" |
| 15 #include "net/base/network_change_notifier.h" |
| 9 | 16 |
| 10 #include <gtk/gtk.h> | 17 #include <gtk/gtk.h> |
| 11 | 18 |
| 12 class MessageLoopObserver : public MessageLoopForUI::Observer { | 19 class MessageLoopObserver : public MessageLoopForUI::Observer { |
| 13 virtual void WillProcessEvent(GdkEvent* event) { | 20 virtual void WillProcessEvent(GdkEvent* event) { |
| 14 // On chromeos we want to map Alt-left click to right click. | 21 // On chromeos we want to map Alt-left click to right click. |
| 15 // This code only changes presses and releases. We could decide to also | 22 // This code only changes presses and releases. We could decide to also |
| 16 // modify drags and crossings. It doesn't seem to be a problem right now | 23 // modify drags and crossings. It doesn't seem to be a problem right now |
| 17 // with our support for context menus (the only real need we have). | 24 // with our support for context menus (the only real need we have). |
| 18 // There are some inconsistent states both with what we have and what | 25 // There are some inconsistent states both with what we have and what |
| (...skipping 15 matching lines...) Expand all Loading... |
| 34 } | 41 } |
| 35 } | 42 } |
| 36 | 43 |
| 37 virtual void DidProcessEvent(GdkEvent* event) { | 44 virtual void DidProcessEvent(GdkEvent* event) { |
| 38 } | 45 } |
| 39 }; | 46 }; |
| 40 | 47 |
| 41 static base::LazyInstance<MessageLoopObserver> g_message_loop_observer( | 48 static base::LazyInstance<MessageLoopObserver> g_message_loop_observer( |
| 42 base::LINKER_INITIALIZED); | 49 base::LINKER_INITIALIZED); |
| 43 | 50 |
| 51 BrowserMainPartsChromeos::BrowserMainPartsChromeos( |
| 52 const MainFunctionParams& parameters) |
| 53 : BrowserMainPartsGtk(parameters) { |
| 54 } |
| 55 BrowserMainPartsChromeos::~BrowserMainPartsChromeos() { |
| 56 if (!parameters().ui_task && chromeos::CrosLibrary::Get()) |
| 57 chromeos::CrosLibrary::Shutdown(); |
| 58 |
| 59 // To be precise, logout (browser shutdown) is not yet done, but the |
| 60 // remaining work is negligible, hence we say LogoutDone here. |
| 61 chromeos::BootTimesLoader::Get()->AddLogoutTimeMarker("LogoutDone", |
| 62 false); |
| 63 chromeos::BootTimesLoader::Get()->WriteLogoutTimes(); |
| 64 } |
| 65 |
| 66 void BrowserMainPartsChromeos::PreMainMessageLoopStart() { |
| 67 // Initialize CrosLibrary only for the browser, unless running tests |
| 68 // (which do their own CrosLibrary setup). |
| 69 if (!parameters().ui_task) { |
| 70 bool use_stub = parameters().command_line_.HasSwitch(switches::kStubCros); |
| 71 chromeos::CrosLibrary::Initialize(use_stub); |
| 72 } |
| 73 // Replace the default NetworkChangeNotifierFactory with ChromeOS specific |
| 74 // implementation. |
| 75 net::NetworkChangeNotifier::SetFactory( |
| 76 new chromeos::CrosNetworkChangeNotifierFactory()); |
| 77 } |
| 78 |
| 44 void BrowserMainPartsChromeos::PostMainMessageLoopStart() { | 79 void BrowserMainPartsChromeos::PostMainMessageLoopStart() { |
| 45 BrowserMainPartsPosix::PostMainMessageLoopStart(); | 80 BrowserMainPartsPosix::PostMainMessageLoopStart(); |
| 46 MessageLoopForUI* message_loop = MessageLoopForUI::current(); | 81 MessageLoopForUI* message_loop = MessageLoopForUI::current(); |
| 47 message_loop->AddObserver(g_message_loop_observer.Pointer()); | 82 message_loop->AddObserver(g_message_loop_observer.Pointer()); |
| 48 } | 83 } |
| 49 | |
| 50 // static | |
| 51 BrowserMainParts* BrowserMainParts::CreateBrowserMainParts( | |
| 52 const MainFunctionParams& parameters) { | |
| 53 return new BrowserMainPartsChromeos(parameters); | |
| 54 } | |
| OLD | NEW |