Index: chrome/browser/ui/panels/panel.cc |
diff --git a/chrome/browser/ui/panels/panel.cc b/chrome/browser/ui/panels/panel.cc |
index f9a8db80eb4ed1953ea9771d38643d5230074f88..18dcd26947bfca5cef757618fd3475a6aca688f2 100644 |
--- a/chrome/browser/ui/panels/panel.cc |
+++ b/chrome/browser/ui/panels/panel.cc |
@@ -8,13 +8,10 @@ |
#include "base/message_loop.h" |
#include "chrome/browser/profiles/profile.h" |
#include "chrome/browser/ui/browser.h" |
-#include "chrome/browser/ui/browser_finder.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_strip.h" |
-#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
-#include "chrome/browser/ui/tabs/tab_strip_model.h" |
-#include "chrome/browser/ui/window_sizer.h" |
#include "chrome/common/chrome_notification_types.h" |
#include "content/public/browser/notification_service.h" |
#include "content/public/browser/notification_source.h" |
@@ -23,13 +20,7 @@ |
#include "content/public/browser/web_contents.h" |
#include "ui/gfx/rect.h" |
-#if defined(USE_AURA) |
-#include "chrome/browser/ui/panels/panel_browser_view.h" |
-#endif |
- |
-using content::NativeWebKeyboardEvent; |
using content::RenderViewHost; |
-using content::SSLStatus; |
using content::WebContents; |
Panel::Panel(Browser* browser, const gfx::Size& requested_size) |
@@ -55,13 +46,13 @@ void Panel::Initialize(const gfx::Rect& bounds) { |
DCHECK(!bounds.IsEmpty()); |
initialized_ = true; |
native_panel_ = CreateNativePanel(browser_, this, bounds); |
+ panel_browser_window_.reset( |
+ new PanelBrowserWindow(browser_, this, native_panel_)); |
if (panel_strip_ != NULL) |
native_panel_->PreventActivationByOS(panel_strip_->IsPanelMinimized(this)); |
} |
void Panel::OnNativePanelClosed() { |
- if (auto_resizable_) |
- native_panel_->GetPanelBrowser()->tab_strip_model()->RemoveObserver(this); |
manager()->OnPanelClosed(this); |
DCHECK(!panel_strip_); |
} |
@@ -70,6 +61,10 @@ PanelManager* Panel::manager() const { |
return PanelManager::GetInstance(); |
} |
+BrowserWindow* Panel::browser_window() const { |
+ return panel_browser_window_.get(); |
+} |
+ |
bool Panel::CanMinimize() const { |
return panel_strip_ && panel_strip_->CanMinimizePanel(this) && !IsMinimized(); |
} |
@@ -131,11 +126,9 @@ void Panel::SetAutoResizable(bool resizable) { |
auto_resizable_ = resizable; |
WebContents* web_contents = browser()->GetSelectedWebContents(); |
if (auto_resizable_) { |
- browser()->tab_strip_model()->AddObserver(this); |
if (web_contents) |
EnableWebContentsAutoResize(web_contents); |
} else { |
- browser()->tab_strip_model()->RemoveObserver(this); |
registrar_.RemoveAll(); |
if (web_contents) { |
@@ -276,6 +269,9 @@ bool Panel::IsActive() const { |
return native_panel_->IsPanelActive(); |
} |
+void Panel::SetDraggableRegion(SkRegion* region) { |
+} |
+ |
void Panel::FlashFrame(bool draw_attention) { |
if (IsDrawingAttention() == draw_attention || !panel_strip_) |
return; |
@@ -295,50 +291,6 @@ bool Panel::IsAlwaysOnTop() const { |
return always_on_top_; |
} |
-gfx::NativeWindow Panel::GetNativeHandle() { |
- return native_panel_->GetNativePanelHandle(); |
-} |
- |
-BrowserWindowTesting* Panel::GetBrowserWindowTesting() { |
- NOTIMPLEMENTED(); |
- return NULL; |
-} |
- |
-StatusBubble* Panel::GetStatusBubble() { |
- // TODO(jennb): Implement. http://crbug.com/102723 |
- return NULL; |
-} |
- |
-void Panel::ToolbarSizeChanged(bool is_animating){ |
- NOTIMPLEMENTED(); |
-} |
- |
-void Panel::UpdateTitleBar() { |
- native_panel_->UpdatePanelTitleBar(); |
-} |
- |
-void Panel::BookmarkBarStateChanged( |
- BookmarkBar::AnimateChangeType change_type) { |
- NOTIMPLEMENTED(); |
-} |
- |
-void Panel::UpdateDevTools() { |
- NOTIMPLEMENTED(); |
-} |
- |
-void Panel::SetDevToolsDockSide(DevToolsDockSide side) { |
- NOTIMPLEMENTED(); |
-} |
- |
-void Panel::UpdateLoadingAnimations(bool should_animate) { |
- native_panel_->UpdatePanelLoadingAnimations(should_animate); |
-} |
- |
-void Panel::SetStarredState(bool is_starred) { |
- // Since panels are typically not bookmarked extension UI windows, they don't |
- // have starred state. |
-} |
- |
gfx::Rect Panel::GetRestoredBounds() const { |
gfx::Rect bounds = native_panel_->GetPanelBounds(); |
bounds.set_y(bounds.bottom() - full_size_.height()); |
@@ -382,316 +334,14 @@ void Panel::Restore() { |
panel_strip_->RestorePanel(this); |
} |
-void Panel::EnterFullscreen( |
- const GURL& url, FullscreenExitBubbleType type) { |
- NOTIMPLEMENTED(); |
-} |
- |
-void Panel::ExitFullscreen() { |
- NOTIMPLEMENTED(); |
-} |
- |
-void Panel::UpdateFullscreenExitBubbleContent( |
- const GURL& url, |
- FullscreenExitBubbleType bubble_type) { |
- NOTIMPLEMENTED(); |
-} |
- |
bool Panel::IsFullscreen() const { |
return false; |
} |
-bool Panel::IsFullscreenBubbleVisible() const { |
- NOTIMPLEMENTED(); |
- return false; |
-} |
- |
-LocationBar* Panel::GetLocationBar() const { |
-#if defined(USE_AURA) |
- // TODO(stevenjb): Remove this when Aura panels are implemented post R18. |
- PanelBrowserView* panel_view = static_cast<PanelBrowserView*>(native_panel_); |
- return panel_view->GetLocationBar(); |
-#else |
- // Panels do not have a location bar. |
- return NULL; |
-#endif |
-} |
- |
-void Panel::SetFocusToLocationBar(bool select_all) { |
-#if defined(USE_AURA) |
- // TODO(stevenjb): Remove this when Aura panels are implemented post R18. |
- PanelBrowserView* panel_view = static_cast<PanelBrowserView*>(native_panel_); |
- panel_view->SetFocusToLocationBar(select_all); |
-#else |
- // Panels do not have a location bar. |
-#endif |
-} |
- |
-void Panel::UpdateReloadStopState(bool is_loading, bool force) { |
- // Panels don't have stop/reload indicator. |
-} |
- |
-void Panel::UpdateToolbar(TabContentsWrapper* contents, |
- bool should_restore_state) { |
- // Panels do not have a toolbar. |
-} |
- |
-void Panel::FocusToolbar() { |
- // Panels do not have a toolbar. |
-} |
- |
-void Panel::FocusAppMenu() { |
- NOTIMPLEMENTED(); |
-} |
- |
-void Panel::FocusBookmarksToolbar() { |
- NOTIMPLEMENTED(); |
-} |
- |
-void Panel::RotatePaneFocus(bool forwards) { |
- NOTIMPLEMENTED(); |
-} |
- |
-bool Panel::IsBookmarkBarVisible() const { |
- return false; |
-} |
- |
-bool Panel::IsBookmarkBarAnimating() const { |
- return false; |
-} |
- |
-// This is used by extensions to decide if a window can be closed. |
-// Always return true as panels do not have tabs that can be dragged, |
-// during which extensions will avoid closing a window. |
-bool Panel::IsTabStripEditable() const { |
- return true; |
-} |
- |
-bool Panel::IsToolbarVisible() const { |
- NOTIMPLEMENTED(); |
- return false; |
-} |
- |
-gfx::Rect Panel::GetRootWindowResizerRect() const { |
- return gfx::Rect(); |
-} |
- |
-bool Panel::IsPanel() const { |
- return true; |
-} |
- |
-void Panel::DisableInactiveFrame() { |
- NOTIMPLEMENTED(); |
-} |
- |
-void Panel::ConfirmAddSearchProvider(TemplateURL* template_url, |
- Profile* profile) { |
- NOTIMPLEMENTED(); |
-} |
- |
-void Panel::ToggleBookmarkBar() { |
- NOTIMPLEMENTED(); |
-} |
- |
-void Panel::ShowAboutChromeDialog() { |
- NOTIMPLEMENTED(); |
-} |
- |
-void Panel::ShowUpdateChromeDialog() { |
- NOTIMPLEMENTED(); |
-} |
- |
-void Panel::ShowTaskManager() { |
- native_panel_->ShowTaskManagerForPanel(); |
-} |
- |
-void Panel::ShowBackgroundPages() { |
- NOTIMPLEMENTED(); |
-} |
- |
-void Panel::ShowBookmarkBubble(const GURL& url, bool already_bookmarked) { |
- NOTIMPLEMENTED(); |
-} |
- |
-void Panel::ShowChromeToMobileBubble() { |
- NOTIMPLEMENTED(); |
-} |
- |
-#if defined(ENABLE_ONE_CLICK_SIGNIN) |
-void Panel::ShowOneClickSigninBubble( |
- const base::Closure& learn_more_callback, |
- const base::Closure& advanced_callback) { |
- NOTIMPLEMENTED(); |
-} |
-#endif |
- |
-bool Panel::IsDownloadShelfVisible() const { |
- return false; |
-} |
- |
-DownloadShelf* Panel::GetDownloadShelf() { |
- Browser* panel_browser = native_panel_->GetPanelBrowser(); |
- Profile* profile = panel_browser->profile(); |
- Browser* tabbed_browser = browser::FindTabbedBrowser(profile, true); |
- |
- if (!tabbed_browser) { |
- // Set initial bounds so window will not be positioned at an offset |
- // to this panel as panels are at the bottom of the screen. |
- gfx::Rect window_bounds; |
- WindowSizer::GetBrowserWindowBounds(std::string(), gfx::Rect(), |
- panel_browser, &window_bounds); |
- Browser::CreateParams params(Browser::TYPE_TABBED, profile); |
- params.initial_bounds = window_bounds; |
- tabbed_browser = Browser::CreateWithParams(params); |
- tabbed_browser->NewTab(); |
- } |
- |
- tabbed_browser->window()->Show(); // Ensure download shelf is visible. |
- return tabbed_browser->window()->GetDownloadShelf(); |
-} |
- |
-void Panel::ConfirmBrowserCloseWithPendingDownloads() { |
- NOTIMPLEMENTED(); |
-} |
- |
-void Panel::UserChangedTheme() { |
- native_panel_->NotifyPanelOnUserChangedTheme(); |
-} |
- |
-int Panel::GetExtraRenderViewHeight() const { |
- // This is currently used only on Linux and that returns the height for |
- // optional elements like bookmark bar, download bar etc. Not applicable to |
- // panels. |
- return 0; |
-} |
- |
-void Panel::WebContentsFocused(WebContents* contents) { |
- native_panel_->PanelWebContentsFocused(contents); |
-} |
- |
-void Panel::ShowPageInfo(Profile* profile, |
- const GURL& url, |
- const SSLStatus& ssl, |
- bool show_history) { |
- NOTIMPLEMENTED(); |
-} |
-void Panel::ShowWebsiteSettings(Profile* profile, |
- TabContentsWrapper* tab_contents_wrapper, |
- const GURL& url, |
- const content::SSLStatus& ssl, |
- bool show_history) { |
- NOTIMPLEMENTED(); |
-} |
- |
-void Panel::ShowAppMenu() { |
- NOTIMPLEMENTED(); |
-} |
- |
-bool Panel::PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event, |
- bool* is_keyboard_shortcut) { |
- return native_panel_->PreHandlePanelKeyboardEvent(event, |
- is_keyboard_shortcut); |
-} |
- |
-void Panel::HandleKeyboardEvent(const NativeWebKeyboardEvent& event) { |
- native_panel_->HandlePanelKeyboardEvent(event); |
-} |
- |
-void Panel::ShowCreateWebAppShortcutsDialog(TabContentsWrapper* tab_contents) { |
- NOTIMPLEMENTED(); |
-} |
- |
-void Panel::ShowCreateChromeAppShortcutsDialog(Profile* profile, |
- const extensions::Extension* app) { |
- NOTIMPLEMENTED(); |
-} |
- |
-void Panel::Cut() { |
- native_panel_->PanelCut(); |
-} |
- |
-void Panel::Copy() { |
- native_panel_->PanelCopy(); |
-} |
- |
-void Panel::Paste() { |
- native_panel_->PanelPaste(); |
-} |
- |
-#if defined(OS_MACOSX) |
-void Panel::OpenTabpose() { |
- NOTIMPLEMENTED(); |
-} |
- |
-void Panel::EnterPresentationMode( |
- const GURL& url, |
- FullscreenExitBubbleType content_type) { |
- NOTIMPLEMENTED(); |
-} |
- |
-void Panel::ExitPresentationMode() { |
- NOTIMPLEMENTED(); |
-} |
- |
-bool Panel::InPresentationMode() { |
- NOTIMPLEMENTED(); |
- return false; |
-} |
-#endif |
- |
-void Panel::ShowInstant(TabContentsWrapper* preview) { |
- NOTIMPLEMENTED(); |
-} |
- |
-void Panel::HideInstant() { |
- NOTIMPLEMENTED(); |
-} |
- |
-gfx::Rect Panel::GetInstantBounds() { |
- NOTIMPLEMENTED(); |
- return gfx::Rect(); |
-} |
- |
-WindowOpenDisposition Panel::GetDispositionForPopupBounds( |
- const gfx::Rect& bounds) { |
-#if defined(USE_AURA) |
- // TODO(stevenjb): Remove this when Aura panels are implemented post R18. |
- PanelBrowserView* panel_view = static_cast<PanelBrowserView*>(native_panel_); |
- return panel_view->GetDispositionForPopupBounds(bounds); |
-#else |
- return NEW_POPUP; |
-#endif |
-} |
- |
-FindBar* Panel::CreateFindBar() { |
- return native_panel_->CreatePanelFindBar(); |
-} |
- |
-void Panel::ResizeDueToAutoResize(WebContents* web_contents, |
- const gfx::Size& pref_size) { |
+void Panel::OnWindowAutoResized(const gfx::Size& preferred_window_size) { |
DCHECK(auto_resizable_); |
- return manager()->OnWindowAutoResized( |
- this, |
- native_panel_->WindowSizeFromContentSize(pref_size)); |
-} |
- |
-void Panel::ShowAvatarBubble(WebContents* web_contents, const gfx::Rect& rect) { |
- // Panels will never show a new tab page so this should never be called. |
- NOTREACHED(); |
-} |
- |
-void Panel::ShowAvatarBubbleFromAvatarButton() { |
- // Panels will never show an avatar button so this should never be called. |
- NOTREACHED(); |
-} |
- |
-void Panel::TabInsertedAt(TabContentsWrapper* contents, |
- int index, |
- bool foreground) { |
- if (auto_resizable_) { |
- DCHECK_EQ(0, index); |
- EnableWebContentsAutoResize(contents->web_contents()); |
- } |
+ if (panel_strip_) |
+ panel_strip_->ResizePanelWindow(this, preferred_window_size); |
} |
void Panel::EnableWebContentsAutoResize(WebContents* web_contents) { |
@@ -792,6 +442,3 @@ void Panel::OnPanelEndUserResizing() { |
SetPreviewMode(false); |
} |
-void Panel::DestroyBrowser() { |
- native_panel_->DestroyPanelBrowser(); |
-} |