Index: chrome/browser/ui/panels/panel.cc |
=================================================================== |
--- chrome/browser/ui/panels/panel.cc (revision 94932) |
+++ chrome/browser/ui/panels/panel.cc (working copy) |
@@ -8,12 +8,16 @@ |
#include "chrome/browser/extensions/extension_prefs.h" |
#include "chrome/browser/extensions/extension_service.h" |
#include "chrome/browser/profiles/profile.h" |
+#include "content/browser/renderer_host/render_view_host.h" |
#include "chrome/browser/ui/browser.h" |
#include "chrome/browser/ui/panels/native_panel.h" |
#include "chrome/browser/ui/panels/panel_manager.h" |
#include "chrome/browser/ui/window_sizer.h" |
#include "chrome/browser/web_applications/web_app.h" |
#include "chrome/common/extensions/extension.h" |
+#include "content/browser/tab_contents/tab_contents.h" |
+#include "content/common/content_notification_types.h" |
+#include "content/common/view_messages.h" |
#include "ui/gfx/rect.h" |
// static |
@@ -27,9 +31,15 @@ |
} |
Panel::Panel(Browser* browser, const gfx::Rect& bounds) |
- : native_panel_(NULL), |
+ : initial_size_(bounds.size()), |
+ max_size_(bounds.size()), |
+ native_panel_(NULL), |
expansion_state_(EXPANDED) { |
native_panel_ = CreateNativePanel(browser, this, bounds); |
+ |
+ registrar_.Add(this, |
+ content::NOTIFICATION_TAB_ADDED, |
+ Source<TabContentsDelegate>(browser)); |
} |
Panel::~Panel() { |
@@ -40,10 +50,37 @@ |
return PanelManager::GetInstance(); |
} |
+void Panel::SetRestoredBounds(const gfx::Rect& bounds) { |
+ native_panel_->SetPanelRestoredBounds(bounds); |
+} |
+ |
void Panel::SetPanelBounds(const gfx::Rect& bounds) { |
native_panel_->SetPanelBounds(bounds); |
} |
+void Panel::SetMaximumSize(const gfx::Size& max_size) { |
+ if (max_size_ == max_size) |
+ return; |
+ max_size_ = max_size; |
+ |
+ // Tell the renderer not to show the scroll bar till |max_size_| since the |
+ // panel can grow to |max_size_|. |
+ // Note: It might be possible that the tab is not created yet. If so, we will |
+ // send the message when NOTIFICATION_TAB_ADDED is received. |
+ TabContents* tab_contents = browser()->GetSelectedTabContents(); |
+ if (!tab_contents) |
+ return; |
+ RenderViewHost* render_view_host = tab_contents->render_view_host(); |
+ if (!render_view_host) |
+ return; |
+ |
+ gfx::Size non_client_size = GetNonClientAreaSize(); |
+ render_view_host->Send(new ViewMsg_DisableScrollbarsForSmallWindows( |
Dmitry Titov
2011/08/05 19:02:20
here you subtract non_client and in the notificati
jianli
2011/08/09 19:56:16
Done.
|
+ render_view_host->routing_id(), |
+ gfx::Size(max_size_.width() - non_client_size.width(), |
+ max_size_.height() - non_client_size.height()))); |
+} |
+ |
void Panel::SetExpansionState(ExpansionState new_expansion_state) { |
if (expansion_state_ == new_expansion_state) |
return; |
@@ -70,6 +107,10 @@ |
return native_panel_->IsDrawingAttention(); |
} |
+gfx::Size Panel::GetNonClientAreaSize() const { |
+ return native_panel_->GetNonClientAreaSize(); |
+} |
+ |
void Panel::Show() { |
native_panel_->ShowPanel(); |
} |
@@ -146,7 +187,7 @@ |
} |
gfx::Rect Panel::GetRestoredBounds() const { |
- return native_panel_->GetPanelBounds(); |
+ return native_panel_->GetPanelRestoredBounds(); |
} |
gfx::Rect Panel::GetBounds() const { |
@@ -414,6 +455,29 @@ |
} |
#endif |
+void Panel::UpdatePreferredSize(const gfx::Size& pref_size) { |
+ return manager()->UpdatePreferredSize(this, pref_size); |
Dmitry Titov
2011/08/05 19:02:20
As discussed, lets compute the window size here ri
jianli
2011/08/09 19:56:16
Done.
|
+} |
+ |
+void Panel::Observe(int type, |
+ const NotificationSource& source, |
+ const NotificationDetails& details) { |
+ switch (type) { |
+ case content::NOTIFICATION_TAB_ADDED: { |
+ RenderViewHost* render_view_host = |
+ browser()->GetSelectedTabContents()->render_view_host(); |
+ render_view_host->Send(new ViewMsg_EnablePreferredSizeChangedMode( |
+ render_view_host->routing_id(), |
+ kPreferredSizeWidth | kPreferredSizeHeightThisIsSlow)); |
+ render_view_host->Send(new ViewMsg_DisableScrollbarsForSmallWindows( |
+ render_view_host->routing_id(), max_size_)); |
+ } |
+ default: |
+ NOTREACHED() << "Got a notification we didn't register for!"; |
+ break; |
+ } |
+} |
+ |
Browser* Panel::browser() const { |
return native_panel_->GetPanelBrowser(); |
} |