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 3 // found in the LICENSE file. 4 5 #ifndef UI_VIEWS_FOCUS_FOCUS_MANAGER_FACTORY_H_ 6 #define UI_VIEWS_FOCUS_FOCUS_MANAGER_FACTORY_H_ 7 8 #include "base/basictypes.h" 9 #include "ui/views/views_export.h" 10 11 namespace views { 12 13 class FocusManager; 14 class Widget; 15 16 // A factory to create FocusManager. This is used in unit tests 17 // to inject a custom factory. 18 class VIEWS_EXPORT FocusManagerFactory { 19 public: 20 // Create a FocusManager for the given |widget| using installe Factory. 21 static FocusManager* Create(Widget* widget, bool desktop_widget); 22 23 // Installs FocusManagerFactory. If |factory| is NULL, it resets 24 // to the default factory which creates plain FocusManager. 25 static void Install(FocusManagerFactory* factory); 26 27 protected: 28 FocusManagerFactory(); 29 virtual ~FocusManagerFactory(); 30 31 // Create a FocusManager for the given |widget|. 32 // The |desktop_widget| bool is true for widgets created in the desktop and 33 // false for widgets created in the shell. 34 virtual FocusManager* CreateFocusManager(Widget* widget, 35 bool desktop_widget) = 0; 36 37 private: 38 DISALLOW_COPY_AND_ASSIGN(FocusManagerFactory); 39 }; 40 41 } // namespace views 42 43 #endif // UI_VIEWS_FOCUS_FOCUS_MANAGER_FACTORY_H_ 44