summaryrefslogtreecommitdiffstats
path: root/chrome_frame
diff options
context:
space:
mode:
authoramit@chromium.org <amit@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-03 22:33:46 +0000
committeramit@chromium.org <amit@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-03 22:33:46 +0000
commitf6985243ea050cb848843faf4b63049f5285dce7 (patch)
tree0f6b63aaeffefa25ac104d9121847ee0a254bfd4 /chrome_frame
parent52dde0af9ceba4d770c07a37d5ef93d230c4290b (diff)
downloadchromium_src-f6985243ea050cb848843faf4b63049f5285dce7.zip
chromium_src-f6985243ea050cb848843faf4b63049f5285dce7.tar.gz
chromium_src-f6985243ea050cb848843faf4b63049f5285dce7.tar.bz2
Move modified ATL sample code to third_party
No code modifications other than removing chromium licence block. BUG=80617 TEST=none Review URL: http://codereview.chromium.org/6901059 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@83979 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame')
-rw-r--r--chrome_frame/chrome_active_document.h4
-rw-r--r--chrome_frame/chrome_frame.gyp6
-rw-r--r--chrome_frame/in_place_menu.h202
-rw-r--r--chrome_frame/ole_document_impl.h247
4 files changed, 5 insertions, 454 deletions
diff --git a/chrome_frame/chrome_active_document.h b/chrome_frame/chrome_active_document.h
index a720f23..5440528 100644
--- a/chrome_frame/chrome_active_document.h
+++ b/chrome_frame/chrome_active_document.h
@@ -25,10 +25,10 @@
#include "chrome_frame/find_dialog.h"
#include "chrome_frame/html_private_window_impl.h"
#include "chrome_frame/html_window_impl.h"
-#include "chrome_frame/in_place_menu.h"
-#include "chrome_frame/ole_document_impl.h"
#include "chrome_frame/resource.h"
#include "chrome_frame/utils.h"
+#include "third_party/active_doc/in_place_menu.h"
+#include "third_party/active_doc/ole_document_impl.h"
class Thread;
class TabProxy;
diff --git a/chrome_frame/chrome_frame.gyp b/chrome_frame/chrome_frame.gyp
index b454c51..228e102 100644
--- a/chrome_frame/chrome_frame.gyp
+++ b/chrome_frame/chrome_frame.gyp
@@ -711,6 +711,7 @@
'exception_barrier.cc',
'exception_barrier.h',
'exception_barrier_lowlevel.asm',
+ 'extra_system_apis.h',
'find_dialog.cc',
'find_dialog.h',
'function_stub.cc',
@@ -720,7 +721,6 @@
'http_negotiate.cc',
'http_negotiate.h',
'iids.cc',
- 'in_place_menu.h',
'infobars/infobar_content.h',
'infobars/internal/displaced_window_manager.cc',
'infobars/internal/displaced_window_manager.h',
@@ -733,7 +733,6 @@
'infobars/infobar_manager.cc',
'metrics_service.cc',
'metrics_service.h',
- 'ole_document_impl.h',
'policy_settings.cc',
'policy_settings.h',
'protocol_sink_wrap.cc',
@@ -753,7 +752,8 @@
'register_bho.rgs',
'stream_impl.cc',
'stream_impl.h',
- 'extra_system_apis.h',
+ 'third_party/active_doc/in_place_menu.h',
+ 'third_party/active_doc/ole_document_impl.h',
'urlmon_bind_status_callback.h',
'urlmon_bind_status_callback.cc',
'urlmon_moniker.h',
diff --git a/chrome_frame/in_place_menu.h b/chrome_frame/in_place_menu.h
deleted file mode 100644
index 76e9d75..0000000
--- a/chrome_frame/in_place_menu.h
+++ /dev/null
@@ -1,202 +0,0 @@
-// Copyright (c) 2011 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.
-
-#ifndef CHROME_FRAME_IN_PLACE_MENU_H_
-#define CHROME_FRAME_IN_PLACE_MENU_H_
-
-// in_place_menu.h : menu merging implementation
-//
-// This file is a modified version of the menu.h file, which is
-// part of the ActiveDoc MSDN sample. The modifications are largely
-// conversions to Google coding guidelines. Below is the original header
-// from the file.
-
-// This is a part of the Active Template Library.
-// Copyright (c) Microsoft Corporation. All rights reserved.
-//
-// This source code is only intended as a supplement to the
-// Active Template Library Reference and related
-// electronic documentation provided with the library.
-// See these sources for detailed information regarding the
-// Active Template Library product.
-
-#include "base/logging.h"
-#include "base/win/scoped_comptr.h"
-
-template <class T>
-class InPlaceMenu {
- public:
- InPlaceMenu() : shared_menu_(NULL), ole_menu_(NULL), our_menu_(NULL) {
- }
-
- ~InPlaceMenu() {
- InPlaceMenuDestroy();
- }
-
- HRESULT InPlaceMenuCreate(LPCWSTR menu_name) {
- // We might already have an in-place menu set, because we set menus
- // IOleDocumentView::UIActivate as well as in
- // IOleInPlaceActiveObject::OnDocWindowActivate. If we have already
- // done our work, just return silently
- if (ole_menu_ || shared_menu_)
- return S_OK;
-
- base::win::ScopedComPtr<IOleInPlaceFrame> in_place_frame;
- GetInPlaceFrame(in_place_frame.Receive());
- // We have no IOleInPlaceFrame, no menu merging possible
- if (!in_place_frame) {
- NOTREACHED();
- return E_FAIL;
- }
- // Create a blank menu and ask the container to add
- // its menus into the OLEMENUGROUPWIDTHS structure
- shared_menu_ = ::CreateMenu();
- OLEMENUGROUPWIDTHS mgw = {0};
- HRESULT hr = in_place_frame->InsertMenus(shared_menu_, &mgw);
- if (FAILED(hr)) {
- ::DestroyMenu(shared_menu_);
- shared_menu_ = NULL;
- return hr;
- }
- // Insert our menus
- our_menu_ = LoadMenu(_AtlBaseModule.GetResourceInstance(),menu_name);
- MergeMenus(shared_menu_, our_menu_, &mgw.width[0], 1);
- // Send the menu to the client
- ole_menu_ = (HMENU)OleCreateMenuDescriptor(shared_menu_, &mgw);
- T* t = static_cast<T*>(this);
- in_place_frame->SetMenu(shared_menu_, ole_menu_, t->m_hWnd);
- return S_OK;
- }
-
- HRESULT InPlaceMenuDestroy() {
- base::win::ScopedComPtr<IOleInPlaceFrame> in_place_frame;
- GetInPlaceFrame(in_place_frame.Receive());
- if (in_place_frame) {
- in_place_frame->RemoveMenus(shared_menu_);
- in_place_frame->SetMenu(NULL, NULL, NULL);
- }
- if (ole_menu_) {
- OleDestroyMenuDescriptor(ole_menu_);
- ole_menu_ = NULL;
- }
- if (shared_menu_) {
- UnmergeMenus(shared_menu_, our_menu_);
- DestroyMenu(shared_menu_);
- shared_menu_ = NULL;
- }
- if (our_menu_) {
- DestroyMenu(our_menu_);
- our_menu_ = NULL;
- }
- return S_OK;
- }
-
- void MergeMenus(HMENU shared_menu, HMENU source_menu, LONG* menu_widths,
- unsigned int width_index) {
- // Copy the popups from the source menu
- // Insert at appropriate spot depending on width_index
- DCHECK(width_index == 0 || width_index == 1);
- int position = 0;
- if (width_index == 1)
- position = (int)menu_widths[0];
- int group_width = 0;
- int menu_items = GetMenuItemCount(source_menu);
- for (int index = 0; index < menu_items; index++) {
- // Get the HMENU of the popup
- HMENU popup_menu = ::GetSubMenu(source_menu, index);
- // Separators move us to next group
- UINT state = GetMenuState(source_menu, index, MF_BYPOSITION);
- if (!popup_menu && (state & MF_SEPARATOR)) {
- // Servers should not touch past 5
- DCHECK(width_index <= 5);
- menu_widths[width_index] = group_width;
- group_width = 0;
- if (width_index < 5)
- position += static_cast<int>(menu_widths[width_index+1]);
- width_index += 2;
- } else {
- // Get the menu item text
- TCHAR item_text[256] = {0};
- int text_length = GetMenuString(source_menu, index, item_text,
- ARRAYSIZE(item_text), MF_BYPOSITION);
- // Popups are handled differently than normal menu items
- if (popup_menu) {
- if (::GetMenuItemCount(popup_menu) != 0) {
- // Strip the HIBYTE because it contains a count of items
- state = LOBYTE(state) | MF_POPUP; // Must be popup
- // Non-empty popup -- add it to the shared menu bar
- InsertMenu(shared_menu, position, state|MF_BYPOSITION,
- reinterpret_cast<UINT_PTR>(popup_menu), item_text);
- ++position;
- ++group_width;
- }
- } else if (text_length > 0) {
- // only non-empty items are added
- DCHECK(item_text[0] != 0);
- // here the state does not contain a count in the HIBYTE
- InsertMenu(shared_menu, position, state|MF_BYPOSITION,
- GetMenuItemID(source_menu, index), item_text);
- ++position;
- ++group_width;
- }
- }
- }
- }
-
- void UnmergeMenus(HMENU shared_menu, HMENU source_menu) {
- int our_item_count = GetMenuItemCount(source_menu);
- int shared_item_count = GetMenuItemCount(shared_menu);
-
- for (int index = shared_item_count - 1; index >= 0; index--) {
- // Check the popup menus
- HMENU popup_menu = ::GetSubMenu(shared_menu, index);
- if (popup_menu) {
- // If it is one of ours, remove it from the shared menu
- for (int sub_index = 0; sub_index < our_item_count; sub_index++) {
- if (::GetSubMenu(source_menu, sub_index) == popup_menu) {
- // Remove the menu from hMenuShared
- RemoveMenu(shared_menu, index, MF_BYPOSITION);
- break;
- }
- }
- }
- }
- }
-
- protected:
- HRESULT GetInPlaceFrame(IOleInPlaceFrame** in_place_frame) {
- if (!in_place_frame) {
- NOTREACHED();
- return E_POINTER;
- }
- T* t = static_cast<T*>(this);
- HRESULT hr = E_FAIL;
- if (S_OK != t->GetInPlaceFrame(in_place_frame)) {
- // We weren't given an IOleInPlaceFrame pointer, so
- // we'll have to get it ourselves.
- if (t->m_spInPlaceSite) {
- t->frame_info_.cb = sizeof(OLEINPLACEFRAMEINFO);
- base::win::ScopedComPtr<IOleInPlaceUIWindow> in_place_ui_window;
- RECT position_rect = {0};
- RECT clip_rect = {0};
- hr = t->m_spInPlaceSite->GetWindowContext(in_place_frame,
- in_place_ui_window.Receive(),
- &position_rect, &clip_rect,
- &t->frame_info_);
- }
- }
- return hr;
- }
-
- protected:
- // The OLE menu descriptor created by the OleCreateMenuDescriptor
- HMENU ole_menu_;
- // The shared menu that we pass to IOleInPlaceFrame::SetMenu
- HMENU shared_menu_;
- // Our menu resource that we want to insert
- HMENU our_menu_;
-};
-
-#endif // CHROME_FRAME_IN_PLACE_MENU_H_
-
diff --git a/chrome_frame/ole_document_impl.h b/chrome_frame/ole_document_impl.h
deleted file mode 100644
index f18db16..0000000
--- a/chrome_frame/ole_document_impl.h
+++ /dev/null
@@ -1,247 +0,0 @@
-// 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.
-
-// TODO(slightlyoff): Add any required LICENSE block changes for MSFT code
-// inclusion.
-
-// ole_document_impl.h : IOleDocument implementation
-//
-// This file is a modified version of the OleDocument.h file, which is
-// part of the ActiveDoc MSDN sample. The modifications are largely
-// conversions to Google coding guidelines. Below if the original header
-// from the file.
-
-// This is a part of the Active Template Library.
-// Copyright (c) Microsoft Corporation. All rights reserved.
-//
-// This source code is only intended as a supplement to the
-// Active Template Library Reference and related
-// electronic documentation provided with the library.
-// See these sources for detailed information regarding the
-// Active Template Library product.
-
-#ifndef CHROME_FRAME_OLE_DOCUMENT_IMPL_H_
-#define CHROME_FRAME_OLE_DOCUMENT_IMPL_H_
-
-// TODO(sanjeevr): Revisit this impl file and cleanup dependencies
-#include <atlbase.h>
-#include <docobj.h>
-
-#include "base/logging.h"
-
-//////////////////////////////////////////////////////////////////////////////
-// IOleDocumentImpl
-template <class T>
-class ATL_NO_VTABLE IOleDocumentImpl : public IOleDocument {
- public:
- STDMETHOD(CreateView)(IOleInPlaceSite* in_place_site,
- IStream* stream,
- DWORD reserved ,
- IOleDocumentView** new_view) {
- DVLOG(1) << __FUNCTION__;
- if (new_view == NULL)
- return E_POINTER;
- T* t = static_cast<T*>(this);
- // If we've already created a view then we can't create another as we
- // currently only support the ability to create one view
- if (t->m_spInPlaceSite)
- return E_FAIL;
- IOleDocumentView* view;
- t->GetUnknown()->QueryInterface(IID_IOleDocumentView,
- reinterpret_cast<void**>(&view));
- // If we support IOleDocument we should support IOleDocumentView
- ATLENSURE(view != NULL);
- // If they've given us a site then use it
- if (in_place_site != NULL)
- view->SetInPlaceSite(in_place_site);
- // If they have given us an IStream pointer then use it to
- // initialize the view
- if (stream != NULL)
- view->ApplyViewState(stream);
- // Return the view
- *new_view = view;
- return S_OK;
- }
-
- STDMETHOD(GetDocMiscStatus)(DWORD* status) {
- DVLOG(1) << __FUNCTION__;
- if (NULL == status)
- return E_POINTER;
- *status = DOCMISC_NOFILESUPPORT;
- return S_OK;
- }
-
- STDMETHOD(EnumViews)(IEnumOleDocumentViews** enum_views,
- IOleDocumentView** view) {
- DVLOG(1) << __FUNCTION__;
- if (view == NULL)
- return E_POINTER;
- T* t = static_cast<T*>(this);
- // We only support one view
- return t->_InternalQueryInterface(IID_IOleDocumentView,
- reinterpret_cast<void**>(view));
- }
-};
-
-//////////////////////////////////////////////////////////////////////////////
-// IOleDocumentViewImpl
-
-template <class T>
-class ATL_NO_VTABLE IOleDocumentViewImpl : public IOleDocumentView {
- public:
- STDMETHOD(SetInPlaceSite)(IOleInPlaceSite* in_place_site) {
- DVLOG(1) << __FUNCTION__;
- T* t = static_cast<T*>(this);
- if (t->m_spInPlaceSite) {
- // If we already have a site get rid of it
- UIActivate(FALSE);
- HRESULT hr = t->InPlaceDeactivate();
- if (FAILED(hr))
- return hr;
- DCHECK(!t->m_bInPlaceActive);
- }
- if (in_place_site != NULL) {
- t->m_spInPlaceSite.Release();
- in_place_site->QueryInterface(
- IID_IOleInPlaceSiteWindowless,
- reinterpret_cast<void **>(&t->m_spInPlaceSite));
- if (!t->m_spInPlaceSite) {
- // TODO(sanjeevr): This is a super-hack because m_spInPlaceSite
- // is an IOleInPlaceSiteWindowless pointer and we are setting
- // an IOleInPlaceSite pointer into it. The problem is that ATL
- // (CComControlBase) uses this in a schizophrenic manner based
- // on the m_bWndLess flag. Ouch, ouch, ouch! Find a way to clean
- // this up.
- // Disclaimer: I did not invent this hack, it exists in the MSDN
- // sample from where this code has been derived and it also exists
- // in ATL itself (look at atlctl.h line 938).
- t->m_spInPlaceSite =
- reinterpret_cast<IOleInPlaceSiteWindowless*>(in_place_site);
- }
- }
- return S_OK;
- }
-
- STDMETHOD(GetInPlaceSite)(IOleInPlaceSite** in_place_site) {
- DVLOG(1) << __FUNCTION__;
- if (in_place_site == NULL)
- return E_POINTER;
- T* t = static_cast<T*>(this);
- return t->m_spInPlaceSite->QueryInterface(
- IID_IOleInPlaceSite,
- reinterpret_cast<LPVOID *>(in_place_site));
- }
-
- STDMETHOD(GetDocument)(IUnknown** document) {
- DVLOG(1) << __FUNCTION__;
- if (document == NULL)
- return E_POINTER;
- T* t = static_cast<T*>(this);
- *document = t->GetUnknown();
- (*document)->AddRef();
- return S_OK;
- }
-
- STDMETHOD(SetRect)(LPRECT view_rect) {
- static bool is_resizing = false;
- if (is_resizing)
- return S_OK;
- is_resizing = true;
- DVLOG(1) << __FUNCTION__ << " " << view_rect->left << ","
- << view_rect->top << "," << view_rect->right << ","
- << view_rect->bottom;
- T* t = static_cast<T*>(this);
- t->SetObjectRects(view_rect, view_rect);
- is_resizing = false;
- return S_OK;
- }
-
- STDMETHOD(GetRect)(LPRECT view_rect) {
- DVLOG(1) << __FUNCTION__;
- if (view_rect == NULL)
- return E_POINTER;
- T* t = static_cast<T*>(this);
- *view_rect = t->m_rcPos;
- return S_OK;
- }
-
- STDMETHOD(SetRectComplex)(LPRECT view_rect,
- LPRECT hscroll_rect,
- LPRECT vscroll_rect,
- LPRECT size_box_rect) {
- DVLOG(1) << __FUNCTION__ << " not implemented";
- return E_NOTIMPL;
- }
-
- STDMETHOD(Show)(BOOL show) {
- DVLOG(1) << __FUNCTION__;
- T* t = static_cast<T*>(this);
- HRESULT hr = S_OK;
- if (show) {
- if (!t->m_bUIActive)
- hr = t->ActiveXDocActivate(OLEIVERB_INPLACEACTIVATE);
- } else {
- hr = t->UIActivate(FALSE);
- ::ShowWindow(t->m_hWnd, SW_HIDE);
- }
- return hr;
- }
-
- STDMETHOD(UIActivate)(BOOL ui_activate) {
- DVLOG(1) << __FUNCTION__;
- T* t = static_cast<T*>(this);
- HRESULT hr = S_OK;
- if (ui_activate) {
- // We must know the client site first
- if (t->m_spInPlaceSite == NULL)
- return E_UNEXPECTED;
- if (!t->m_bUIActive)
- hr = t->ActiveXDocActivate(OLEIVERB_UIACTIVATE);
- } else {
- // Menu integration is still not complete, so do not destroy
- // IE's menus. If we call InPlaceMenuDestroy here, menu items such
- // as Print etc will be disabled and we will not get calls to QueryStatus
- // for those commands.
- // t->InPlaceMenuDestroy();
- // t->DestroyToolbar();
- hr = t->UIDeactivate();
- }
- return hr;
- }
-
- STDMETHOD(Open)() {
- DVLOG(1) << __FUNCTION__ << " not implemented";
- return E_NOTIMPL;
- }
-
- STDMETHOD(CloseView)(DWORD reserved) {
- DVLOG(1) << __FUNCTION__;
- T* t = static_cast<T*>(this);
- t->Show(FALSE);
- t->SetInPlaceSite(NULL);
- return S_OK;
- }
-
- STDMETHOD(SaveViewState)(LPSTREAM stream) {
- DVLOG(1) << __FUNCTION__ << " not implemented";
- return E_NOTIMPL;
- }
-
- STDMETHOD(ApplyViewState)(LPSTREAM stream) {
- DVLOG(1) << __FUNCTION__ << " not implemented";
- return E_NOTIMPL;
- }
-
- STDMETHOD(Clone)(IOleInPlaceSite* new_in_place_site,
- IOleDocumentView** new_view) {
- DVLOG(1) << __FUNCTION__ << " not implemented";
- return E_NOTIMPL;
- }
-
- HRESULT ActiveXDocActivate(LONG verb) {
- return E_NOTIMPL;
- }
-};
-
-#endif // CHROME_FRAME_OLE_DOCUMENT_IMPL_H_