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

Unified Diff: chrome_frame/chrome_frame_helper_util.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, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome_frame/chrome_frame_helper_util.h ('k') | chrome_frame/chrome_frame_helper_version.rc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome_frame/chrome_frame_helper_util.cc
===================================================================
--- chrome_frame/chrome_frame_helper_util.cc (revision 0)
+++ chrome_frame/chrome_frame_helper_util.cc (revision 0)
@@ -0,0 +1,88 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome_frame/chrome_frame_helper_util.h"
+
+#include <shlwapi.h>
+
+const wchar_t kGetBrowserMessage[] = L"GetAutomationObject";
+
+bool UtilIsWebBrowserWindow(HWND window_to_check) {
+ bool is_browser_window = false;
+
+ if (!IsWindow(window_to_check)) {
+ return is_browser_window;
+ }
+
+ static wchar_t* known_ie_window_classes[] = {
+ L"IEFrame",
+ L"TabWindowClass"
+ };
+
+ for (int i = 0; i < ARRAYSIZE(known_ie_window_classes); i++) {
+ if (IsWindowOfClass(window_to_check, known_ie_window_classes[i])) {
+ is_browser_window = true;
+ break;
+ }
+ }
+
+ return is_browser_window;
+}
+
+HRESULT UtilGetWebBrowserObjectFromWindow(HWND window,
+ REFIID iid,
+ void** web_browser_object) {
+ if (NULL == web_browser_object) {
+ return E_POINTER;
+ }
+
+ // Check whether this window is really a web browser window.
+ if (UtilIsWebBrowserWindow(window)) {
+ // IWebBroswer2 interface pointer can be retrieved from the browser
+ // window by simply sending a registered message "GetAutomationObject"
+ // Note that since we are sending a message to parent window make sure that
+ // it is in the same thread.
+ if (GetWindowThreadProcessId(window, NULL) != GetCurrentThreadId()) {
+ return E_UNEXPECTED;
+ }
+
+ static const ULONG get_browser_message =
+ RegisterWindowMessageW(kGetBrowserMessage);
+
+ *web_browser_object =
+ reinterpret_cast<void*>(SendMessage(window,
+ get_browser_message,
+ reinterpret_cast<WPARAM>(&iid),
+ NULL));
+ if (NULL != *web_browser_object) {
+ return S_OK;
+ }
+ } else {
+ return E_INVALIDARG;
+ }
+ return E_NOINTERFACE;
+}
+
+
+bool IsWindowOfClass(HWND window_to_check, const wchar_t* window_class) {
+ bool window_matches = false;
+ const int buf_size = MAX_PATH;
+ wchar_t buffer[buf_size] = {0};
+ DWORD dwRetSize = GetClassNameW(window_to_check, buffer, buf_size);
+ // If the window name is any longer than this, it isn't the one we want.
+ if (dwRetSize < (buf_size - 1)) {
+ if (0 == lstrcmpiW(window_class, buffer)) {
+ window_matches = true;
+ }
+ }
+ return window_matches;
+}
+
+
+bool IsNamedProcess(const wchar_t* process_name) {
+ wchar_t file_path[2048] = {0};
+ GetModuleFileName(NULL, file_path, 2047);
+ wchar_t* file_name = PathFindFileName(file_path);
+ return (0 == lstrcmpiW(file_name, process_name));
+}
Property changes on: chrome_frame\chrome_frame_helper_util.cc
___________________________________________________________________
Added: svn:eol-style
+ LF
« no previous file with comments | « chrome_frame/chrome_frame_helper_util.h ('k') | chrome_frame/chrome_frame_helper_version.rc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698