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

Side by Side Diff: chrome/browser/ui/panels/panel_manager.cc

Issue 10066041: Revert 132144 - Broke ASAN (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 8 months 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_manager.h" 5 #include "chrome/browser/ui/panels/panel_manager.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/message_loop.h" 12 #include "base/message_loop.h"
13 #include "chrome/browser/fullscreen.h"
13 #include "chrome/browser/ui/browser.h" 14 #include "chrome/browser/ui/browser.h"
14 #include "chrome/browser/ui/browser_list.h" 15 #include "chrome/browser/ui/browser_list.h"
15 #include "chrome/browser/ui/panels/detached_panel_strip.h" 16 #include "chrome/browser/ui/panels/detached_panel_strip.h"
16 #include "chrome/browser/ui/panels/docked_panel_strip.h" 17 #include "chrome/browser/ui/panels/docked_panel_strip.h"
17 #include "chrome/browser/ui/panels/overflow_panel_strip.h" 18 #include "chrome/browser/ui/panels/overflow_panel_strip.h"
18 #include "chrome/browser/ui/panels/panel_drag_controller.h" 19 #include "chrome/browser/ui/panels/panel_drag_controller.h"
19 #include "chrome/browser/ui/panels/panel_mouse_watcher.h" 20 #include "chrome/browser/ui/panels/panel_mouse_watcher.h"
20 #include "chrome/browser/ui/panels/panel_resize_controller.h" 21 #include "chrome/browser/ui/panels/panel_resize_controller.h"
21 #include "chrome/common/chrome_notification_types.h" 22 #include "chrome/common/chrome_notification_types.h"
22 #include "chrome/common/chrome_switches.h" 23 #include "chrome/common/chrome_switches.h"
23 #include "chrome/common/chrome_version_info.h" 24 #include "chrome/common/chrome_version_info.h"
24 #include "content/public/browser/notification_service.h" 25 #include "content/public/browser/notification_service.h"
25 #include "content/public/browser/notification_source.h" 26 #include "content/public/browser/notification_source.h"
26 27
27 #if defined(TOOLKIT_GTK) 28 #if defined(TOOLKIT_GTK)
28 #include "ui/base/x/x11_util.h" 29 #include "ui/base/x/x11_util.h"
29 #endif 30 #endif
30 31
31 namespace { 32 namespace {
32 const int kOverflowStripThickness = 26; 33 const int kOverflowStripThickness = 26;
33 34
34 // Width of spacing around panel strip and the left/right edges of the screen. 35 // Width of spacing around panel strip and the left/right edges of the screen.
35 const int kPanelStripLeftMargin = kOverflowStripThickness + 6; 36 const int kPanelStripLeftMargin = kOverflowStripThickness + 6;
36 const int kPanelStripRightMargin = 24; 37 const int kPanelStripRightMargin = 24;
37 38
38 // Height of panel strip is based on the factor of the working area. 39 // Height of panel strip is based on the factor of the working area.
39 const double kPanelStripHeightFactor = 0.5; 40 const double kPanelStripHeightFactor = 0.5;
40 41
42 const int kFullScreenModeCheckIntervalMs = 1000;
43
41 // New panels that cannot fit in the panel strip are moved to overflow 44 // New panels that cannot fit in the panel strip are moved to overflow
42 // after a brief delay. 45 // after a brief delay.
43 const int kMoveNewPanelToOverflowDelayMs = 1500; // arbitrary 46 const int kMoveNewPanelToOverflowDelayMs = 1500; // arbitrary
44 } // namespace 47 } // namespace
45 48
46 // static 49 // static
47 bool PanelManager::shorten_time_intervals_ = false; 50 bool PanelManager::shorten_time_intervals_ = false;
48 51
49 // static 52 // static
50 PanelManager* PanelManager::GetInstance() { 53 PanelManager* PanelManager::GetInstance() {
(...skipping 25 matching lines...) Expand all
76 extension_id == std::string("ppleadejekpmccmnpjdimmlfljlkdfej") || 79 extension_id == std::string("ppleadejekpmccmnpjdimmlfljlkdfej") ||
77 extension_id == std::string("eggnbpckecmjlblplehfpjjdhhidfdoj"); 80 extension_id == std::string("eggnbpckecmjlblplehfpjjdhhidfdoj");
78 } 81 }
79 82
80 return true; 83 return true;
81 } 84 }
82 85
83 PanelManager::PanelManager() 86 PanelManager::PanelManager()
84 : panel_mouse_watcher_(PanelMouseWatcher::Create()), 87 : panel_mouse_watcher_(PanelMouseWatcher::Create()),
85 auto_sizing_enabled_(true), 88 auto_sizing_enabled_(true),
89 is_full_screen_(false),
86 is_processing_overflow_(false) { 90 is_processing_overflow_(false) {
87 // DisplaySettingsProvider should be created before the creation of strips 91 // DisplaySettingsProvider should be created before the creation of strips
88 // since some strip might depend on it. 92 // since some strip might depend on it.
89 display_settings_provider_.reset(DisplaySettingsProvider::Create()); 93 display_settings_provider_.reset(DisplaySettingsProvider::Create());
90 display_settings_provider_->AddDisplayAreaObserver(this); 94 display_settings_provider_->set_display_area_observer(this);
91 95
92 detached_strip_.reset(new DetachedPanelStrip(this)); 96 detached_strip_.reset(new DetachedPanelStrip(this));
93 docked_strip_.reset(new DockedPanelStrip(this)); 97 docked_strip_.reset(new DockedPanelStrip(this));
94 overflow_strip_.reset(new OverflowPanelStrip(this)); 98 overflow_strip_.reset(new OverflowPanelStrip(this));
95 drag_controller_.reset(new PanelDragController(this)); 99 drag_controller_.reset(new PanelDragController(this));
96 resize_controller_.reset(new PanelResizeController(this)); 100 resize_controller_.reset(new PanelResizeController(this));
97 } 101 }
98 102
99 PanelManager::~PanelManager() { 103 PanelManager::~PanelManager() {
100 display_settings_provider_->RemoveDisplayAreaObserver(this);
101 } 104 }
102 105
103 void PanelManager::OnDisplayAreaChanged(const gfx::Rect& display_area) { 106 void PanelManager::OnDisplayAreaChanged(const gfx::Rect& display_area) {
104 int height = 107 int height =
105 static_cast<int>(display_area.height() * kPanelStripHeightFactor); 108 static_cast<int>(display_area.height() * kPanelStripHeightFactor);
106 gfx::Rect docked_strip_bounds; 109 gfx::Rect docked_strip_bounds;
107 docked_strip_bounds.set_x(display_area.x() + kPanelStripLeftMargin); 110 docked_strip_bounds.set_x(display_area.x() + kPanelStripLeftMargin);
108 docked_strip_bounds.set_y(display_area.bottom() - height); 111 docked_strip_bounds.set_y(display_area.bottom() - height);
109 docked_strip_bounds.set_width(display_area.width() - 112 docked_strip_bounds.set_width(display_area.width() -
110 kPanelStripLeftMargin - kPanelStripRightMargin); 113 kPanelStripLeftMargin - kPanelStripRightMargin);
111 docked_strip_bounds.set_height(height); 114 docked_strip_bounds.set_height(height);
112 docked_strip_->SetDisplayArea(docked_strip_bounds); 115 docked_strip_->SetDisplayArea(docked_strip_bounds);
113 116
114 gfx::Rect overflow_area(display_area); 117 gfx::Rect overflow_area(display_area);
115 overflow_area.set_width(kOverflowStripThickness); 118 overflow_area.set_width(kOverflowStripThickness);
116 overflow_strip_->SetDisplayArea(overflow_area); 119 overflow_strip_->SetDisplayArea(overflow_area);
117 } 120 }
118 121
119 void PanelManager::OnFullScreenModeChanged(bool is_full_screen) {
120 docked_strip_->OnFullScreenModeChanged(is_full_screen);
121 overflow_strip_->OnFullScreenModeChanged(is_full_screen);
122 }
123
124 Panel* PanelManager::CreatePanel(Browser* browser) { 122 Panel* PanelManager::CreatePanel(Browser* browser) {
125 // Need to sync the display area if no panel is present. This is because: 123 // Need to sync the display area if no panel is present. This is because:
126 // 1) Display area is not initialized until first panel is created. 124 // 1) Display area is not initialized until first panel is created.
127 // 2) On windows, display settings notification is tied to a window. When 125 // 2) On windows, display settings notification is tied to a window. When
128 // display settings are changed at the time that no panel exists, we do 126 // display settings are changed at the time that no panel exists, we do
129 // not receive any notification. 127 // not receive any notification.
130 if (num_panels() == 0) 128 if (num_panels() == 0)
131 display_settings_provider_->OnDisplaySettingsChanged(); 129 display_settings_provider_->OnDisplaySettingsChanged();
132 130
133 int width = browser->override_bounds().width(); 131 int width = browser->override_bounds().width();
134 int height = browser->override_bounds().height(); 132 int height = browser->override_bounds().height();
135 Panel* panel = new Panel(browser, gfx::Size(width, height)); 133 Panel* panel = new Panel(browser, gfx::Size(width, height));
136 docked_strip_->AddPanel(panel, PanelStrip::DEFAULT_POSITION); 134 docked_strip_->AddPanel(panel, PanelStrip::DEFAULT_POSITION);
137 docked_strip_->UpdatePanelOnStripChange(panel); 135 docked_strip_->UpdatePanelOnStripChange(panel);
138 136
139 content::NotificationService::current()->Notify( 137 content::NotificationService::current()->Notify(
140 chrome::NOTIFICATION_PANEL_ADDED, 138 chrome::NOTIFICATION_PANEL_ADDED,
141 content::Source<Panel>(panel), 139 content::Source<Panel>(panel),
142 content::NotificationService::NoDetails()); 140 content::NotificationService::NoDetails());
143 141
144 if (num_panels() == 1) { 142 if (num_panels() == 1) {
145 display_settings_provider_->AddFullScreenObserver(this); 143 full_screen_mode_timer_.Start(FROM_HERE,
144 base::TimeDelta::FromMilliseconds(kFullScreenModeCheckIntervalMs),
145 this, &PanelManager::CheckFullScreenMode);
146 } 146 }
147 147
148 return panel; 148 return panel;
149 } 149 }
150 150
151 void PanelManager::CheckFullScreenMode() {
152 bool is_full_screen_new = IsFullScreenMode();
153 if (is_full_screen_ == is_full_screen_new)
154 return;
155 is_full_screen_ = is_full_screen_new;
156 docked_strip_->OnFullScreenModeChanged(is_full_screen_);
157 overflow_strip_->OnFullScreenModeChanged(is_full_screen_);
158 }
159
151 void PanelManager::OnPanelClosed(Panel* panel) { 160 void PanelManager::OnPanelClosed(Panel* panel) {
152 if (num_panels() == 1) { 161 if (num_panels() == 1)
153 display_settings_provider_->RemoveFullScreenObserver(this); 162 full_screen_mode_timer_.Stop();
154 }
155 163
156 drag_controller_->OnPanelClosed(panel); 164 drag_controller_->OnPanelClosed(panel);
157 resize_controller_->OnPanelClosed(panel); 165 resize_controller_->OnPanelClosed(panel);
158 panel->panel_strip()->RemovePanel(panel); 166 panel->panel_strip()->RemovePanel(panel);
159 167
160 content::NotificationService::current()->Notify( 168 content::NotificationService::current()->Notify(
161 chrome::NOTIFICATION_PANEL_CLOSED, 169 chrome::NOTIFICATION_PANEL_CLOSED,
162 content::Source<Panel>(panel), 170 content::Source<Panel>(panel),
163 content::NotificationService::NoDetails()); 171 content::NotificationService::NoDetails());
164 } 172 }
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 base::TimeDelta::FromMilliseconds(PanelManager::AdjustTimeInterval( 379 base::TimeDelta::FromMilliseconds(PanelManager::AdjustTimeInterval(
372 kMoveNewPanelToOverflowDelayMs))); 380 kMoveNewPanelToOverflowDelayMs)));
373 } 381 }
374 382
375 content::NotificationService::current()->Notify( 383 content::NotificationService::current()->Notify(
376 chrome::NOTIFICATION_PANEL_BOUNDS_ANIMATIONS_FINISHED, 384 chrome::NOTIFICATION_PANEL_BOUNDS_ANIMATIONS_FINISHED,
377 content::Source<Panel>(panel), 385 content::Source<Panel>(panel),
378 content::NotificationService::NoDetails()); 386 content::NotificationService::NoDetails());
379 } 387 }
380 388
OLDNEW
« no previous file with comments | « chrome/browser/ui/panels/panel_manager.h ('k') | chrome/browser/ui/panels/panel_window_controller_cocoa.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698