Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(294)

Unified Diff: chrome/browser/ui/panels/panel.cc

Issue 8774016: Change the panel using the improved way of doing autosizing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix comment. Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/panels/panel.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/panels/panel.cc
diff --git a/chrome/browser/ui/panels/panel.cc b/chrome/browser/ui/panels/panel.cc
index 5bcab6c969788442fbc6d0a98affc2d27d6fea95..5885599c6b7ce4741e286a367b821b42125ef7e1 100644
--- a/chrome/browser/ui/panels/panel.cc
+++ b/chrome/browser/ui/panels/panel.cc
@@ -100,12 +100,7 @@ void Panel::SetSizeRange(const gfx::Size& min_size, const gfx::Size& max_size) {
min_size_ = min_size;
max_size_ = max_size;
- // Need to update the renderer on the new size range.
- if (auto_resizable_) {
- RenderViewHost* render_view_host = GetRenderViewHost();
- if (render_view_host)
- RequestRenderViewHostToDisableScrollbars(render_view_host);
- }
+ ConfigureAutoResize(browser()->GetSelectedTabContents());
}
void Panel::SetExpansionState(ExpansionState new_state) {
@@ -583,13 +578,10 @@ void Panel::TabInsertedAt(TabContentsWrapper* contents,
void Panel::EnableTabContentsAutoResize(TabContents* tab_contents) {
DCHECK(tab_contents);
- RenderViewHost* render_view_host = tab_contents->render_view_host();
- if (render_view_host)
- EnableRendererAutoResize(render_view_host);
+ ConfigureAutoResize(tab_contents);
// We also need to know when the render view host changes in order
- // to turn on preferred size changed notifications in the new
- // render view host.
+ // to turn on auto-resize notifications in the new render view host.
registrar_.RemoveAll(); // Stop notifications for previous contents, if any.
registrar_.Add(
this,
@@ -600,43 +592,26 @@ void Panel::EnableTabContentsAutoResize(TabContents* tab_contents) {
void Panel::Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) {
- if (auto_resizable_) {
- DCHECK_EQ(type, content::NOTIFICATION_TAB_CONTENTS_SWAPPED);
- RenderViewHost* render_view_host =
- content::Source<TabContents>(source).ptr()->render_view_host();
- if (render_view_host)
- EnableRendererAutoResize(render_view_host);
- }
+ DCHECK_EQ(type, content::NOTIFICATION_TAB_CONTENTS_SWAPPED);
+ ConfigureAutoResize(content::Source<TabContents>(source).ptr());
}
-RenderViewHost* Panel::GetRenderViewHost() const {
- TabContents* tab_contents = browser()->GetSelectedTabContents();
- if (!tab_contents)
- return NULL;
- return tab_contents->render_view_host();
-}
+void Panel::ConfigureAutoResize(TabContents* tab_contents) {
+ if (!auto_resizable_ || !tab_contents)
+ return;
-void Panel::EnableRendererAutoResize(RenderViewHost* render_view_host) {
- DCHECK(auto_resizable_);
- DCHECK(render_view_host);
- render_view_host->EnablePreferredSizeMode();
- RequestRenderViewHostToDisableScrollbars(render_view_host);
-}
+ // NULL might be returned if the tab has not been added.
+ RenderViewHost* render_view_host = tab_contents->render_view_host();
+ if (!render_view_host)
+ return;
-void Panel::RequestRenderViewHostToDisableScrollbars(
- RenderViewHost* render_view_host) {
- DCHECK(auto_resizable_);
- DCHECK(render_view_host);
- render_view_host->DisableScrollbarsForThreshold(
+ render_view_host->EnableAutoResize(
+ min_size_,
native_panel_->ContentSizeFromWindowSize(max_size_));
}
void Panel::OnWindowSizeAvailable() {
- if (auto_resizable_) {
- RenderViewHost* render_view_host = GetRenderViewHost();
- if (render_view_host)
- RequestRenderViewHostToDisableScrollbars(render_view_host);
- }
+ ConfigureAutoResize(browser()->GetSelectedTabContents());
}
void Panel::DestroyBrowser() {
« no previous file with comments | « chrome/browser/ui/panels/panel.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698