diff options
-rw-r--r-- | base/message_pump_win.cc | 1 | ||||
-rw-r--r-- | chrome/browser/autocomplete/autocomplete_edit_view_win.cc | 7 | ||||
-rw-r--r-- | chrome/browser/process_singleton_win.cc | 7 | ||||
-rw-r--r-- | chrome/views/widget/widget_win.cc | 105 |
4 files changed, 40 insertions, 80 deletions
diff --git a/base/message_pump_win.cc b/base/message_pump_win.cc index ffd12ca..3af1991 100644 --- a/base/message_pump_win.cc +++ b/base/message_pump_win.cc @@ -88,7 +88,6 @@ MessagePumpForUI::MessagePumpForUI() { MessagePumpForUI::~MessagePumpForUI() { DestroyWindow(message_hwnd_); - UnregisterClass(kWndClass, GetModuleHandle(NULL)); } void MessagePumpForUI::ScheduleWork() { diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_win.cc b/chrome/browser/autocomplete/autocomplete_edit_view_win.cc index 8f4c122..95a71b9 100644 --- a/chrome/browser/autocomplete/autocomplete_edit_view_win.cc +++ b/chrome/browser/autocomplete/autocomplete_edit_view_win.cc @@ -428,7 +428,6 @@ AutocompleteEditViewWin::AutocompleteEditViewWin( g_paint_patcher.Pointer()->RefPatch(); - // Note: on Vista and later, the next call implicity calls OleInitialize(). Create(hwnd, 0, 0, 0, l10n_util::GetExtendedStyles()); SetReadOnly(popup_window_mode_); SetFont(font_.hfont()); @@ -519,12 +518,6 @@ AutocompleteEditViewWin::~AutocompleteEditViewWin() { // been destroyed. This prevents us from relying on the AtExit or static // destructor sequence to do our unpatching, which is generally fragile. g_paint_patcher.Pointer()->DerefPatch(); - - // On Vista and later, the CRichEditCtrl window initializes OLE. - // We balance that initialization here. - win_util::WinVersion version = win_util::GetWinVersion(); - if (version >= win_util::WINVERSION_VISTA) - OleUninitialize(); } void AutocompleteEditViewWin::SaveStateToTab(TabContents* tab) { diff --git a/chrome/browser/process_singleton_win.cc b/chrome/browser/process_singleton_win.cc index c34a4d1..99d2d5f 100644 --- a/chrome/browser/process_singleton_win.cc +++ b/chrome/browser/process_singleton_win.cc @@ -45,10 +45,8 @@ ProcessSingleton::ProcessSingleton(const FilePath& user_data_dir) } ProcessSingleton::~ProcessSingleton() { - if (window_) { + if (window_) DestroyWindow(window_); - UnregisterClass(chrome::kMessageWindowClass, GetModuleHandle(NULL)); - } } bool ProcessSingleton::NotifyOtherProcess() { @@ -144,8 +142,7 @@ void ProcessSingleton::Create() { wc.lpfnWndProc = ProcessSingleton::WndProcStatic; wc.hInstance = hinst; wc.lpszClassName = chrome::kMessageWindowClass; - ATOM clazz = RegisterClassEx(&wc); - DCHECK(clazz); + RegisterClassEx(&wc); std::wstring user_data_dir; PathService::Get(chrome::DIR_USER_DATA, &user_data_dir); diff --git a/chrome/views/widget/widget_win.cc b/chrome/views/widget/widget_win.cc index 86795b5..a362f21 100644 --- a/chrome/views/widget/widget_win.cc +++ b/chrome/views/widget/widget_win.cc @@ -42,6 +42,13 @@ NativeControlWin* GetNativeControlWinForHWND(HWND hwnd) { ::GetProp(hwnd, NativeControlWin::kNativeControlWinKey)); } +// Used to locate the WidgetWin issuing the current Create. Only valid for the +// life of Create. +// +// This obviously assumes we only create WidgetWins from the same thread, +// which is currently the case. +static WidgetWin* instance_issuing_create = NULL; + /////////////////////////////////////////////////////////////////////////////// // Window class tracking. @@ -59,78 +66,36 @@ struct ClassInfo { background(NULL) {} // Compares two ClassInfos. Returns true if all members match. - bool Equals(const ClassInfo& other) const { + bool Equals(const ClassInfo& other) { return (other.style == style && other.background == background); } }; -class ClassRegistrar { - public: - ~ClassRegistrar() { - for (RegisteredClasses::iterator i = registered_classes_.begin(); - i != registered_classes_.end(); ++i) { - UnregisterClass(i->name.c_str(), NULL); - } +// Represents a registered window class. +struct RegisteredClass { + RegisteredClass(const ClassInfo& info, + const std::wstring& name, + ATOM atom) + : info(info), + name(name), + atom(atom) { } - // Puts the name for the class matching |class_info| in |class_name|, creating - // a new name if the class is not yet known. - // Returns true if this class was already known, false otherwise. - bool RetrieveClassName(const ClassInfo& class_info, std::wstring* name) { - for (RegisteredClasses::iterator i = registered_classes_.begin(); - i != registered_classes_.end(); ++i) { - if (class_info.Equals(i->info)) { - name->assign(i->name); - return true; - } - } - - name->assign(std::wstring(WidgetWin::kBaseClassName) + - IntToWString(registered_count_++)); - return false; - } - - void RegisterClass(const ClassInfo& class_info, - const std::wstring& name, - ATOM atom) { - registered_classes_.push_back(RegisteredClass(class_info, name, atom)); - } - - private: - // Represents a registered window class. - struct RegisteredClass { - RegisteredClass(const ClassInfo& info, - const std::wstring& name, - ATOM atom) - : info(info), - name(name), - atom(atom) { - } - - // Info used to create the class. - ClassInfo info; + // Info used to create the class. + ClassInfo info; - // The name given to the window. - std::wstring name; - - // The ATOM returned from creating the window. - ATOM atom; - }; - - ClassRegistrar() { } - friend struct DefaultSingletonTraits<ClassRegistrar>; + // The name given to the window. + std::wstring name; - typedef std::list<RegisteredClass> RegisteredClasses; - RegisteredClasses registered_classes_; + // The ATOM returned from creating the window. + ATOM atom; +}; - // Counter of how many classes have ben registered so far. - static int registered_count_; +typedef std::list<RegisteredClass> RegisteredClasses; - DISALLOW_COPY_AND_ASSIGN(ClassRegistrar); -}; +// The list of registered classes. +static RegisteredClasses* registered_classes = NULL; -// static -int ClassRegistrar::registered_count_ = 0; /////////////////////////////////////////////////////////////////////////////// // WidgetWin, public @@ -890,12 +855,19 @@ void WidgetWin::UpdateWindowFromContents(HDC dib_dc) { } std::wstring WidgetWin::GetWindowClassName() { + if (!registered_classes) + registered_classes = new RegisteredClasses(); ClassInfo class_info(initial_class_style()); - std::wstring name; - if (Singleton<ClassRegistrar>()->RetrieveClassName(class_info, &name)) - return name; + for (RegisteredClasses::iterator i = registered_classes->begin(); + i != registered_classes->end(); ++i) { + if (class_info.Equals(i->info)) + return i->name; + } // No class found, need to register one. + static int registered_count = 0; + std::wstring name = + std::wstring(kBaseClassName) + IntToWString(registered_count++); WNDCLASSEX class_ex; class_ex.cbSize = sizeof(WNDCLASSEX); class_ex.style = class_info.style; @@ -912,9 +884,8 @@ std::wstring WidgetWin::GetWindowClassName() { class_ex.hIconSm = class_ex.hIcon; ATOM atom = RegisterClassEx(&class_ex); DCHECK(atom); - - Singleton<ClassRegistrar>()->RegisterClass(class_info, name, atom); - + RegisteredClass registered_class(class_info, name, atom); + registered_classes->push_back(registered_class); return name; } |