Commit 4d617833 authored by jennb@chromium.org's avatar jennb@chromium.org

Separate BrowserWindow from Panel class.

New PanelBrowserWindow class contains the BrowserWindow interface used by the browser to interact with Panels. Panel is now a BaseWindow.

First step of many in the Panel refactor.

BUG=127323
TEST=All existing tests still pass.

Review URL: https://chromiumcodereview.appspot.com/10411036

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@138310 0039d316-1c4b-4281-b951-d872f2087c98
parent a85197ef
...@@ -3365,7 +3365,7 @@ BrowserWindow* Browser::CreateBrowserWindow() { ...@@ -3365,7 +3365,7 @@ BrowserWindow* Browser::CreateBrowserWindow() {
create_panel = is_type_panel(); create_panel = is_type_panel();
#endif #endif
if (create_panel) if (create_panel)
return PanelManager::GetInstance()->CreatePanel(this); return PanelManager::GetInstance()->CreatePanel(this)->browser_window();
return BrowserWindow::CreateBrowserWindow(this); return BrowserWindow::CreateBrowserWindow(this);
} }
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/panels/native_panel.h" #include "chrome/browser/ui/panels/native_panel.h"
#include "chrome/browser/ui/panels/panel_browser_window.h"
#include "chrome/browser/ui/panels/panel_manager.h" #include "chrome/browser/ui/panels/panel_manager.h"
#include "chrome/browser/ui/panels/panel_mouse_watcher.h" #include "chrome/browser/ui/panels/panel_mouse_watcher.h"
#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
...@@ -338,7 +339,9 @@ Panel* BasePanelBrowserTest::CreatePanelWithParams( ...@@ -338,7 +339,9 @@ Panel* BasePanelBrowserTest::CreatePanelWithParams(
observer.Wait(); observer.Wait();
} }
Panel* panel = static_cast<Panel*>(panel_browser->window()); PanelBrowserWindow* panel_browser_window =
static_cast<PanelBrowserWindow*>(panel_browser->window());
Panel* panel = panel_browser_window->panel();
if (!PanelManager::GetInstance()->auto_sizing_enabled() || if (!PanelManager::GetInstance()->auto_sizing_enabled() ||
params.bounds.width() || params.bounds.height()) { params.bounds.width() || params.bounds.height()) {
......
...@@ -9,10 +9,12 @@ ...@@ -9,10 +9,12 @@
#include "chrome/browser/ui/panels/panel.h" #include "chrome/browser/ui/panels/panel.h"
#include "ui/gfx/native_widget_types.h" #include "ui/gfx/native_widget_types.h"
class Browser;
class FindBar; class FindBar;
class NativePanelTesting; class NativePanelTesting;
namespace content { namespace content {
struct NativeWebKeyboardEvent;
class WebContents; class WebContents;
} }
...@@ -32,6 +34,7 @@ class Rect; ...@@ -32,6 +34,7 @@ class Rect;
// use Panel in all the method names to avoid collisions. // use Panel in all the method names to avoid collisions.
class NativePanel { class NativePanel {
friend class Panel; friend class Panel;
friend class PanelBrowserWindow;
friend class PanelBrowserTest; friend class PanelBrowserTest;
protected: protected:
......
This diff is collapsed.
This diff is collapsed.
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "base/command_line.h" #include "base/command_line.h"
#include "base/logging.h" #include "base/logging.h"
#include "chrome/browser/native_window_notification_source.h" #include "chrome/browser/native_window_notification_source.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/panels/display_settings_provider.h" #include "chrome/browser/ui/panels/display_settings_provider.h"
#include "chrome/browser/ui/panels/panel.h" #include "chrome/browser/ui/panels/panel.h"
#include "chrome/browser/ui/panels/panel_bounds_animation.h" #include "chrome/browser/ui/panels/panel_bounds_animation.h"
...@@ -15,6 +16,7 @@ ...@@ -15,6 +16,7 @@
#include "chrome/browser/ui/panels/panel_strip.h" #include "chrome/browser/ui/panels/panel_strip.h"
#include "chrome/browser/ui/views/frame/browser_frame.h" #include "chrome/browser/ui/views/frame/browser_frame.h"
#include "chrome/common/chrome_notification_types.h" #include "chrome/common/chrome_notification_types.h"
#include "content/public/browser/native_web_keyboard_event.h"
#include "content/public/browser/notification_service.h" #include "content/public/browser/notification_service.h"
#include "grit/chromium_strings.h" #include "grit/chromium_strings.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
......
This diff is collapsed.
// Copyright (c) 2012 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_UI_PANELS_PANEL_BROWSER_WINDOW_H_
#define CHROME_BROWSER_UI_PANELS_PANEL_BROWSER_WINDOW_H_
#pragma once
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/tabs/tab_strip_model_observer.h"
namespace extensions {
class Extension;
}
class NativePanel;
class Panel;
// A platform independent implementation of BrowserWindow for Panels. This
// class gets the first crack at all the BrowserWindow calls for Panels and
// do one or more of the following:
// - Do nothing. The function is not relevant to Panels.
// - Throw an exception. The function shouldn't be called for Panels.
// - Instruct Panel to do panel-specific platform independent processing
// and then invoke the function on the platform specific BrowserWindow member.
// - Invoke the function on the platform specific BrowserWindow member direclty.
class PanelBrowserWindow : public BrowserWindow,
public TabStripModelObserver {
public:
PanelBrowserWindow(Browser* browser, Panel* panel, NativePanel* native_panel);
virtual ~PanelBrowserWindow();
// BaseWindow overrides.
virtual bool IsActive() const OVERRIDE;
virtual bool IsMaximized() const OVERRIDE;
virtual bool IsMinimized() const OVERRIDE;
virtual bool IsFullscreen() const OVERRIDE;
virtual gfx::Rect GetRestoredBounds() const OVERRIDE;
virtual gfx::Rect GetBounds() const OVERRIDE;
virtual void Show() OVERRIDE;
virtual void ShowInactive() OVERRIDE;
virtual void Close() OVERRIDE;
virtual void Activate() OVERRIDE;
virtual void Deactivate() OVERRIDE;
virtual void Maximize() OVERRIDE;
virtual void Minimize() OVERRIDE;
virtual void Restore() OVERRIDE;
virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE;
virtual void SetDraggableRegion(SkRegion* region) OVERRIDE;
virtual void FlashFrame(bool flash) OVERRIDE;
virtual bool IsAlwaysOnTop() const OVERRIDE;
// BrowserWindow overrides.
virtual gfx::NativeWindow GetNativeHandle() OVERRIDE;
virtual BrowserWindowTesting* GetBrowserWindowTesting() OVERRIDE;
virtual StatusBubble* GetStatusBubble() OVERRIDE;
virtual void ToolbarSizeChanged(bool is_animating) OVERRIDE;
virtual void UpdateTitleBar() OVERRIDE;
virtual void BookmarkBarStateChanged(
BookmarkBar::AnimateChangeType change_type) OVERRIDE;
virtual void UpdateDevTools() OVERRIDE;
virtual void SetDevToolsDockSide(DevToolsDockSide side) OVERRIDE;
virtual void UpdateLoadingAnimations(bool should_animate) OVERRIDE;
virtual void SetStarredState(bool is_starred) OVERRIDE;
virtual void EnterFullscreen(
const GURL& url, FullscreenExitBubbleType type) OVERRIDE;
virtual void ExitFullscreen() OVERRIDE;
virtual void UpdateFullscreenExitBubbleContent(
const GURL& url,
FullscreenExitBubbleType bubble_type) OVERRIDE;
virtual bool IsFullscreenBubbleVisible() const OVERRIDE;
virtual LocationBar* GetLocationBar() const OVERRIDE;
virtual void SetFocusToLocationBar(bool select_all) OVERRIDE;
virtual void UpdateReloadStopState(bool is_loading, bool force) OVERRIDE;
virtual void UpdateToolbar(TabContentsWrapper* contents,
bool should_restore_state) OVERRIDE;
virtual void FocusToolbar() OVERRIDE;
virtual void FocusAppMenu() OVERRIDE;
virtual void FocusBookmarksToolbar() OVERRIDE;
virtual void RotatePaneFocus(bool forwards) OVERRIDE;
virtual bool IsBookmarkBarVisible() const OVERRIDE;
virtual bool IsBookmarkBarAnimating() const OVERRIDE;
virtual bool IsTabStripEditable() const OVERRIDE;
virtual bool IsToolbarVisible() const OVERRIDE;
virtual gfx::Rect GetRootWindowResizerRect() const OVERRIDE;
virtual bool IsPanel() const OVERRIDE;
virtual void DisableInactiveFrame() OVERRIDE;
virtual void ConfirmAddSearchProvider(TemplateURL* template_url,
Profile* profile) OVERRIDE;
virtual void ToggleBookmarkBar() OVERRIDE;
virtual void ShowAboutChromeDialog() OVERRIDE;
virtual void ShowUpdateChromeDialog() OVERRIDE;
virtual void ShowTaskManager() OVERRIDE;
virtual void ShowBackgroundPages() OVERRIDE;
virtual void ShowBookmarkBubble(
const GURL& url, bool already_bookmarked) OVERRIDE;
virtual void ShowChromeToMobileBubble() OVERRIDE;
#if defined(ENABLE_ONE_CLICK_SIGNIN)
virtual void ShowOneClickSigninBubble(
const base::Closure& learn_more_callback,
const base::Closure& advanced_callback) OVERRIDE;
#endif
virtual bool IsDownloadShelfVisible() const OVERRIDE;
virtual DownloadShelf* GetDownloadShelf() OVERRIDE;
virtual void ConfirmBrowserCloseWithPendingDownloads() OVERRIDE;
virtual void UserChangedTheme() OVERRIDE;
virtual int GetExtraRenderViewHeight() const OVERRIDE;
virtual void WebContentsFocused(content::WebContents* contents) OVERRIDE;
virtual void ShowPageInfo(Profile* profile,
const GURL& url,
const content::SSLStatus& ssl,
bool show_history) OVERRIDE;
virtual void ShowWebsiteSettings(Profile* profile,
TabContentsWrapper* tab_contents_wrapper,
const GURL& url,
const content::SSLStatus& ssl,
bool show_history) OVERRIDE;
virtual void ShowAppMenu() OVERRIDE;
virtual bool PreHandleKeyboardEvent(
const content::NativeWebKeyboardEvent& event,
bool* is_keyboard_shortcut) OVERRIDE;
virtual void HandleKeyboardEvent(
const content::NativeWebKeyboardEvent& event) OVERRIDE;
virtual void ShowCreateWebAppShortcutsDialog(
TabContentsWrapper* tab_contents) OVERRIDE;
virtual void ShowCreateChromeAppShortcutsDialog(
Profile* profile, const extensions::Extension* app) OVERRIDE;
virtual void Cut() OVERRIDE;
virtual void Copy() OVERRIDE;
virtual void Paste() OVERRIDE;
#if defined(OS_MACOSX)
virtual void OpenTabpose() OVERRIDE;
virtual void EnterPresentationMode(
const GURL& url,
FullscreenExitBubbleType bubble_type) OVERRIDE;
virtual void ExitPresentationMode() OVERRIDE;
virtual bool InPresentationMode() OVERRIDE;
#endif
virtual void ShowInstant(TabContentsWrapper* preview) OVERRIDE;
virtual void HideInstant() OVERRIDE;
virtual gfx::Rect GetInstantBounds() OVERRIDE;
virtual WindowOpenDisposition GetDispositionForPopupBounds(
const gfx::Rect& bounds) OVERRIDE;
virtual FindBar* CreateFindBar() OVERRIDE;
virtual void ResizeDueToAutoResize(content::WebContents* web_contents,
const gfx::Size& new_size) OVERRIDE;
virtual void ShowAvatarBubble(content::WebContents* web_contents,
const gfx::Rect& rect) OVERRIDE;
virtual void ShowAvatarBubbleFromAvatarButton() OVERRIDE;
// TabStripModelObserver overrides.
virtual void TabInsertedAt(TabContentsWrapper* contents,
int index,
bool foreground) OVERRIDE;
protected:
virtual void DestroyBrowser() OVERRIDE;
private:
friend class BasePanelBrowserTest;
friend class PanelBrowserWindowCocoaTest;
Panel* panel() const { return panel_; } // only for tests
Browser* browser_; // Weak, owned by native panel.
Panel* panel_; // Weak pointer. Owns us.
// Platform specifc implementation for panels. It'd be one of
// PanelBrowserWindowGtk/PanelBrowserView/PanelBrowserWindowCocoa.
NativePanel* native_panel_; // Weak, owns us (through ownership of Panel).
DISALLOW_COPY_AND_ASSIGN(PanelBrowserWindow);
};
#endif // CHROME_BROWSER_UI_PANELS_PANEL_BROWSER_WINDOW_H_
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "chrome/browser/ui/cocoa/cocoa_profile_test.h" #include "chrome/browser/ui/cocoa/cocoa_profile_test.h"
#import "chrome/browser/ui/cocoa/run_loop_testing.h" #import "chrome/browser/ui/cocoa/run_loop_testing.h"
#include "chrome/browser/ui/panels/panel.h" #include "chrome/browser/ui/panels/panel.h"
#include "chrome/browser/ui/panels/panel_browser_window.h"
#include "chrome/browser/ui/panels/panel_manager.h" #include "chrome/browser/ui/panels/panel_manager.h"
#import "chrome/browser/ui/panels/panel_titlebar_view_cocoa.h" #import "chrome/browser/ui/panels/panel_titlebar_view_cocoa.h"
#import "chrome/browser/ui/panels/panel_window_controller_cocoa.h" #import "chrome/browser/ui/panels/panel_window_controller_cocoa.h"
...@@ -59,7 +60,9 @@ class PanelBrowserWindowCocoaTest : public CocoaProfileTest { ...@@ -59,7 +60,9 @@ class PanelBrowserWindowCocoaTest : public CocoaProfileTest {
Browser::TYPE_PANEL, panel_name, gfx::Rect(), profile())); Browser::TYPE_PANEL, panel_name, gfx::Rect(), profile()));
EXPECT_EQ(panels_count + 1, manager->num_panels()); EXPECT_EQ(panels_count + 1, manager->num_panels());
Panel* panel = static_cast<Panel*>(panel_browser->window()); PanelBrowserWindow* panel_browser_window =
static_cast<PanelBrowserWindow*>(panel_browser->window());
Panel* panel = panel_browser_window->panel();
EXPECT_TRUE(panel); EXPECT_TRUE(panel);
EXPECT_TRUE(panel->native_panel()); // Native panel is created right away. EXPECT_TRUE(panel->native_panel()); // Native panel is created right away.
PanelBrowserWindowCocoa* native_window = PanelBrowserWindowCocoa* native_window =
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "base/bind.h" #include "base/bind.h"
#include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_list.h" #include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/gtk/browser_titlebar.h" #include "chrome/browser/ui/gtk/browser_titlebar.h"
#include "chrome/browser/ui/gtk/custom_button.h" #include "chrome/browser/ui/gtk/custom_button.h"
#include "chrome/browser/ui/gtk/gtk_theme_service.h" #include "chrome/browser/ui/gtk/gtk_theme_service.h"
...@@ -18,6 +19,7 @@ ...@@ -18,6 +19,7 @@
#include "chrome/browser/ui/panels/panel_manager.h" #include "chrome/browser/ui/panels/panel_manager.h"
#include "chrome/browser/ui/panels/panel_strip.h" #include "chrome/browser/ui/panels/panel_strip.h"
#include "chrome/common/chrome_notification_types.h" #include "chrome/common/chrome_notification_types.h"
#include "content/public/browser/native_web_keyboard_event.h"
#include "content/public/browser/notification_service.h" #include "content/public/browser/notification_service.h"
#include "grit/theme_resources_standard.h" #include "grit/theme_resources_standard.h"
#include "grit/ui_resources.h" #include "grit/ui_resources.h"
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "base/message_loop.h" #include "base/message_loop.h"
#include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_list.h" #include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/panels/detached_panel_strip.h" #include "chrome/browser/ui/panels/detached_panel_strip.h"
#include "chrome/browser/ui/panels/docked_panel_strip.h" #include "chrome/browser/ui/panels/docked_panel_strip.h"
#include "chrome/browser/ui/panels/panel_drag_controller.h" #include "chrome/browser/ui/panels/panel_drag_controller.h"
...@@ -216,12 +217,6 @@ void PanelManager::OnPanelExpansionStateChanged(Panel* panel) { ...@@ -216,12 +217,6 @@ void PanelManager::OnPanelExpansionStateChanged(Panel* panel) {
} }
void PanelManager::OnWindowAutoResized(Panel* panel,
const gfx::Size& preferred_window_size) {
DCHECK(auto_sizing_enabled_);
panel->panel_strip()->ResizePanelWindow(panel, preferred_window_size);
}
void PanelManager::ResizePanel(Panel* panel, const gfx::Size& new_size) { void PanelManager::ResizePanel(Panel* panel, const gfx::Size& new_size) {
PanelStrip* panel_strip = panel->panel_strip(); PanelStrip* panel_strip = panel->panel_strip();
if (!panel_strip) if (!panel_strip)
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include "ui/gfx/rect.h" #include "ui/gfx/rect.h"
class Browser; class Browser;
class BrowserWindow;
class DetachedPanelStrip; class DetachedPanelStrip;
class DockedPanelStrip; class DockedPanelStrip;
class PanelDragController; class PanelDragController;
...@@ -64,13 +65,8 @@ class PanelManager : public DisplaySettingsProvider::DisplayAreaObserver, ...@@ -64,13 +65,8 @@ class PanelManager : public DisplaySettingsProvider::DisplayAreaObserver,
// Resizes the panel and sets the origin. // Resizes the panel and sets the origin.
void OnPanelResizedByMouse(Panel* panel, const gfx::Rect& new_bounds); void OnPanelResizedByMouse(Panel* panel, const gfx::Rect& new_bounds);
// Invoked when the preferred window size of the given panel might need to // Resizes the panel. Explicitly setting the panel size will disable
// get changed. // auto-size for the panel.
void OnWindowAutoResized(Panel* panel,
const gfx::Size& preferred_window_size);
// Resizes the panel. Explicitly setting the panel size is not allowed
// for panels that are auto-sized.
void ResizePanel(Panel* panel, const gfx::Size& new_size); void ResizePanel(Panel* panel, const gfx::Size& new_size);
// Invoked when a panel's expansion state changes. // Invoked when a panel's expansion state changes.
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "chrome/browser/themes/theme_service_factory.h" #include "chrome/browser/themes/theme_service_factory.h"
#include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_list.h" #include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_window.h"
#import "chrome/browser/ui/cocoa/browser_window_utils.h" #import "chrome/browser/ui/cocoa/browser_window_utils.h"
#import "chrome/browser/ui/cocoa/event_utils.h" #import "chrome/browser/ui/cocoa/event_utils.h"
#import "chrome/browser/ui/cocoa/find_bar/find_bar_bridge.h" #import "chrome/browser/ui/cocoa/find_bar/find_bar_bridge.h"
......
...@@ -3113,6 +3113,8 @@ ...@@ -3113,6 +3113,8 @@
'browser/ui/panels/panel_browser_view.h', 'browser/ui/panels/panel_browser_view.h',
'browser/ui/panels/panel_browser_titlebar_gtk.cc', 'browser/ui/panels/panel_browser_titlebar_gtk.cc',
'browser/ui/panels/panel_browser_titlebar_gtk.h', 'browser/ui/panels/panel_browser_titlebar_gtk.h',
'browser/ui/panels/panel_browser_window.cc',
'browser/ui/panels/panel_browser_window.h',
'browser/ui/panels/panel_browser_window_cocoa.h', 'browser/ui/panels/panel_browser_window_cocoa.h',
'browser/ui/panels/panel_browser_window_cocoa.mm', 'browser/ui/panels/panel_browser_window_cocoa.mm',
'browser/ui/panels/panel_browser_window_gtk.cc', 'browser/ui/panels/panel_browser_window_gtk.cc',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment