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 "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "chrome/browser/ui/panels/docked_panel_strip.h" | 9 #include "chrome/browser/ui/panels/docked_panel_strip.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
(...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
679 content::Source<WebContents>(web_contents)); | 679 content::Source<WebContents>(web_contents)); |
680 } | 680 } |
681 | 681 |
682 void Panel::Observe(int type, | 682 void Panel::Observe(int type, |
683 const content::NotificationSource& source, | 683 const content::NotificationSource& source, |
684 const content::NotificationDetails& details) { | 684 const content::NotificationDetails& details) { |
685 DCHECK_EQ(content::NOTIFICATION_WEB_CONTENTS_SWAPPED, type); | 685 DCHECK_EQ(content::NOTIFICATION_WEB_CONTENTS_SWAPPED, type); |
686 ConfigureAutoResize(content::Source<WebContents>(source).ptr()); | 686 ConfigureAutoResize(content::Source<WebContents>(source).ptr()); |
687 } | 687 } |
688 | 688 |
689 void Panel::OnActiveStateChanged() { | 689 void Panel::OnActiveStateChanged(bool active) { |
690 // Clear draw attention state when an expanded panel becomes active. | |
jianli
2012/04/25 18:19:31
remove "draw" in the comment?
jennb
2012/04/25 20:34:05
Done.
| |
691 // On some systems (e.g. Win), mouse-down activates a panel regardless of | |
692 // its expansion state. However, we don't want to clear draw attention if | |
693 // contents are not visible. In that scenario, if the mouse-down results | |
694 // in a mouse-click, draw attention will be cleared then. | |
695 // See Panel::OnTitlebarClicked(). | |
696 if (active && IsDrawingAttention() && !IsMinimized()) | |
697 FlashFrame(false); | |
698 | |
690 if (panel_strip_) | 699 if (panel_strip_) |
691 panel_strip_->OnPanelActiveStateChanged(this); | 700 panel_strip_->OnPanelActiveStateChanged(this); |
701 | |
702 content::NotificationService::current()->Notify( | |
703 chrome::NOTIFICATION_PANEL_CHANGED_ACTIVE_STATUS, | |
704 content::Source<Panel>(this), | |
705 content::NotificationService::NoDetails()); | |
692 } | 706 } |
693 | 707 |
694 void Panel::ConfigureAutoResize(WebContents* web_contents) { | 708 void Panel::ConfigureAutoResize(WebContents* web_contents) { |
695 if (!auto_resizable_ || !web_contents) | 709 if (!auto_resizable_ || !web_contents) |
696 return; | 710 return; |
697 | 711 |
698 // NULL might be returned if the tab has not been added. | 712 // NULL might be returned if the tab has not been added. |
699 RenderViewHost* render_view_host = web_contents->GetRenderViewHost(); | 713 RenderViewHost* render_view_host = web_contents->GetRenderViewHost(); |
700 if (!render_view_host) | 714 if (!render_view_host) |
701 return; | 715 return; |
702 | 716 |
703 render_view_host->EnableAutoResize( | 717 render_view_host->EnableAutoResize( |
704 min_size_, | 718 min_size_, |
705 native_panel_->ContentSizeFromWindowSize(max_size_)); | 719 native_panel_->ContentSizeFromWindowSize(max_size_)); |
706 } | 720 } |
707 | 721 |
708 void Panel::OnWindowSizeAvailable() { | 722 void Panel::OnWindowSizeAvailable() { |
709 ConfigureAutoResize(browser()->GetSelectedWebContents()); | 723 ConfigureAutoResize(browser()->GetSelectedWebContents()); |
710 } | 724 } |
711 | 725 |
712 void Panel::OnTitlebarClicked(panel::ClickModifier modifier) { | 726 void Panel::OnTitlebarClicked(panel::ClickModifier modifier) { |
713 if (panel_strip_) | 727 if (panel_strip_) |
714 panel_strip_->OnPanelTitlebarClicked(this, modifier); | 728 panel_strip_->OnPanelTitlebarClicked(this, modifier); |
729 | |
730 // Normally the system activates a window when the titlebar is clicked. | |
731 // However, we prevent system activation of minimized panels, thus the | |
732 // activation may not have occurred. Also, some OSes (Windows) will | |
733 // activate a minimized panel on mouse-down regardless of our attempts to | |
734 // prevent system activation. Attention state is not cleared in that case. | |
735 // See Panel::OnActiveStateChanged(). | |
736 // Therefore, we ensure activation and clearing of attention state here. | |
737 // These are no-ops if no changes are needed. | |
738 Activate(); | |
739 FlashFrame(false); | |
715 } | 740 } |
716 | 741 |
717 void Panel::DestroyBrowser() { | 742 void Panel::DestroyBrowser() { |
718 native_panel_->DestroyPanelBrowser(); | 743 native_panel_->DestroyPanelBrowser(); |
719 } | 744 } |
OLD | NEW |