Index: chrome/browser/ui/panels/panel_manager.cc |
=================================================================== |
--- chrome/browser/ui/panels/panel_manager.cc (revision 104349) |
+++ chrome/browser/ui/panels/panel_manager.cc (working copy) |
@@ -10,6 +10,7 @@ |
#include "base/memory/scoped_ptr.h" |
#include "base/message_loop.h" |
#include "chrome/browser/ui/browser.h" |
+#include "chrome/browser/ui/browser_list.h" |
#include "chrome/browser/ui/window_sizer.h" |
namespace { |
@@ -523,6 +524,51 @@ |
return bottom; |
} |
+BrowserWindow* PanelManager::GetNextPanelToActivate(Panel* panel) const { |
jennb
2011/10/07 20:34:16
Why do we need to find the next panel within the s
jianli
2011/10/07 22:01:54
Per discussion, we changed to activate the last ac
|
+ // First, find a panel that satisfies the following criteria: |
+ // 1) expanded |
+ // 2) from the same extension |
+ // 3) closer to the panel to be deactivated, if there're more than one panels |
+ // that meet 1 and 2 |
+ const Extension* extension = panel->GetExtension(); |
+ size_t panel_index; |
+ for (panel_index = 0; panel_index < panels_.size(); ++panel_index) { |
+ if (panels_[panel_index] == panel) |
+ break; |
+ } |
+ DCHECK(panel_index < panels_.size()); |
+ |
+ size_t max_index_delta = std::max(panel_index, panels_.size() - panel_index); |
Dmitry Titov
2011/10/07 20:29:15
This needs a comment. Why this specific math?
jianli
2011/10/07 22:01:54
Not needed due to deactivation algorithm change.
|
+ for (size_t delta = 1; delta <= max_index_delta; ++delta) { |
+ if (panel_index + delta < panels_.size()) { |
+ Panel* next_panel = panels_[panel_index + delta]; |
+ if (next_panel->expansion_state() == Panel::EXPANDED && |
+ next_panel->GetExtension() == extension) { |
+ return next_panel->browser()->window(); |
+ } |
+ } |
+ |
+ if (panel_index >= delta) { |
Dmitry Titov
2011/10/07 20:29:15
would be more readable as 'panel_index - delta >=
jianli
2011/10/07 22:01:54
Not needed due to deactivation algorithm change.
|
+ Panel* next_panel = panels_[panel_index - delta]; |
+ if (next_panel->expansion_state() == Panel::EXPANDED && |
+ next_panel->GetExtension() == extension) { |
+ return next_panel->browser()->window(); |
+ } |
+ } |
+ } |
+ |
+ // Then, find the last active tabbed window. |
+ BrowserList::const_reverse_iterator iter = BrowserList::begin_last_active(); |
+ BrowserList::const_reverse_iterator end = BrowserList::end_last_active(); |
+ for (; (iter != end); ++iter) { |
+ Browser* browser = *iter; |
+ if (browser->is_type_tabbed()) |
+ return browser->window(); |
+ } |
+ |
+ return NULL; |
+} |
+ |
void PanelManager::OnMouseMove(const gfx::Point& mouse_position) { |
bool bring_up_titlebars = ShouldBringUpTitlebars(mouse_position.x(), |
mouse_position.y()); |