diff options
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/automation/automation_provider.cc | 4 | ||||
-rw-r--r-- | chrome/browser/automation/automation_provider.h | 3 | ||||
-rw-r--r-- | chrome/browser/automation/automation_provider_win.cc | 10 | ||||
-rw-r--r-- | chrome/browser/automation/chrome_frame_automation_provider.cc | 1 | ||||
-rw-r--r-- | chrome/browser/external_tab_container.cc | 13 | ||||
-rw-r--r-- | chrome/browser/external_tab_container.h | 10 | ||||
-rw-r--r-- | chrome/browser/views/browser_bubble.cc | 38 | ||||
-rw-r--r-- | chrome/browser/views/browser_bubble.h | 7 | ||||
-rw-r--r-- | chrome/browser/views/frame/browser_bubble_host.cc | 43 | ||||
-rw-r--r-- | chrome/browser/views/frame/browser_bubble_host.h | 42 | ||||
-rw-r--r-- | chrome/browser/views/frame/browser_view.cc | 26 | ||||
-rw-r--r-- | chrome/browser/views/frame/browser_view.h | 11 |
12 files changed, 160 insertions, 48 deletions
diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc index 8cef80a..be3a44e 100644 --- a/chrome/browser/automation/automation_provider.cc +++ b/chrome/browser/automation/automation_provider.cc @@ -465,6 +465,9 @@ void AutomationProvider::OnMessageReceived(const IPC::Message& message) { IPC_MESSAGE_HANDLER(AutomationMsg_ShutdownSessionService, ShutdownSessionService) IPC_MESSAGE_HANDLER(AutomationMsg_SaveAsAsync, SaveAsAsync) +#if defined(OS_WIN) + IPC_MESSAGE_HANDLER(AutomationMsg_BrowserMove, OnBrowserMoved) +#endif IPC_END_MESSAGE_MAP() } @@ -2264,4 +2267,3 @@ void AutomationProvider::SaveAsAsync(int tab_handle) { if (tab_contents) tab_contents->OnSavePage(); } - diff --git a/chrome/browser/automation/automation_provider.h b/chrome/browser/automation/automation_provider.h index de371f8..24b381a 100644 --- a/chrome/browser/automation/automation_provider.h +++ b/chrome/browser/automation/automation_provider.h @@ -229,6 +229,9 @@ class AutomationProvider : public base::RefCounted<AutomationProvider>, void SetProxyConfig(const std::string& new_proxy_config); void IsFullscreen(int handle, bool* is_fullscreen); void GetFullscreenBubbleVisibility(int handle, bool* is_visible); +#if defined(OS_WIN) + void OnBrowserMoved(int handle); +#endif #if defined(OS_WIN) void ScheduleMouseEvent(views::View* view, diff --git a/chrome/browser/automation/automation_provider_win.cc b/chrome/browser/automation/automation_provider_win.cc index d5457e9..59d9867 100644 --- a/chrome/browser/automation/automation_provider_win.cc +++ b/chrome/browser/automation/automation_provider_win.cc @@ -506,3 +506,13 @@ void AutomationProvider::SetEnableExtensionAutomation( "SetEnableExtensionAutomation called with invalid tab handle."; } } + +void AutomationProvider::OnBrowserMoved(int tab_handle) { + ExternalTabContainer* external_tab = GetExternalTabForHandle(tab_handle); + if (external_tab) { + external_tab->WindowMoved(); + } else { + DLOG(WARNING) << + "AutomationProvider::OnBrowserMoved called with invalid tab handle."; + } +} diff --git a/chrome/browser/automation/chrome_frame_automation_provider.cc b/chrome/browser/automation/chrome_frame_automation_provider.cc index f9e82f7..ab87b92 100644 --- a/chrome/browser/automation/chrome_frame_automation_provider.cc +++ b/chrome/browser/automation/chrome_frame_automation_provider.cc @@ -35,6 +35,7 @@ bool ChromeFrameAutomationProvider::IsValidMessage(uint32 type) { case AutomationMsg_CreateExternalTab::ID: case AutomationMsg_ConnectExternalTab::ID: #if defined(OS_WIN) + case AutomationMsg_BrowserMove::ID: case AutomationMsg_ProcessUnhandledAccelerator::ID: case AutomationMsg_TabReposition::ID: case AutomationMsg_ForwardContextMenuCommandToChrome::ID: diff --git a/chrome/browser/external_tab_container.cc b/chrome/browser/external_tab_container.cc index 9e098fd..837d006 100644 --- a/chrome/browser/external_tab_container.cc +++ b/chrome/browser/external_tab_container.cc @@ -256,7 +256,7 @@ void ExternalTabContainer::FocusThroughTabTraversal(bool reverse) { // static bool ExternalTabContainer::IsExternalTabContainer(HWND window) { - if (GetProp(window, kWindowObjectKey) != NULL) + if (::GetProp(window, kWindowObjectKey) != NULL) return true; return false; @@ -277,6 +277,17 @@ ExternalTabContainer* ExternalTabContainer::GetContainerForTab( return container; } +// static +ExternalTabContainer* + ExternalTabContainer::GetExternalContainerFromNativeWindow( + gfx::NativeView native_window) { + ExternalTabContainer* tab_container = NULL; + if (native_window) { + HANDLE handle = ::GetProp(native_window, kWindowObjectKey); + tab_container = reinterpret_cast<ExternalTabContainer*>(handle); + } + return tab_container; +} //////////////////////////////////////////////////////////////////////////////// // ExternalTabContainer, TabContentsDelegate implementation: diff --git a/chrome/browser/external_tab_container.h b/chrome/browser/external_tab_container.h index 0b25afb..154d258 100644 --- a/chrome/browser/external_tab_container.h +++ b/chrome/browser/external_tab_container.h @@ -13,6 +13,7 @@ #include "chrome/browser/browser.h" #include "chrome/browser/net/chrome_url_request_context.h" #include "chrome/browser/tab_contents/tab_contents_delegate.h" +#include "chrome/browser/views/frame/browser_bubble_host.h" #include "chrome/browser/views/infobars/infobar_container.h" #include "chrome/browser/views/unhandled_keyboard_event_handler.h" #include "chrome/common/navigation_types.h" @@ -39,7 +40,8 @@ class ExternalTabContainer : public TabContentsDelegate, public views::WidgetWin, public base::RefCounted<ExternalTabContainer>, public views::AcceleratorTarget, - public InfoBarContainer::Delegate { + public InfoBarContainer::Delegate, + public BrowserBubbleHost { public: typedef std::map<intptr_t, scoped_refptr<ExternalTabContainer> > PendingTabs; @@ -89,6 +91,12 @@ class ExternalTabContainer : public TabContentsDelegate, // ExternalTabContainer window static bool IsExternalTabContainer(HWND window); + // A helper function that returns a pointer to the ExternalTabContainer + // instance associated with a native view. Returns NULL if the window + // is not an ExternalTabContainer. + static ExternalTabContainer* GetExternalContainerFromNativeWindow( + gfx::NativeView native_window); + // A helper method that retrieves the ExternalTabContainer object that // hosts the given tab window. static ExternalTabContainer* GetContainerForTab(HWND tab_window); diff --git a/chrome/browser/views/browser_bubble.cc b/chrome/browser/views/browser_bubble.cc index 1b690db..b199680 100644 --- a/chrome/browser/views/browser_bubble.cc +++ b/chrome/browser/views/browser_bubble.cc @@ -6,20 +6,35 @@ #include "app/l10n_util.h" #include "chrome/browser/views/frame/browser_view.h" +#if defined(OS_WIN) +#include "chrome/browser/external_tab_container.h" +#endif #include "views/widget/root_view.h" #include "views/window/window.h" namespace { -BrowserView* GetBrowserViewFromFrame(views::Widget* frame) { - BrowserView* browser_view = NULL; +BrowserBubbleHost* GetBubbleHostFromFrame(views::Widget* frame) { + if (!frame) + return NULL; + + BrowserBubbleHost* bubble_host = NULL; views::Window* window = frame->GetWindow(); if (window) { - browser_view = BrowserView::GetBrowserViewForNativeWindow( + bubble_host = BrowserView::GetBrowserViewForNativeWindow( window->GetNativeWindow()); - DCHECK(browser_view); + DCHECK(bubble_host); + } +#if defined(OS_WIN) + // The frame may also be an ExternalTabContainer, which is also capable of + // hosting BrowserBubbles. + gfx::NativeView native_view = frame->GetNativeView(); + if (!bubble_host) { + bubble_host = + ExternalTabContainer::GetExternalContainerFromNativeWindow(native_view); } - return browser_view; +#endif + return bubble_host; } } // namespace @@ -31,7 +46,8 @@ BrowserBubble::BrowserBubble(views::View* view, views::Widget* frame, visible_(false), delegate_(NULL), attached_(false), - drop_shadow_enabled_(drop_shadow) { + drop_shadow_enabled_(drop_shadow), + bubble_host_(GetBubbleHostFromFrame(frame)) { gfx::Size size = view->GetPreferredSize(); bounds_.SetRect(origin.x(), origin.y(), size.width(), size.height()); InitPopup(); @@ -55,9 +71,8 @@ void BrowserBubble::DetachFromBrowser() { return; attached_ = false; - BrowserView* browser_view = GetBrowserViewFromFrame(frame_); - if (browser_view) - browser_view->DetachBrowserBubble(this); + if (bubble_host_) + bubble_host_->DetachBrowserBubble(this); } void BrowserBubble::AttachToBrowser() { @@ -65,9 +80,8 @@ void BrowserBubble::AttachToBrowser() { if (attached_) return; - BrowserView* browser_view = GetBrowserViewFromFrame(frame_); - if (browser_view) - browser_view->AttachBrowserBubble(this); + if (bubble_host_) + bubble_host_->AttachBrowserBubble(this); attached_ = true; } diff --git a/chrome/browser/views/browser_bubble.h b/chrome/browser/views/browser_bubble.h index 012c552..feb55f8 100644 --- a/chrome/browser/views/browser_bubble.h +++ b/chrome/browser/views/browser_bubble.h @@ -8,6 +8,8 @@ #include "views/view.h" #include "views/widget/widget.h" +class BrowserBubbleHost; + // A class for creating a floating window that is "attached" to a particular // Browser. If you don't install a delegate, the bubble will hide // automatically when the browser moves. The bubble is only shown manually. @@ -58,7 +60,7 @@ class BrowserBubble { Delegate* delegate() const { return delegate_; } void set_delegate(Delegate* del) { delegate_ = del; } - // Notifications from BrowserView. + // Notifications from BrowserBubbleHost. // With no delegate, both of these default to Hiding the bubble. virtual void BrowserWindowMoved(); virtual void BrowserWindowClosing(); @@ -120,6 +122,9 @@ class BrowserBubble { // Does the bubble have a drop-shadow. bool drop_shadow_enabled_; + // Non-owning pointer to the host of this bubble. + BrowserBubbleHost* bubble_host_; + DISALLOW_COPY_AND_ASSIGN(BrowserBubble); }; diff --git a/chrome/browser/views/frame/browser_bubble_host.cc b/chrome/browser/views/frame/browser_bubble_host.cc new file mode 100644 index 0000000..60809bf --- /dev/null +++ b/chrome/browser/views/frame/browser_bubble_host.cc @@ -0,0 +1,43 @@ +// 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/browser/views/frame/browser_bubble_host.h" + +#include "base/logging.h" +#include "chrome/browser/views/browser_bubble.h" + +void BrowserBubbleHost::WindowMoved() { + // Do safe iteration in case the bubble winds up closing as a result of this + // message. + for (BubbleSet::iterator i = browser_bubbles_.begin(); + i != browser_bubbles_.end();) { + BubbleSet::iterator bubble = i++; + (*bubble)->BrowserWindowMoved(); + } +} + +void BrowserBubbleHost::AttachBrowserBubble(BrowserBubble* bubble) { + DCHECK(browser_bubbles_.find(bubble) == browser_bubbles_.end()) << + "Attempt to register the same BrowserBubble multiple times."; + browser_bubbles_.insert(bubble); +} + +void BrowserBubbleHost::DetachBrowserBubble(BrowserBubble* bubble) { + BubbleSet::iterator it = browser_bubbles_.find(bubble); + DCHECK(it != browser_bubbles_.end()) << + "Attempt to detach an unrecognized BrowserBubble."; + if (it != browser_bubbles_.end()) + browser_bubbles_.erase(it); +} + +void BrowserBubbleHost::Close() { + // BrowserWindowClosing will usually cause the bubble to remove itself from + // the set, so we need to iterate in a way that's safe against deletion. + for (BubbleSet::iterator i = browser_bubbles_.begin(); + i != browser_bubbles_.end();) { + BubbleSet::iterator bubble = i++; + (*bubble)->BrowserWindowClosing(); + } +} + diff --git a/chrome/browser/views/frame/browser_bubble_host.h b/chrome/browser/views/frame/browser_bubble_host.h new file mode 100644 index 0000000..4763a50 --- /dev/null +++ b/chrome/browser/views/frame/browser_bubble_host.h @@ -0,0 +1,42 @@ +// 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. + +#ifndef CHROME_BROWSER_VIEWS_FRAME_BROWSER_BUBBLE_HOST_H_ +#define CHROME_BROWSER_VIEWS_FRAME_BROWSER_BUBBLE_HOST_H_ + +#include <set> + +#include "base/basictypes.h" + +class BrowserBubble; + +// A class providing a hosting environment for BrowserBubble instances. +// Allows for notification to attached BrowserBubbles of browser move, and +// close events. +class BrowserBubbleHost { + public: + BrowserBubbleHost() {} + + // Invoked when the window containing the attached browser-bubbles is moved. + // Calls BrowserBubble::BrowserWindowMoved on all attached bubbles. + void WindowMoved(); + + // To be called when the frame containing the BrowserBubbleHost is closing. + // Calls BrowserBubble::BrowserWindowClosing on all attached bubbles. + void Close(); + + // Registers/Unregisters |bubble| to receive notifications when the host moves + // or is closed. + void AttachBrowserBubble(BrowserBubble* bubble); + void DetachBrowserBubble(BrowserBubble* bubble); + + private: + // The set of bubbles associated with this host. + typedef std::set<BrowserBubble*> BubbleSet; + BubbleSet browser_bubbles_; + + DISALLOW_COPY_AND_ASSIGN(BrowserBubbleHost); +}; + +#endif // CHROME_BROWSER_VIEWS_FRAME_BROWSER_BUBBLE_HOST_H_ diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc index b6a3e17..f3ccddf 100644 --- a/chrome/browser/views/frame/browser_view.cc +++ b/chrome/browser/views/frame/browser_view.cc @@ -486,13 +486,7 @@ void BrowserView::WindowMoved() { status_bubble_->Reposition(); - // Do safe iteration in case the bubble winds up closing as a result of this - // message. - for (BubbleSet::iterator i = browser_bubbles_.begin(); - i != browser_bubbles_.end();) { - BubbleSet::iterator bubble = i++; - (*bubble)->BrowserWindowMoved(); - } + BrowserBubbleHost::WindowMoved(); browser::HideBookmarkBubbleView(); @@ -653,16 +647,6 @@ void BrowserView::RegisterBrowserViewPrefs(PrefService* prefs) { kDefaultHungPluginDetectFrequency); } -void BrowserView::AttachBrowserBubble(BrowserBubble* bubble) { - browser_bubbles_.insert(bubble); -} - -void BrowserView::DetachBrowserBubble(BrowserBubble* bubble) { - BubbleSet::iterator it = browser_bubbles_.find(bubble); - if (it != browser_bubbles_.end()) - browser_bubbles_.erase(it); -} - bool BrowserView::IsPositionInWindowCaption(const gfx::Point& point) { return GetBrowserViewLayout()->IsPositionInWindowCaption(point); } @@ -712,13 +696,7 @@ void BrowserView::SetBounds(const gfx::Rect& bounds) { } void BrowserView::Close() { - // BrowserWindowClosing will usually cause the bubble to remove itself from - // the set, so we need to iterate in a way that's safe against deletion. - for (BubbleSet::iterator i = browser_bubbles_.begin(); - i != browser_bubbles_.end();) { - BubbleSet::iterator bubble = i++; - (*bubble)->BrowserWindowClosing(); - } + BrowserBubbleHost::Close(); frame_->GetWindow()->Close(); } diff --git a/chrome/browser/views/frame/browser_view.h b/chrome/browser/views/frame/browser_view.h index 02fa1e0..7732621 100644 --- a/chrome/browser/views/frame/browser_view.h +++ b/chrome/browser/views/frame/browser_view.h @@ -17,6 +17,7 @@ #include "chrome/browser/browser.h" #include "chrome/browser/browser_window.h" #include "chrome/browser/tabs/tab_strip_model.h" +#include "chrome/browser/views/frame/browser_bubble_host.h" #include "chrome/browser/views/frame/browser_frame.h" #include "chrome/browser/views/infobars/infobar_container.h" #include "chrome/browser/views/tabs/tab_strip.h" @@ -67,7 +68,8 @@ class SingleSplitView; // A ClientView subclass that provides the contents of a browser window, // including the TabStrip, toolbars, download shelves, the content area etc. // -class BrowserView : public BrowserWindow, +class BrowserView : public BrowserBubbleHost, + public BrowserWindow, public BrowserWindowTesting, public NotificationObserver, public TabStripModelObserver, @@ -216,10 +218,6 @@ class BrowserView : public BrowserWindow, // Register preferences specific to this view. static void RegisterBrowserViewPrefs(PrefService* prefs); - // Attach/Detach a BrowserBubble to the browser. - void AttachBrowserBubble(BrowserBubble *bubble); - void DetachBrowserBubble(BrowserBubble *bubble); - // Returns true if the specified point(BrowserView coordinates) is in // in the window caption area of the browser window. bool IsPositionInWindowCaption(const gfx::Point& point); @@ -561,9 +559,6 @@ class BrowserView : public BrowserWindow, // A bottom bar for showing extensions. ExtensionShelf* extension_shelf_; - typedef std::set<BrowserBubble*> BubbleSet; - BubbleSet browser_bubbles_; - // The accessible name of this view. std::wstring accessible_name_; |