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_frame/chrome_frame_activex.h" | 5 #include "chrome_frame/chrome_frame_activex.h" |
6 | 6 |
7 #include <wininet.h> | 7 #include <wininet.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <map> | 10 #include <map> |
(...skipping 19 matching lines...) Expand all Loading... |
30 #include "chrome_frame/utils.h" | 30 #include "chrome_frame/utils.h" |
31 | 31 |
32 namespace { | 32 namespace { |
33 | 33 |
34 // Class used to maintain a mapping from top-level windows to ChromeFrameActivex | 34 // Class used to maintain a mapping from top-level windows to ChromeFrameActivex |
35 // instances. | 35 // instances. |
36 class TopLevelWindowMapping { | 36 class TopLevelWindowMapping { |
37 public: | 37 public: |
38 typedef std::vector<HWND> WindowList; | 38 typedef std::vector<HWND> WindowList; |
39 | 39 |
40 static TopLevelWindowMapping* instance() { | 40 static TopLevelWindowMapping* GetInstance() { |
41 return Singleton<TopLevelWindowMapping>::get(); | 41 return Singleton<TopLevelWindowMapping>::get(); |
42 } | 42 } |
43 | 43 |
44 // Add |cf_window| to the set of windows registered under |top_window|. | 44 // Add |cf_window| to the set of windows registered under |top_window|. |
45 void AddMapping(HWND top_window, HWND cf_window) { | 45 void AddMapping(HWND top_window, HWND cf_window) { |
46 top_window_map_lock_.Lock(); | 46 top_window_map_lock_.Lock(); |
47 top_window_map_[top_window].push_back(cf_window); | 47 top_window_map_[top_window].push_back(cf_window); |
48 top_window_map_lock_.Unlock(); | 48 top_window_map_lock_.Unlock(); |
49 } | 49 } |
50 | 50 |
(...skipping 25 matching lines...) Expand all Loading... |
76 // Chrome-Frame instances. | 76 // Chrome-Frame instances. |
77 LRESULT CALLBACK TopWindowProc(int code, WPARAM wparam, LPARAM lparam) { | 77 LRESULT CALLBACK TopWindowProc(int code, WPARAM wparam, LPARAM lparam) { |
78 CWPSTRUCT *info = reinterpret_cast<CWPSTRUCT*>(lparam); | 78 CWPSTRUCT *info = reinterpret_cast<CWPSTRUCT*>(lparam); |
79 const UINT &message = info->message; | 79 const UINT &message = info->message; |
80 const HWND &message_hwnd = info->hwnd; | 80 const HWND &message_hwnd = info->hwnd; |
81 | 81 |
82 switch (message) { | 82 switch (message) { |
83 case WM_MOVE: | 83 case WM_MOVE: |
84 case WM_MOVING: { | 84 case WM_MOVING: { |
85 TopLevelWindowMapping::WindowList cf_instances = | 85 TopLevelWindowMapping::WindowList cf_instances = |
86 TopLevelWindowMapping::instance()->GetInstances(message_hwnd); | 86 TopLevelWindowMapping::GetInstance()->GetInstances(message_hwnd); |
87 TopLevelWindowMapping::WindowList::iterator | 87 TopLevelWindowMapping::WindowList::iterator |
88 iter(cf_instances.begin()), end(cf_instances.end()); | 88 iter(cf_instances.begin()), end(cf_instances.end()); |
89 for (;iter != end; ++iter) { | 89 for (;iter != end; ++iter) { |
90 PostMessage(*iter, WM_HOST_MOVED_NOTIFICATION, NULL, NULL); | 90 PostMessage(*iter, WM_HOST_MOVED_NOTIFICATION, NULL, NULL); |
91 } | 91 } |
92 break; | 92 break; |
93 } | 93 } |
94 default: | 94 default: |
95 break; | 95 break; |
96 } | 96 } |
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
639 return hr; | 639 return hr; |
640 | 640 |
641 HWND parent_wnd; | 641 HWND parent_wnd; |
642 hr = ole_window->GetWindow(&parent_wnd); | 642 hr = ole_window->GetWindow(&parent_wnd); |
643 if (FAILED(hr)) | 643 if (FAILED(hr)) |
644 return hr; | 644 return hr; |
645 | 645 |
646 HWND top_window = ::GetAncestor(parent_wnd, GA_ROOT); | 646 HWND top_window = ::GetAncestor(parent_wnd, GA_ROOT); |
647 chrome_wndproc_hook_ = InstallLocalWindowHook(top_window); | 647 chrome_wndproc_hook_ = InstallLocalWindowHook(top_window); |
648 if (chrome_wndproc_hook_) | 648 if (chrome_wndproc_hook_) |
649 TopLevelWindowMapping::instance()->AddMapping(top_window, m_hWnd); | 649 TopLevelWindowMapping::GetInstance()->AddMapping(top_window, m_hWnd); |
650 | 650 |
651 return chrome_wndproc_hook_ ? S_OK : E_FAIL; | 651 return chrome_wndproc_hook_ ? S_OK : E_FAIL; |
652 } | 652 } |
653 | 653 |
654 HRESULT ChromeFrameActivex::registerBhoIfNeeded() { | 654 HRESULT ChromeFrameActivex::registerBhoIfNeeded() { |
655 if (!m_spUnkSite) { | 655 if (!m_spUnkSite) { |
656 NOTREACHED() << "Invalid client site"; | 656 NOTREACHED() << "Invalid client site"; |
657 return E_FAIL; | 657 return E_FAIL; |
658 } | 658 } |
659 | 659 |
(...skipping 27 matching lines...) Expand all Loading... |
687 if (FAILED(hr)) { | 687 if (FAILED(hr)) { |
688 NOTREACHED() << "ChromeFrame BHO SetSite failed. Error:" | 688 NOTREACHED() << "ChromeFrame BHO SetSite failed. Error:" |
689 << base::StringPrintf(" 0x%08X", hr); | 689 << base::StringPrintf(" 0x%08X", hr); |
690 return hr; | 690 return hr; |
691 } | 691 } |
692 | 692 |
693 web_browser2->PutProperty(base::win::ScopedBstr(bho_class_id_as_string), | 693 web_browser2->PutProperty(base::win::ScopedBstr(bho_class_id_as_string), |
694 base::win::ScopedVariant(bho)); | 694 base::win::ScopedVariant(bho)); |
695 return S_OK; | 695 return S_OK; |
696 } | 696 } |
OLD | NEW |