Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / ui / views / focus / focus_manager_factory.cc
blob62770d71b1da275d9a93a190939afc5eebfc8d32
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.
5 #include "ui/views/focus/focus_manager_factory.h"
7 #include "base/compiler_specific.h"
8 #include "ui/views/focus/focus_manager.h"
10 namespace views {
12 namespace {
14 class DefaultFocusManagerFactory : public FocusManagerFactory {
15 public:
16 DefaultFocusManagerFactory() : FocusManagerFactory() {}
17 virtual ~DefaultFocusManagerFactory() {}
19 protected:
20 virtual FocusManager* CreateFocusManager(Widget* widget,
21 bool desktop_widget) OVERRIDE {
22 return new FocusManager(widget, NULL /* delegate */);
25 private:
26 DISALLOW_COPY_AND_ASSIGN(DefaultFocusManagerFactory);
29 FocusManagerFactory* focus_manager_factory = NULL;
31 } // namespace
33 FocusManagerFactory::FocusManagerFactory() {
36 FocusManagerFactory::~FocusManagerFactory() {
39 // static
40 FocusManager* FocusManagerFactory::Create(Widget* widget,
41 bool desktop_widget) {
42 if (!focus_manager_factory)
43 focus_manager_factory = new DefaultFocusManagerFactory();
44 return focus_manager_factory->CreateFocusManager(widget, desktop_widget);
47 // static
48 void FocusManagerFactory::Install(FocusManagerFactory* f) {
49 if (f == focus_manager_factory)
50 return;
51 delete focus_manager_factory;
52 focus_manager_factory = f ? f : new DefaultFocusManagerFactory();
55 } // namespace views