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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 chrome::NOTIFICATION_PANEL_CHANGED_BOUNDS, | 111 chrome::NOTIFICATION_PANEL_CHANGED_BOUNDS, |
112 content::Source<Panel>(this), | 112 content::Source<Panel>(this), |
113 content::NotificationService::NoDetails()); | 113 content::NotificationService::NoDetails()); |
114 } | 114 } |
115 | 115 |
116 void Panel::SetAutoResizable(bool resizable) { | 116 void Panel::SetAutoResizable(bool resizable) { |
117 if (auto_resizable_ == resizable) | 117 if (auto_resizable_ == resizable) |
118 return; | 118 return; |
119 | 119 |
120 auto_resizable_ = resizable; | 120 auto_resizable_ = resizable; |
| 121 WebContents* web_contents = browser()->GetSelectedWebContents(); |
121 if (auto_resizable_) { | 122 if (auto_resizable_) { |
122 browser()->tabstrip_model()->AddObserver(this); | 123 browser()->tabstrip_model()->AddObserver(this); |
123 WebContents* web_contents = browser()->GetSelectedWebContents(); | |
124 if (web_contents) | 124 if (web_contents) |
125 EnableWebContentsAutoResize(web_contents); | 125 EnableWebContentsAutoResize(web_contents); |
126 } else { | 126 } else { |
127 browser()->tabstrip_model()->RemoveObserver(this); | 127 browser()->tabstrip_model()->RemoveObserver(this); |
128 registrar_.RemoveAll(); | 128 registrar_.RemoveAll(); |
| 129 |
| 130 if (web_contents) { |
| 131 // NULL might be returned if the tab has not been added. |
| 132 RenderViewHost* render_view_host = web_contents->GetRenderViewHost(); |
| 133 if (render_view_host) |
| 134 render_view_host->DisableAutoResize(restored_size_); |
| 135 } |
129 } | 136 } |
130 } | 137 } |
131 | 138 |
132 void Panel::SetSizeRange(const gfx::Size& min_size, const gfx::Size& max_size) { | 139 void Panel::SetSizeRange(const gfx::Size& min_size, const gfx::Size& max_size) { |
133 if (min_size == min_size_ && max_size == max_size_) | 140 if (min_size == min_size_ && max_size == max_size_) |
134 return; | 141 return; |
135 | 142 |
136 DCHECK(min_size.width() <= max_size.width()); | 143 DCHECK(min_size.width() <= max_size.width()); |
137 DCHECK(min_size.height() <= max_size.height()); | 144 DCHECK(min_size.height() <= max_size.height()); |
138 min_size_ = min_size; | 145 min_size_ = min_size; |
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
618 NOTIMPLEMENTED(); | 625 NOTIMPLEMENTED(); |
619 } | 626 } |
620 | 627 |
621 void Panel::ShowKeyboardOverlay(gfx::NativeWindow owning_window) { | 628 void Panel::ShowKeyboardOverlay(gfx::NativeWindow owning_window) { |
622 NOTIMPLEMENTED(); | 629 NOTIMPLEMENTED(); |
623 } | 630 } |
624 #endif | 631 #endif |
625 | 632 |
626 void Panel::UpdatePreferredSize(WebContents* web_contents, | 633 void Panel::UpdatePreferredSize(WebContents* web_contents, |
627 const gfx::Size& pref_size) { | 634 const gfx::Size& pref_size) { |
628 if (auto_resizable_) { | 635 DCHECK(auto_resizable_); |
629 return manager()->OnPreferredWindowSizeChanged(this, | 636 return manager()->OnPreferredWindowSizeChanged(this, |
630 native_panel_->WindowSizeFromContentSize(pref_size)); | 637 native_panel_->WindowSizeFromContentSize(pref_size)); |
631 } | |
632 } | 638 } |
633 | 639 |
634 void Panel::ShowAvatarBubble(WebContents* web_contents, const gfx::Rect& rect) { | 640 void Panel::ShowAvatarBubble(WebContents* web_contents, const gfx::Rect& rect) { |
635 // Panels will never show a new tab page so this should never be called. | 641 // Panels will never show a new tab page so this should never be called. |
636 NOTREACHED(); | 642 NOTREACHED(); |
637 } | 643 } |
638 | 644 |
639 void Panel::ShowAvatarBubbleFromAvatarButton() { | 645 void Panel::ShowAvatarBubbleFromAvatarButton() { |
640 // Panels will never show an avatar button so this should never be called. | 646 // Panels will never show an avatar button so this should never be called. |
641 NOTREACHED(); | 647 NOTREACHED(); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
684 native_panel_->ContentSizeFromWindowSize(max_size_)); | 690 native_panel_->ContentSizeFromWindowSize(max_size_)); |
685 } | 691 } |
686 | 692 |
687 void Panel::OnWindowSizeAvailable() { | 693 void Panel::OnWindowSizeAvailable() { |
688 ConfigureAutoResize(browser()->GetSelectedWebContents()); | 694 ConfigureAutoResize(browser()->GetSelectedWebContents()); |
689 } | 695 } |
690 | 696 |
691 void Panel::DestroyBrowser() { | 697 void Panel::DestroyBrowser() { |
692 native_panel_->DestroyPanelBrowser(); | 698 native_panel_->DestroyPanelBrowser(); |
693 } | 699 } |
OLD | NEW |