diff options
author | nick@chromium.org <nick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-13 23:21:26 +0000 |
---|---|---|
committer | nick@chromium.org <nick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-13 23:21:26 +0000 |
commit | c3f64b5090840a5124cb7c929af6eb8e95dbd592 (patch) | |
tree | 66b03de2e73c73f0f001b35d025d22482bf88efb | |
parent | a785dab62712680006d9152b584a280ef0b97fcd (diff) | |
download | chromium_src-c3f64b5090840a5124cb7c929af6eb8e95dbd592.zip chromium_src-c3f64b5090840a5124cb7c929af6eb8e95dbd592.tar.gz chromium_src-c3f64b5090840a5124cb7c929af6eb8e95dbd592.tar.bz2 |
[Reason for revert: broken the Linux build]
Revert 81502 - Panels: Fix where Browser::window_ is set. Fill in code to get work area.BUG=NoneTEST=NoneReview URL: http://codereview.chromium.org/6828003
TBR=jennb@chromium.org
Review URL: http://codereview.chromium.org/6850004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@81504 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/autofill/credit_card_unittest.cc | 10 | ||||
-rw-r--r-- | chrome/browser/ui/browser.cc | 46 | ||||
-rw-r--r-- | chrome/browser/ui/browser.h | 5 | ||||
-rw-r--r-- | chrome/browser/ui/panels/display_settings.h | 16 | ||||
-rw-r--r-- | chrome/browser/ui/panels/panel.h | 7 | ||||
-rw-r--r-- | chrome/browser/ui/panels/panel_manager.cc | 32 | ||||
-rw-r--r-- | chrome/browser/ui/panels/panel_manager.h | 10 | ||||
-rw-r--r-- | chrome/chrome_browser.gypi | 1 |
8 files changed, 76 insertions, 51 deletions
diff --git a/chrome/browser/autofill/credit_card_unittest.cc b/chrome/browser/autofill/credit_card_unittest.cc index 4dc167f..4ffc00f 100644 --- a/chrome/browser/autofill/credit_card_unittest.cc +++ b/chrome/browser/autofill/credit_card_unittest.cc @@ -134,13 +134,3 @@ TEST(CreditCardTest, SetInfoCreditCardNumber) { EXPECT_EQ(ASCIIToUTF16("4321-5432-6543-xxxx"), card.GetInfo(CREDIT_CARD_NUMBER)); } - -// Verify that we preserve exactly what the user typed for credit card numbers. -TEST(CreditCardTest, SetInfoCreditCardNumber) { - CreditCard card; - - autofill_test::SetCreditCardInfo(&card, "Bob Dylan", - "4321-5432-6543-xxxx", "07", "2013"); - EXPECT_EQ(ASCIIToUTF16("4321-5432-6543-xxxx"), - card.GetInfo(CREDIT_CARD_NUMBER)); -} diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc index 606c664..92c9edd 100644 --- a/chrome/browser/ui/browser.cc +++ b/chrome/browser/ui/browser.cc @@ -372,15 +372,32 @@ Browser* Browser::CreateForApp(const std::string& app_name, Browser::Type type = TYPE_APP; if (is_panel) { - if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnablePanels)) { - type = TYPE_APP_PANEL; - } else { - // TYPE_APP_PANEL is the logical choice. However, the panel UI - // is not fully implemented. See crbug/55943. - type = TYPE_APP_POPUP; - } + // TYPE_APP_PANEL is the logical choice. However, the panel UI + // is not fully implemented. See crbug/55943. + type = TYPE_APP_POPUP; + } + + Browser* browser = new Browser(type, profile); + browser->app_name_ = app_name; + + if (!window_size.IsEmpty()) { + gfx::Rect initial_pos(window_size); + browser->set_override_bounds(initial_pos); } + browser->InitBrowserWindow(); + + return browser; +} + +// static +Browser* Browser::CreateForPanel(const std::string& app_name, + const gfx::Size& window_size, + Profile* profile) { + // TODO(jianli): For now we just use TYPE_APP_PANEL to stand for the panel + // this is created from the extension when the specific command line flag + // is set. + Browser::Type type = TYPE_APP_PANEL; Browser* browser = new Browser(type, profile); browser->app_name_ = app_name; @@ -389,6 +406,7 @@ Browser* Browser::CreateForApp(const std::string& app_name, browser->set_override_bounds(initial_pos); } + browser->window_ = PanelManager::GetInstance()->Create(browser); browser->InitBrowserWindow(); return browser; @@ -574,9 +592,13 @@ TabContents* Browser::OpenApplicationWindow( window_size.SetSize(extension->launch_width(), extension->launch_height()); - Browser* browser = Browser::CreateForApp(app_name, window_size, profile, - as_panel); - + Browser* browser; + if (as_panel && + CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnablePanels)) { + browser = Browser::CreateForPanel(app_name, window_size, profile); + } else { + browser = Browser::CreateForApp(app_name, window_size, profile, as_panel); + } if (app_browser) *app_browser = browser; @@ -3538,10 +3560,6 @@ gfx::Rect Browser::GetInstantBounds() { // Browser, protected: BrowserWindow* Browser::CreateBrowserWindow() { - if (type() == Browser::TYPE_APP_PANEL && - CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnablePanels)) - return PanelManager::GetInstance()->CreatePanel(this); - return BrowserWindow::CreateBrowserWindow(this); } diff --git a/chrome/browser/ui/browser.h b/chrome/browser/ui/browser.h index 92dbae8..1959e3d 100644 --- a/chrome/browser/ui/browser.h +++ b/chrome/browser/ui/browser.h @@ -153,6 +153,11 @@ class Browser : public TabHandlerDelegate, Profile* profile, bool is_panel); + // Like Create, but creates a panel for extension application. + static Browser* CreateForPanel(const std::string& app_name, + const gfx::Size& window_size, + Profile* profile); + // Like Create, but creates a tabstrip-less and toolbar-less // DevTools "app" window. static Browser* CreateForDevTools(Profile* profile); diff --git a/chrome/browser/ui/panels/display_settings.h b/chrome/browser/ui/panels/display_settings.h new file mode 100644 index 0000000..5c79f83 --- /dev/null +++ b/chrome/browser/ui/panels/display_settings.h @@ -0,0 +1,16 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_UI_PANELS_DISPLAY_SETTINGS_H_ +#define CHROME_BROWSER_UI_PANELS_DISPLAY_SETTINGS_H_ +#pragma once + +namespace gfx { +class Rect; +} + +// TODO (jianli): to be implemented. +void GetMainScreenWorkArea(gfx::Rect* bounds) { } + +#endif // CHROME_BROWSER_UI_PANELS_DISPLAY_SETTINGS_H_ diff --git a/chrome/browser/ui/panels/panel.h b/chrome/browser/ui/panels/panel.h index e692af19..eda3ad6 100644 --- a/chrome/browser/ui/panels/panel.h +++ b/chrome/browser/ui/panels/panel.h @@ -25,6 +25,7 @@ class PanelManager; // other Panels. For example deleting a panel would rearrange other panels. class Panel : public BrowserWindow { public: + Panel(Browser* browser, const gfx::Rect& bounds); virtual ~Panel(); // Returns the PanelManager associated with this panel. @@ -132,15 +133,11 @@ class Panel : public BrowserWindow { virtual void DestroyBrowser(); private: - friend class PanelManager; - - // Panel can only be created using PanelManager::CreatePanel(). - Panel(Browser* browser, const gfx::Rect& bounds); - // Platform specifc BrowserWindow implementation for panels. It'd be one of // PanelBrowserWindowGtk/PanelBrowserView/PanelBrowserWindowCocoa. scoped_ptr<BrowserWindow> browser_window_; + // The bounds. gfx::Rect bounds_; // Is the panel minimized? diff --git a/chrome/browser/ui/panels/panel_manager.cc b/chrome/browser/ui/panels/panel_manager.cc index d78f84b..af63b35 100644 --- a/chrome/browser/ui/panels/panel_manager.cc +++ b/chrome/browser/ui/panels/panel_manager.cc @@ -8,8 +8,8 @@ #include "base/logging.h" #include "base/scoped_ptr.h" #include "chrome/browser/ui/browser.h" +#include "chrome/browser/ui/panels/display_settings.h" #include "chrome/browser/ui/panels/panel.h" -#include "chrome/browser/ui/window_sizer.h" namespace { // Invalid panel index. @@ -51,35 +51,32 @@ PanelManager::PanelManager() bottom_edge_y_(0), dragging_panel_index_(kInvalidPanelIndex), dragging_panel_original_x_(0) { - OnDisplayChanged(); + OnDisplaySettingsChanged(); } PanelManager::~PanelManager() { - DCHECK(active_panels_.empty()); - DCHECK(pending_panels_.empty()); - DCHECK(panels_pending_to_remove_.empty()); } -void PanelManager::OnDisplayChanged() { - scoped_ptr<WindowSizer::MonitorInfoProvider> info_provider( - WindowSizer::CreateDefaultMonitorInfoProvider()); - gfx::Rect work_area = info_provider->GetPrimaryMonitorWorkArea(); +void PanelManager::OnDisplaySettingsChanged() { + gfx::Rect work_area; + GetMainScreenWorkArea(&work_area); min_x_ = work_area.x(); current_x_ = work_area.right(); bottom_edge_y_ = work_area.bottom(); + max_width_ = static_cast<int>(work_area.width() * kPanelMaxWidthFactor); max_height_ = static_cast<int>(work_area.height() * kPanelMaxHeightFactor); Rearrange(active_panels_.begin()); } -Panel* PanelManager::CreatePanel(Browser* browser) { +Panel* PanelManager::Create(Browser* browser) { gfx::Rect bounds = browser->override_bounds(); - bool is_within_bounds = ComputeBoundsForNextPanel(&bounds, true); + bool success = ComputeBoundsForNextPanel(&bounds, true); Panel* panel = new Panel(browser, bounds); - if (is_within_bounds) + if (success) active_panels_.push_back(panel); else pending_panels_.push_back(panel); @@ -91,11 +88,12 @@ void PanelManager::ProcessPending() { while (!pending_panels_.empty()) { Panel* panel = pending_panels_.front(); gfx::Rect bounds = panel->bounds(); - if (ComputeBoundsForNextPanel(&bounds, true)) { - // TODO(jianli): More work to support displaying pending panels. - active_panels_.push_back(panel); - pending_panels_.pop_front(); - } + bool success = ComputeBoundsForNextPanel(&bounds, true); + if (!success) + return; + // TODO(jianli): More work to be done to support displaying pending panels. + active_panels_.push_back(panel); + pending_panels_.pop_front(); } } diff --git a/chrome/browser/ui/panels/panel_manager.h b/chrome/browser/ui/panels/panel_manager.h index a209904..79689ec 100644 --- a/chrome/browser/ui/panels/panel_manager.h +++ b/chrome/browser/ui/panels/panel_manager.h @@ -23,12 +23,12 @@ class PanelManager { ~PanelManager(); - // Called when the display is changed, i.e. work area is updated. - void OnDisplayChanged(); + // Called when the display settings are changed, i.e. work area is updated. + void OnDisplaySettingsChanged(); // Creates a panel and returns it. The panel might be queued for display // later. - Panel* CreatePanel(Browser* browser); + Panel* Create(Browser* browser); // Removes the given panel. Both active and pending panel lists are checked. // If an active panel is removed, pending panels could put on display if we @@ -79,8 +79,8 @@ class PanelManager { // Computes the bounds for next panel. // |allow_size_change| is used to indicate if the panel size can be changed to - // fall within the size constraint, e.g., when the panel is created. - // Returns true if computed bounds are within the displayable area. + // fall within the size constraint. This is the case we add the panel for the + // first time. bool ComputeBoundsForNextPanel(gfx::Rect* bounds, bool allow_size_change); // Help functions to drag the given panel. diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index d556b9d..fb1da4f 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -2743,6 +2743,7 @@ 'browser/ui/options/options_window.h', 'browser/ui/options/show_options_url.cc', 'browser/ui/options/show_options_url.h', + 'browser/ui/panels/display_settings.h', 'browser/ui/panels/panel.cc', 'browser/ui/panels/panel.h', 'browser/ui/panels/panel_manager.cc', |