| Index: chrome/browser/ui/panels/panel_manager.cc
|
| diff --git a/chrome/browser/ui/panels/panel_manager.cc b/chrome/browser/ui/panels/panel_manager.cc
|
| index 2b24f215b4a54ad50a2037b2e4ca66d892368deb..8d16be01b306381d5ec3849b3153da277e8f85d5 100644
|
| --- a/chrome/browser/ui/panels/panel_manager.cc
|
| +++ b/chrome/browser/ui/panels/panel_manager.cc
|
| @@ -134,6 +134,10 @@ PanelManager::~PanelManager() {
|
| docked_strip_.reset();
|
| }
|
|
|
| +const gfx::Point& PanelManager::GetDefaultDetachedPanelOrigin() {
|
| + return detached_strip_->GetDefaultPanelOrigin();
|
| +}
|
| +
|
| void PanelManager::OnDisplayAreaChanged(const gfx::Rect& display_area) {
|
| if (display_area == display_area_)
|
| return;
|
| @@ -162,21 +166,23 @@ int PanelManager::GetMaxPanelHeight() const {
|
|
|
| Panel* PanelManager::CreatePanel(Browser* browser) {
|
| return CreatePanel(browser, "", NULL, GURL(),
|
| - browser->override_bounds().size());
|
| + browser->override_bounds(), CREATE_DOCKED);
|
| }
|
|
|
| Panel* PanelManager::CreatePanel(const std::string& app_name,
|
| Profile* profile,
|
| const GURL& url,
|
| - const gfx::Size& requested_size) {
|
| - return CreatePanel(NULL, app_name, profile, url, requested_size);
|
| + const gfx::Rect& requested_bounds,
|
| + CreateMode mode) {
|
| + return CreatePanel(NULL, app_name, profile, url, requested_bounds, mode);
|
| }
|
|
|
| Panel* PanelManager::CreatePanel(Browser* browser,
|
| const std::string& app_name,
|
| Profile* profile,
|
| const GURL& url,
|
| - const gfx::Size& requested_size) {
|
| + const gfx::Rect& requested_bounds,
|
| + CreateMode mode) {
|
| // Need to sync the display area if no panel is present. This is because:
|
| // 1) Display area is not initialized until first panel is created.
|
| // 2) On windows, display settings notification is tied to a window. When
|
| @@ -188,8 +194,8 @@ Panel* PanelManager::CreatePanel(Browser* browser,
|
| }
|
|
|
| // Compute initial bounds for the panel.
|
| - int width = requested_size.width();
|
| - int height = requested_size.height();
|
| + int width = requested_bounds.width();
|
| + int height = requested_bounds.height();
|
| if (width == 0)
|
| width = height * kPanelDefaultWidthToHeightRatio;
|
| else if (height == 0)
|
| @@ -207,9 +213,13 @@ Panel* PanelManager::CreatePanel(Browser* browser,
|
| else if (height > max_size.height())
|
| height = max_size.height();
|
|
|
| - gfx::Size panel_size(width, height);
|
| - gfx::Rect bounds(docked_strip_->GetDefaultPositionForPanel(panel_size),
|
| - panel_size);
|
| + gfx::Rect bounds(width, height);
|
| + if (CREATE_DOCKED == mode) {
|
| + bounds.set_origin(docked_strip_->GetDefaultPositionForPanel(bounds.size()));
|
| + } else {
|
| + bounds.set_origin(requested_bounds.origin());
|
| + bounds = bounds.AdjustToFit(display_settings_provider_->GetDisplayArea());
|
| + }
|
|
|
| // Create the panel.
|
| Panel* panel;
|
| @@ -223,17 +233,21 @@ Panel* PanelManager::CreatePanel(Browser* browser,
|
| }
|
|
|
| // Auto resizable feature is enabled only if no initial size is requested.
|
| - if (auto_sizing_enabled() && requested_size.width() == 0 &&
|
| - requested_size.height() == 0) {
|
| + if (auto_sizing_enabled() && requested_bounds.width() == 0 &&
|
| + requested_bounds.height() == 0) {
|
| panel->SetAutoResizable(true);
|
| }
|
|
|
| - // Add the panel to the docked strip.
|
| + // Add the panel to the appropriate panel strip.
|
| // Delay layout refreshes in case multiple panels are created within
|
| // a short time of one another or the focus changes shortly after panel
|
| // is created to avoid excessive screen redraws.
|
| - docked_strip_->AddPanel(panel, PanelStrip::DELAY_LAYOUT_REFRESH);
|
| - docked_strip_->UpdatePanelOnStripChange(panel);
|
| + if (CREATE_DOCKED == mode)
|
| + docked_strip_->AddPanel(panel, PanelStrip::DELAY_LAYOUT_REFRESH);
|
| + else
|
| + detached_strip_->AddPanel(panel, PanelStrip::KNOWN_POSITION);
|
| +
|
| + panel->panel_strip()->UpdatePanelOnStripChange(panel);
|
|
|
| return panel;
|
| }
|
|
|