Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(206)

Side by Side Diff: chrome_frame/bho_loader.cc

Issue 3158036: Add a helper process to Chrome Frame to allow for non-administrative installs... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome_frame/bho_loader.h ('k') | chrome_frame/chrome_frame.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome_frame/bho_loader.h"
6
7 #include <atlbase.h>
8 #include <atlcomcli.h>
9 #include <exdisp.h>
10
11 #include "chrome_frame/chrome_frame_helper_util.h"
12 #include "chrome_frame/event_hooker.h"
13 #include "chrome_tab.h" // NOLINT
14
15
16 // Describes the window class we look for.
17 const wchar_t kStatusBarWindowClass[] = L"msctls_statusbar32";
18
19 BHOLoader::BHOLoader() : hooker_(new EventHooker()) {
20 }
21
22 BHOLoader::~BHOLoader() {
23 if (hooker_) {
24 delete hooker_;
25 hooker_ = NULL;
26 }
27 }
28
29 void BHOLoader::OnHookEvent(DWORD event, HWND window) {
30 // Step 1: Make sure that we are in a process named iexplore.exe.
31 if (IsNamedProcess(L"iexplore.exe")) {
32 // Step 2: Check to see if the window is of the right class.
33 // IE loads BHOs in the WM_CREATE handler of the tab window approximately
34 // after it creates the status bar window. To be as close to IE as possible
35 // in our simulation on BHO loading, we watch for the status bar to be
36 // created and do our simulated BHO loading at that time.
37 if (IsWindowOfClass(window, kStatusBarWindowClass)) {
38 HWND parent_window = GetParent(window);
39 // Step 3:
40 // Parent window of status bar window is the web browser window. Try to
41 // get its IWebBrowser2 interface
42 CComPtr<IWebBrowser2> browser;
43 UtilGetWebBrowserObjectFromWindow(parent_window, __uuidof(browser),
44 reinterpret_cast<void**>(&browser));
45 if (browser) {
46 // TODO(robertshield): We may need to find a way to prevent doing this
47 // twice. A marker of some kind would do. Ask during review for good
48 // suggestions.
49
50 // Step 4:
51 // We have the IWebBrowser2 interface. Now create the BHO instance
52 CComPtr<IObjectWithSite> bho_object;
53 HRESULT error_code = bho_object.CoCreateInstance(CLSID_ChromeFrameBHO,
54 NULL,
55 CLSCTX_INPROC_SERVER);
56
57 if (SUCCEEDED(error_code) && bho_object) {
58 // Step 5:
59 // Initialize the BHO by calling SetSite and passing it IWebBrowser2
60 error_code = bho_object->SetSite(browser);
61 if (SUCCEEDED(error_code)) {
62 // Step 6:
63 // Now add the BHO to the collection of automation objects. This
64 // will ensure that BHO will be accessible from the web pages as
65 // any other BHO. Importantly, it will make sure that our BHO
66 // will be cleaned up at the right time along with other BHOs.
67 wchar_t bho_clsid_as_string[MAX_PATH] = {0};
68 StringFromGUID2(CLSID_ChromeFrameBHO, bho_clsid_as_string,
69 ARRAYSIZE(bho_clsid_as_string));
70
71 CComBSTR bho_clsid_as_string_bstr(bho_clsid_as_string);
72 CComVariant object_variant(bho_object);
73
74 browser->PutProperty(bho_clsid_as_string_bstr, object_variant);
75 }
76 }
77 }
78 }
79 }
80 }
81
82 bool BHOLoader::StartHook() {
83 return hooker_->StartHook();
84 }
85
86 void BHOLoader::StopHook() {
87 hooker_->StopHook();
88 }
89
90 BHOLoader* BHOLoader::GetInstance() {
91 static BHOLoader loader;
92 return &loader;
93 }
OLDNEW
« no previous file with comments | « chrome_frame/bho_loader.h ('k') | chrome_frame/chrome_frame.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698