OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/panels/panel.h" | 5 #include "chrome/browser/ui/panels/panel.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "chrome/browser/extensions/extension_prefs.h" | 8 #include "chrome/browser/extensions/extension_prefs.h" |
9 #include "chrome/browser/extensions/extension_service.h" | 9 #include "chrome/browser/extensions/extension_service.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 chrome::NOTIFICATION_PANEL_CHANGED_BOUNDS, | 112 chrome::NOTIFICATION_PANEL_CHANGED_BOUNDS, |
113 content::Source<Panel>(this), | 113 content::Source<Panel>(this), |
114 content::NotificationService::NoDetails()); | 114 content::NotificationService::NoDetails()); |
115 } | 115 } |
116 | 116 |
117 void Panel::SetAutoResizable(bool resizable) { | 117 void Panel::SetAutoResizable(bool resizable) { |
118 if (auto_resizable_ == resizable) | 118 if (auto_resizable_ == resizable) |
119 return; | 119 return; |
120 | 120 |
121 auto_resizable_ = resizable; | 121 auto_resizable_ = resizable; |
| 122 WebContents* web_contents = browser()->GetSelectedWebContents(); |
122 if (auto_resizable_) { | 123 if (auto_resizable_) { |
123 browser()->tabstrip_model()->AddObserver(this); | 124 browser()->tabstrip_model()->AddObserver(this); |
124 WebContents* web_contents = browser()->GetSelectedWebContents(); | |
125 if (web_contents) | 125 if (web_contents) |
126 EnableWebContentsAutoResize(web_contents); | 126 EnableWebContentsAutoResize(web_contents); |
127 } else { | 127 } else { |
128 browser()->tabstrip_model()->RemoveObserver(this); | 128 browser()->tabstrip_model()->RemoveObserver(this); |
129 registrar_.RemoveAll(); | 129 registrar_.RemoveAll(); |
| 130 |
| 131 if (web_contents) { |
| 132 // NULL might be returned if the tab has not been added. |
| 133 RenderViewHost* render_view_host = web_contents->GetRenderViewHost(); |
| 134 if (render_view_host) |
| 135 render_view_host->DisableAutoResize(restored_size_); |
| 136 } |
130 } | 137 } |
131 } | 138 } |
132 | 139 |
133 void Panel::SetSizeRange(const gfx::Size& min_size, const gfx::Size& max_size) { | 140 void Panel::SetSizeRange(const gfx::Size& min_size, const gfx::Size& max_size) { |
134 if (min_size == min_size_ && max_size == max_size_) | 141 if (min_size == min_size_ && max_size == max_size_) |
135 return; | 142 return; |
136 | 143 |
137 DCHECK(min_size.width() <= max_size.width()); | 144 DCHECK(min_size.width() <= max_size.width()); |
138 DCHECK(min_size.height() <= max_size.height()); | 145 DCHECK(min_size.height() <= max_size.height()); |
139 min_size_ = min_size; | 146 min_size_ = min_size; |
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
613 #if defined(OS_CHROMEOS) | 620 #if defined(OS_CHROMEOS) |
614 void Panel::ShowMobileSetup() { | 621 void Panel::ShowMobileSetup() { |
615 NOTIMPLEMENTED(); | 622 NOTIMPLEMENTED(); |
616 } | 623 } |
617 | 624 |
618 void Panel::ShowKeyboardOverlay(gfx::NativeWindow owning_window) { | 625 void Panel::ShowKeyboardOverlay(gfx::NativeWindow owning_window) { |
619 NOTIMPLEMENTED(); | 626 NOTIMPLEMENTED(); |
620 } | 627 } |
621 #endif | 628 #endif |
622 | 629 |
623 void Panel::UpdatePreferredSize(WebContents* web_contents, | 630 void Panel::ResizeDueToAutoResize(WebContents* web_contents, |
624 const gfx::Size& pref_size) { | 631 const gfx::Size& pref_size) { |
625 if (auto_resizable_) { | 632 DCHECK(auto_resizable_); |
626 return manager()->OnPreferredWindowSizeChanged(this, | 633 return manager()->OnWindowAutoResized( |
627 native_panel_->WindowSizeFromContentSize(pref_size)); | 634 this, |
628 } | 635 native_panel_->WindowSizeFromContentSize(pref_size)); |
629 } | 636 } |
630 | 637 |
631 void Panel::ShowAvatarBubble(WebContents* web_contents, const gfx::Rect& rect) { | 638 void Panel::ShowAvatarBubble(WebContents* web_contents, const gfx::Rect& rect) { |
632 // Panels will never show a new tab page so this should never be called. | 639 // Panels will never show a new tab page so this should never be called. |
633 NOTREACHED(); | 640 NOTREACHED(); |
634 } | 641 } |
635 | 642 |
636 void Panel::ShowAvatarBubbleFromAvatarButton() { | 643 void Panel::ShowAvatarBubbleFromAvatarButton() { |
637 // Panels will never show an avatar button so this should never be called. | 644 // Panels will never show an avatar button so this should never be called. |
638 NOTREACHED(); | 645 NOTREACHED(); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
681 native_panel_->ContentSizeFromWindowSize(max_size_)); | 688 native_panel_->ContentSizeFromWindowSize(max_size_)); |
682 } | 689 } |
683 | 690 |
684 void Panel::OnWindowSizeAvailable() { | 691 void Panel::OnWindowSizeAvailable() { |
685 ConfigureAutoResize(browser()->GetSelectedWebContents()); | 692 ConfigureAutoResize(browser()->GetSelectedWebContents()); |
686 } | 693 } |
687 | 694 |
688 void Panel::DestroyBrowser() { | 695 void Panel::DestroyBrowser() { |
689 native_panel_->DestroyPanelBrowser(); | 696 native_panel_->DestroyPanelBrowser(); |
690 } | 697 } |
OLD | NEW |