diff options
-rw-r--r-- | chrome/browser/ui/DEPS | 2 | ||||
-rw-r--r-- | chrome/browser/ui/ash/app_list/search_builder.cc | 2 | ||||
-rw-r--r-- | chrome/browser/ui/ash/ash_init.cc | 1 | ||||
-rw-r--r-- | chrome/browser/ui/views/ash/balloon_view_ash.cc | 2 | ||||
-rw-r--r-- | chrome/browser/ui/views/ash/chrome_shell_delegate.cc | 4 | ||||
-rw-r--r-- | chrome/browser/ui/views/ash/user_action_handler.cc | 54 | ||||
-rw-r--r-- | chrome/browser/ui/views/ash/user_action_handler.h | 25 | ||||
-rw-r--r-- | chrome/browser/ui/views/ash/window_positioner.cc | 190 | ||||
-rw-r--r-- | chrome/browser/ui/views/ash/window_positioner.h | 64 | ||||
-rw-r--r-- | chrome/browser/ui/views/ash/window_positioner_unittest.cc | 331 | ||||
-rw-r--r-- | chrome/browser/ui/views/constrained_window_views.cc | 2 | ||||
-rw-r--r-- | chrome/browser/ui/views/search_view_controller.cc | 2 | ||||
-rw-r--r-- | chrome/browser/ui/views/select_file_dialog_extension_unittest.cc | 2 |
13 files changed, 8 insertions, 673 deletions
diff --git a/chrome/browser/ui/DEPS b/chrome/browser/ui/DEPS index 1348d32..40399a6 100644 --- a/chrome/browser/ui/DEPS +++ b/chrome/browser/ui/DEPS @@ -4,8 +4,6 @@ include_rules = [ # DO NOT ADD ANY MORE ITEMS TO THE LIST BELOW! "!chrome/browser/ui/views/ash/chrome_shell_delegate.h", "!chrome/browser/ui/views/ash/panel_view_aura.h", - "!chrome/browser/ui/views/ash/user_action_handler.h", - "!chrome/browser/ui/views/ash/window_positioner.h", "!chrome/browser/ui/views/find_bar_host.h", "!chrome/browser/ui/views/frame/browser_frame.h", "!chrome/browser/ui/views/frame/browser_view.h", diff --git a/chrome/browser/ui/ash/app_list/search_builder.cc b/chrome/browser/ui/ash/app_list/search_builder.cc index 659fa36..11b84b8 100644 --- a/chrome/browser/ui/ash/app_list/search_builder.cc +++ b/chrome/browser/ui/ash/app_list/search_builder.cc @@ -23,8 +23,8 @@ #include "chrome/common/extensions/extension.h" #include "chrome/common/extensions/extension_icon_set.h" #include "chrome/common/url_constants.h" -#include "content/public/browser/web_contents.h" #include "content/public/browser/user_metrics.h" +#include "content/public/browser/web_contents.h" #include "grit/generated_resources.h" #include "grit/theme_resources.h" #include "ui/app_list/app_list_switches.h" diff --git a/chrome/browser/ui/ash/ash_init.cc b/chrome/browser/ui/ash/ash_init.cc index dafb875..e40d9a3 100644 --- a/chrome/browser/ui/ash/ash_init.cc +++ b/chrome/browser/ui/ash/ash_init.cc @@ -32,6 +32,7 @@ #include "chrome/browser/ui/ash/brightness_controller_chromeos.h" #include "chrome/browser/ui/ash/ime_controller_chromeos.h" #include "chrome/browser/ui/ash/keyboard_brightness_controller_chromeos.h" +#include "chrome/browser/ui/ash/volume_controller_chromeos.h" #endif diff --git a/chrome/browser/ui/views/ash/balloon_view_ash.cc b/chrome/browser/ui/views/ash/balloon_view_ash.cc index 7ceed74..649bcb1 100644 --- a/chrome/browser/ui/views/ash/balloon_view_ash.cc +++ b/chrome/browser/ui/views/ash/balloon_view_ash.cc @@ -8,8 +8,8 @@ #include "ash/system/status_area_widget.h" #include "ash/system/web_notification/web_notification_tray.h" #include "base/logging.h" -#include "chrome/browser/favicon/favicon_util.h" #include "chrome/browser/extensions/extension_service.h" +#include "chrome/browser/favicon/favicon_util.h" #include "chrome/browser/notifications/balloon_collection.h" #include "chrome/browser/notifications/notification.h" #include "chrome/browser/profiles/profile.h" diff --git a/chrome/browser/ui/views/ash/chrome_shell_delegate.cc b/chrome/browser/ui/views/ash/chrome_shell_delegate.cc index 4ea9c4c..0ff7d1d 100644 --- a/chrome/browser/ui/views/ash/chrome_shell_delegate.cc +++ b/chrome/browser/ui/views/ash/chrome_shell_delegate.cc @@ -16,11 +16,11 @@ #include "chrome/browser/sessions/tab_restore_service_factory.h" #include "chrome/browser/ui/ash/app_list/app_list_view_delegate.h" #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" +#include "chrome/browser/ui/ash/user_action_handler.h" +#include "chrome/browser/ui/ash/window_positioner.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_commands.h" #include "chrome/browser/ui/browser_finder.h" -#include "chrome/browser/ui/ash/user_action_handler.h" -#include "chrome/browser/ui/ash/window_positioner.h" #include "chrome/browser/ui/views/frame/browser_view.h" #include "chrome/browser/ui/webui/chrome_web_contents_handler.h" #include "chrome/common/chrome_notification_types.h" diff --git a/chrome/browser/ui/views/ash/user_action_handler.cc b/chrome/browser/ui/views/ash/user_action_handler.cc deleted file mode 100644 index ce1daa2..0000000 --- a/chrome/browser/ui/views/ash/user_action_handler.cc +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright (c) 2012 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. - -#include "chrome/browser/ui/views/ash/user_action_handler.h" - -#include "ash/wm/window_util.h" -#include "chrome/browser/ui/browser.h" -#include "chrome/browser/ui/browser_list.h" -#include "chrome/browser/ui/browser_tabstrip.h" -#include "chrome/browser/ui/browser_window.h" -#include "chrome/browser/ui/tab_contents/tab_contents.h" -#include "content/public/browser/web_contents.h" - -// Returns the currently-active WebContents belonging to the active browser, or -// NULL if there's no currently-active browser. -content::WebContents* GetActiveWebContents() { - Browser* browser = BrowserList::GetLastActive(); - if (!browser) - return NULL; - if (!ash::wm::IsActiveWindow(browser->window()->GetNativeWindow())) - return NULL; - - return chrome::GetActiveWebContents(browser); -} - -UserActionHandler::UserActionHandler() {} - -UserActionHandler::~UserActionHandler() {} - -bool UserActionHandler::OnUserAction( - aura::client::UserActionClient::Command command) { - switch (command) { - case aura::client::UserActionClient::BACK: { - content::WebContents* contents = GetActiveWebContents(); - if (contents && contents->GetController().CanGoBack()) { - contents->GetController().GoBack(); - return true; - } - break; - } - case aura::client::UserActionClient::FORWARD: { - content::WebContents* contents = GetActiveWebContents(); - if (contents && contents->GetController().CanGoForward()) { - contents->GetController().GoForward(); - return true; - } - break; - } - default: - break; - } - return false; -} diff --git a/chrome/browser/ui/views/ash/user_action_handler.h b/chrome/browser/ui/views/ash/user_action_handler.h deleted file mode 100644 index aa826f5..0000000 --- a/chrome/browser/ui/views/ash/user_action_handler.h +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (c) 2012 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_VIEWS_ASH_USER_ACTION_HANDLER_H_ -#define CHROME_BROWSER_UI_VIEWS_ASH_USER_ACTION_HANDLER_H_ - -#include "base/basictypes.h" -#include "base/compiler_specific.h" -#include "ui/aura/client/user_action_client.h" - -class UserActionHandler : public aura::client::UserActionClient { - public: - UserActionHandler(); - virtual ~UserActionHandler(); - - // aura::client::UserActionClient overrides: - virtual bool OnUserAction( - aura::client::UserActionClient::Command command) OVERRIDE; - - private: - DISALLOW_COPY_AND_ASSIGN(UserActionHandler); -}; - -#endif // CHROME_BROWSER_UI_VIEWS_ASH_USER_ACTION_HANDLER_H_ diff --git a/chrome/browser/ui/views/ash/window_positioner.cc b/chrome/browser/ui/views/ash/window_positioner.cc deleted file mode 100644 index 1e1e8e2..0000000 --- a/chrome/browser/ui/views/ash/window_positioner.cc +++ /dev/null @@ -1,190 +0,0 @@ -// Copyright (c) 2012 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. - -#include "chrome/browser/ui/views/ash/window_positioner.h" - -#include "ash/shell.h" -#include "ash/wm/window_cycle_controller.h" -#include "ash/wm/window_resizer.h" -#include "ash/wm/window_util.h" -#include "ui/aura/window.h" -#include "ui/aura/window_delegate.h" -#include "ui/compositor/layer.h" -#include "ui/gfx/screen.h" - -WindowPositioner::WindowPositioner() - : pop_position_offset_increment_x(0), - pop_position_offset_increment_y(0), - popup_position_offset_from_screen_corner_x(0), - popup_position_offset_from_screen_corner_y(0), - last_popup_position_x_(0), - last_popup_position_y_(0) { -} - -WindowPositioner::~WindowPositioner() { -} - -gfx::Rect WindowPositioner::GetPopupPosition(const gfx::Rect& old_pos) { - int grid = ash::Shell::GetInstance()->GetGridSize(); - // Make sure that the grid has a minimum resolution of 10 pixels. - if (!grid) { - grid = 10; - } else { - while (grid < 10) - grid *= 2; - } - popup_position_offset_from_screen_corner_x = grid; - popup_position_offset_from_screen_corner_y = grid; - if (!pop_position_offset_increment_x) { - // When the popup position increment is , the last popup position - // was not yet initialized. - last_popup_position_x_ = popup_position_offset_from_screen_corner_x; - last_popup_position_y_ = popup_position_offset_from_screen_corner_y; - } - pop_position_offset_increment_x = grid; - pop_position_offset_increment_y = grid; - // We handle the Multi monitor support by retrieving the active window's - // work area. - aura::Window* window = ash::wm::GetActiveWindow(); - const gfx::Rect work_area = window && window->IsVisible() ? - gfx::Screen::GetDisplayNearestWindow(window).work_area() : - gfx::Screen::GetPrimaryDisplay().work_area(); - // Only try to reposition the popup when it is not spanning the entire - // screen. - if ((old_pos.width() + popup_position_offset_from_screen_corner_x >= - work_area.width()) || - (old_pos.height() + popup_position_offset_from_screen_corner_y >= - work_area.height())) - return AlignPopupPosition(old_pos, work_area, grid); - const gfx::Rect result = SmartPopupPosition(old_pos, work_area, grid); - if (!result.IsEmpty()) - return AlignPopupPosition(result, work_area, grid); - return NormalPopupPosition(old_pos, work_area); -} - -gfx::Rect WindowPositioner::NormalPopupPosition( - const gfx::Rect& old_pos, - const gfx::Rect& work_area) { - int w = old_pos.width(); - int h = old_pos.height(); - // Note: The 'last_popup_position' is checked and kept relative to the - // screen size. The offsetting will be done in the last step when the - // target rectangle gets returned. - bool reset = false; - if (last_popup_position_y_ + h > work_area.height() || - last_popup_position_x_ + w > work_area.width()) { - // Popup does not fit on screen. Reset to next diagonal row. - last_popup_position_x_ -= last_popup_position_y_ - - popup_position_offset_from_screen_corner_x - - pop_position_offset_increment_x; - last_popup_position_y_ = popup_position_offset_from_screen_corner_y; - reset = true; - } - if (last_popup_position_x_ + w > work_area.width()) { - // Start again over. - last_popup_position_x_ = popup_position_offset_from_screen_corner_x; - last_popup_position_y_ = popup_position_offset_from_screen_corner_y; - reset = true; - } - int x = last_popup_position_x_; - int y = last_popup_position_y_; - if (!reset) { - last_popup_position_x_ += pop_position_offset_increment_x; - last_popup_position_y_ += pop_position_offset_increment_y; - } - return gfx::Rect(x + work_area.x(), y + work_area.y(), w, h); -} - -gfx::Rect WindowPositioner::SmartPopupPosition( - const gfx::Rect& old_pos, - const gfx::Rect& work_area, - int grid) { - const std::vector<aura::Window*> windows = - ash::WindowCycleController::BuildWindowList(NULL); - - std::vector<const gfx::Rect*> regions; - // Process the window list and check if we can bail immediately. - for (size_t i = 0; i < windows.size(); i++) { - // We only include opaque and visible windows. - if (windows[i] && windows[i]->IsVisible() && windows[i]->layer() && - (!windows[i]->transparent() || - windows[i]->layer()->GetTargetOpacity() == 1.0)) { - // When any window is maximized we cannot find any free space. - if (ash::wm::IsWindowMaximized(windows[i]) || - ash::wm::IsWindowFullscreen(windows[i])) - return gfx::Rect(0, 0, 0, 0); - if (ash::wm::IsWindowNormal(windows[i])) - regions.push_back(&windows[i]->bounds()); - } - } - - if (regions.empty()) - return gfx::Rect(0, 0, 0, 0); - - int w = old_pos.width(); - int h = old_pos.height(); - int x_end = work_area.width() / 2; - int x, x_increment; - // We parse for a proper location on the screen. We do this in two runs: - // The first run will start from the left, parsing down, skipping any - // overlapping windows it will encounter until the popup's height can not - // be served anymore. Then the next grid position to the right will be - // taken, and the same cycle starts again. This will be repeated until we - // hit the middle of the screen (or we find a suitable location). - // In the second run we parse beginning from the right corner downwards and - // then to the left. - // When no location was found, an empty rectangle will be returned. - for (int run = 0; run < 2; run++) { - if (run == 0) { // First run: Start left, parse right till mid screen. - x = 0; - x_increment = pop_position_offset_increment_x; - } else { // Second run: Start right, parse left till mid screen. - x = work_area.width() - w; - x_increment = -pop_position_offset_increment_x; - } - // Note: The passing (x,y,w,h) window is always relative to the work area's - // origin. - for (; x_increment > 0 ? (x < x_end) : (x > x_end); x += x_increment) { - int y = 0; - while (y + h <= work_area.height()) { - size_t i; - for (i = 0; i < regions.size(); i++) { - if (regions[i]->Intersects(gfx::Rect(x + work_area.x(), - y + work_area.y(), w, h))) { - y = regions[i]->bottom() - work_area.y(); - if (grid > 1) { - // Align to the (next) grid step. - y = ash::WindowResizer::AlignToGridRoundUp(y, grid); - } - break; - } - } - if (i >= regions.size()) - return gfx::Rect(x + work_area.x(), y + work_area.y(), w, h); - } - } - } - return gfx::Rect(0, 0, 0, 0); -} - -gfx::Rect WindowPositioner::AlignPopupPosition( - const gfx::Rect& pos, - const gfx::Rect& work_area, - int grid) { - if (grid <= 1) - return pos; - - int x = pos.x() - (pos.x() - work_area.x()) % grid; - int y = pos.y() - (pos.y() - work_area.y()) % grid; - int w = pos.width(); - int h = pos.height(); - - // If the alignment was pushing the window out of the screen, we ignore the - // alignment for that call. - if (abs(pos.right() - work_area.right()) < grid) - x = work_area.right() - w; - if (abs(pos.bottom() - work_area.bottom()) < grid) - y = work_area.bottom() - h; - return gfx::Rect(x, y, w, h); -} diff --git a/chrome/browser/ui/views/ash/window_positioner.h b/chrome/browser/ui/views/ash/window_positioner.h deleted file mode 100644 index 06551e0..0000000 --- a/chrome/browser/ui/views/ash/window_positioner.h +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright (c) 2012 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_VIEWS_ASH_WINDOW_POSITIONER_H_ -#define CHROME_BROWSER_UI_VIEWS_ASH_WINDOW_POSITIONER_H_ - -#include "base/basictypes.h" -#include "ui/gfx/rect.h" - -namespace aura { -class Window; -} - -// WindowPositioner is used by the browser to move new popups automatically to -// a usable position on the closest work area (of the active window). -class WindowPositioner { - public: - WindowPositioner(); - ~WindowPositioner(); - - // Find a suitable screen position for a popup window and return it. The - // passed input position is only used to retrieve the width and height. - // The position is determined on the left / right / top / bottom first. If - // no smart space is found, the position will follow the standard what other - // operating systems do (default cascading style). - gfx::Rect GetPopupPosition(const gfx::Rect& old_pos); - - protected: - // Find a smart way to position the popup window. If there is no space this - // function will return an empty rectangle. - gfx::Rect SmartPopupPosition(const gfx::Rect& old_pos, - const gfx::Rect& work_area, - int grid); - - // Find the next available cascading popup position (on the given screen). - gfx::Rect NormalPopupPosition(const gfx::Rect& old_pos, - const gfx::Rect& work_area); - - // Align the location to the grid / snap to the right / bottom corner. - gfx::Rect AlignPopupPosition(const gfx::Rect &pos, - const gfx::Rect &work_area, - int grid); - - // Constants to identify the type of resize. - static const int kBoundsChange_None; - - // The offset in X and Y for the next popup which opens. - int pop_position_offset_increment_x; - int pop_position_offset_increment_y; - - // The position on the screen for the first popup which gets shown if no - // empty space can be found. - int popup_position_offset_from_screen_corner_x; - int popup_position_offset_from_screen_corner_y; - - // The last used position. - int last_popup_position_x_; - int last_popup_position_y_; - - DISALLOW_COPY_AND_ASSIGN(WindowPositioner); -}; - -#endif // CHROME_BROWSER_UI_VIEWS_ASH_WINDOW_POSITIONER_H_ diff --git a/chrome/browser/ui/views/ash/window_positioner_unittest.cc b/chrome/browser/ui/views/ash/window_positioner_unittest.cc deleted file mode 100644 index 33ed6b7..0000000 --- a/chrome/browser/ui/views/ash/window_positioner_unittest.cc +++ /dev/null @@ -1,331 +0,0 @@ -// Copyright (c) 2012 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. - -#include "chrome/browser/ui/views/ash/window_positioner.h" - -#include "ash/shell.h" -#include "ash/shell_window_ids.h" -#include "ash/test/ash_test_base.h" -#include "ash/test/test_shell_delegate.h" -#include "ash/wm/window_resizer.h" -#include "base/compiler_specific.h" -#include "base/logging.h" -#include "chrome/browser/ui/browser.h" -#include "chrome/test/base/test_browser_window.h" -#include "chrome/test/base/testing_profile.h" -#include "content/public/browser/browser_thread.h" -#include "content/public/test/render_view_test.h" -#include "content/public/test/test_browser_thread.h" -#include "testing/gtest/include/gtest/gtest.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" -#include "ui/aura/env.h" -#include "ui/aura/root_window.h" -#include "ui/aura/test/test_windows.h" -#include "ui/gfx/screen.h" - -namespace ash { -namespace test { - -namespace { - -// A browser window proxy which is able to associate an aura native window with -// it. -class TestBrowserWindowAura : public TestBrowserWindow { - public: - explicit TestBrowserWindowAura(aura::Window *native_window); - virtual ~TestBrowserWindowAura(); - - virtual gfx::NativeWindow GetNativeWindow() OVERRIDE { - return native_window_; - } - - private: - gfx::NativeWindow native_window_; - - DISALLOW_COPY_AND_ASSIGN(TestBrowserWindowAura); -}; - -TestBrowserWindowAura::TestBrowserWindowAura(aura::Window *native_window) - : native_window_(native_window) { -} - -TestBrowserWindowAura::~TestBrowserWindowAura() {} - -// A test class for preparing window positioner tests - it creates a testing -// base by adding a window, a popup and a panel which can be independently -// positioned to see where the positioner will place the window. -class WindowPositionerTest : public AshTestBase { - public: - WindowPositionerTest(); - ~WindowPositionerTest(); - - virtual void SetUp() OVERRIDE; - virtual void TearDown() OVERRIDE; - - protected: - aura::Window* window() { return window_.get(); } - aura::Window* popup() { return popup_.get(); } - aura::Window* panel() { return panel_.get(); } - - Browser* window_browser() { return window_owning_browser_.get(); } - Browser* popup_browser() { return popup_owning_browser_.get(); } - Browser* panel_browser() { return panel_owning_browser_.get(); } - - WindowPositioner* window_positioner() { return window_positioner_; } - - // The positioner & desktop's used grid alignment size. - int grid_size_; - - private: - WindowPositioner* window_positioner_; - - // These two need to be deleted after everything else is gone. - scoped_ptr<content::TestBrowserThread> ui_thread_; - scoped_ptr<TestingProfile> profile_; - - // These get created for each session. - scoped_ptr<aura::Window> window_; - scoped_ptr<aura::Window> popup_; - scoped_ptr<aura::Window> panel_; - - scoped_ptr<BrowserWindow> browser_window_; - scoped_ptr<BrowserWindow> browser_popup_; - scoped_ptr<BrowserWindow> browser_panel_; - - scoped_ptr<Browser> window_owning_browser_; - scoped_ptr<Browser> popup_owning_browser_; - scoped_ptr<Browser> panel_owning_browser_; - - DISALLOW_COPY_AND_ASSIGN(WindowPositionerTest); -}; - -WindowPositionerTest::WindowPositionerTest() - : window_positioner_(NULL) { - // Create a message loop. - MessageLoopForUI* ui_loop = message_loop(); - ui_thread_.reset( - new content::TestBrowserThread(content::BrowserThread::UI, ui_loop)); - - // Create a browser profile. - profile_.reset(new TestingProfile()); -} - -WindowPositionerTest::~WindowPositionerTest() { - profile_.reset(NULL); - ui_thread_.reset(NULL); -} - -void WindowPositionerTest::SetUp() { - AshTestBase::SetUp(); - // Create some default dummy windows. - aura::Window* default_container = ash::Shell::GetContainer( - ash::Shell::GetPrimaryRootWindow(), - ash::internal::kShellWindowId_DefaultContainer); - window_.reset(aura::test::CreateTestWindowWithId(0, default_container)); - window_->SetBounds(gfx::Rect(16, 32, 640, 320)); - popup_.reset(aura::test::CreateTestWindowWithId(1, default_container)); - popup_->SetBounds(gfx::Rect(16, 32, 128, 256)); - panel_.reset(aura::test::CreateTestWindowWithId(2, default_container)); - panel_->SetBounds(gfx::Rect(32, 48, 256, 512)); - - // Create a browser for the window. - browser_window_.reset(new TestBrowserWindowAura(window_.get())); - Browser::CreateParams window_params(profile_.get()); - window_params.window = browser_window_.get(); - window_owning_browser_.reset(new Browser(window_params)); - - // Creating a browser for the popup. - browser_popup_.reset(new TestBrowserWindowAura(popup_.get())); - Browser::CreateParams popup_params(Browser::TYPE_POPUP, profile_.get()); - popup_params.window = browser_popup_.get(); - popup_owning_browser_.reset(new Browser(popup_params)); - - // Creating a browser for the panel. - browser_panel_.reset(new TestBrowserWindowAura(panel_.get())); - Browser::CreateParams panel_params(Browser::TYPE_PANEL, profile_.get()); - panel_params.window = browser_panel_.get(); - panel_owning_browser_.reset(new Browser(panel_params)); - // We hide all windows upon start - each user is required to set it up - // as he needs it. - window()->Hide(); - popup()->Hide(); - panel()->Hide(); - window_positioner_ = new WindowPositioner(); - - // Get the alignment size. - grid_size_ = ash::Shell::GetInstance()->GetGridSize(); - if (!grid_size_) { - grid_size_ = 10; - } else { - while (grid_size_ < 10) - grid_size_ *= 2; - } -} - -void WindowPositionerTest::TearDown() { - // Since the AuraTestBase is needed to create our assets, we have to - // also delete them before we tear it down. - window_owning_browser_.reset(NULL); - popup_owning_browser_.reset(NULL); - panel_owning_browser_.reset(NULL); - - browser_window_.reset(NULL); - browser_popup_.reset(NULL); - browser_panel_.reset(NULL); - - window_.reset(NULL); - popup_.reset(NULL); - panel_.reset(NULL); - - AshTestBase::TearDown(); - delete window_positioner_; - window_positioner_ = NULL; -} - -} // namespace - -TEST_F(WindowPositionerTest, cascading) { - const gfx::Rect work_area = gfx::Screen::GetPrimaryDisplay().work_area(); - - // First see that the window will cascade down when there is no space. - window()->SetBounds(work_area); - window()->Show(); - - gfx::Rect popup_position(0, 0, 200, 200); - // Check that it gets cascaded. - gfx::Rect cascade_1 = window_positioner()->GetPopupPosition(popup_position); - EXPECT_EQ(gfx::Rect(work_area.x() + grid_size_, work_area.y() + grid_size_, - popup_position.width(), popup_position.height()), - cascade_1); - - gfx::Rect cascade_2 = window_positioner()->GetPopupPosition(popup_position); - EXPECT_EQ(gfx::Rect(work_area.x() + 2 * grid_size_, - work_area.y() + 2 * grid_size_, - popup_position.width(), popup_position.height()), - cascade_2); - - // Check that if there is even only a pixel missing it will cascade. - window()->SetBounds(gfx::Rect(work_area.x() + popup_position.width() - 1, - work_area.y() + popup_position.height() - 1, - work_area.width() - - 2 * (popup_position.width() - 1), - work_area.height() - - 2 * (popup_position.height() - 1))); - - gfx::Rect cascade_3 = window_positioner()->GetPopupPosition(popup_position); - EXPECT_EQ(gfx::Rect(work_area.x() + 3 * grid_size_, - work_area.y() + 3 * grid_size_, - popup_position.width(), popup_position.height()), - cascade_3); - - // Check that we overflow into the next line when we do not fit anymore in Y. - gfx::Rect popup_position_4(0, 0, 200, - work_area.height() - - (cascade_3.y() - work_area.y())); - gfx::Rect cascade_4 = - window_positioner()->GetPopupPosition(popup_position_4); - EXPECT_EQ(gfx::Rect(work_area.x() + 2 * grid_size_, - work_area.y() + grid_size_, - popup_position_4.width(), popup_position_4.height()), - cascade_4); - - // Check that we overflow back to the first possible location if we overflow - // to the end. - gfx::Rect popup_position_5(0, 0, - work_area.width() + 1 - - (cascade_4.x() - work_area.x()), - work_area.height() - - (2 * grid_size_ - work_area.y())); - gfx::Rect cascade_5 = - window_positioner()->GetPopupPosition(popup_position_5); - EXPECT_EQ(gfx::Rect(work_area.x() + grid_size_, - work_area.y() + grid_size_, - popup_position_5.width(), popup_position_5.height()), - cascade_5); -} - -TEST_F(WindowPositionerTest, filling) { - const gfx::Rect work_area = gfx::Screen::GetPrimaryDisplay().work_area(); - int grid = ash::Shell::GetInstance()->GetGridSize(); - gfx::Rect popup_position(0, 0, 256, 128); - // Leave space on the left and the right and see if we fill top to bottom. - window()->SetBounds(gfx::Rect(work_area.x() + popup_position.width(), - work_area.y(), - work_area.width() - 2 * popup_position.width(), - work_area.height())); - window()->Show(); - // Check that we are positioned in the top left corner. - gfx::Rect top_left = window_positioner()->GetPopupPosition(popup_position); - EXPECT_EQ(gfx::Rect(work_area.x(), work_area.y(), - popup_position.width(), popup_position.height()), - top_left); - - // Now block the found location. - popup()->SetBounds(top_left); - popup()->Show(); - gfx::Rect mid_left = window_positioner()->GetPopupPosition(popup_position); - EXPECT_EQ(gfx::Rect(work_area.x(), - ash::WindowResizer::AlignToGridRoundDown( - work_area.y() + top_left.height(), grid), - popup_position.width(), popup_position.height()), - mid_left); - - // Block now everything so that we can only put the popup on the bottom - // of the left side. - // Note: We need to keep one "grid spacing free" if the window does not - // fit into the grid (which is true for 200 height).` - popup()->SetBounds(gfx::Rect(work_area.x(), work_area.y(), - popup_position.width(), - work_area.height() - popup_position.height() - - grid + 1)); - gfx::Rect bottom_left = window_positioner()->GetPopupPosition( - popup_position); - EXPECT_EQ(gfx::Rect(work_area.x(), - work_area.bottom() - popup_position.height(), - popup_position.width(), popup_position.height()), - bottom_left); - - // Block now enough to force the right side. - popup()->SetBounds(gfx::Rect(work_area.x(), work_area.y(), - popup_position.width(), - work_area.height() - popup_position.height() + - 1)); - gfx::Rect top_right = window_positioner()->GetPopupPosition( - popup_position); - EXPECT_EQ(gfx::Rect(ash::WindowResizer::AlignToGridRoundDown( - work_area.right() - popup_position.width(), grid), - work_area.y(), - popup_position.width(), popup_position.height()), - top_right); -} - -TEST_F(WindowPositionerTest, blockedByPanel) { - const gfx::Rect work_area = gfx::Screen::GetPrimaryDisplay().work_area(); - - gfx::Rect pop_position(0, 0, 200, 200); - // Let the panel cover everything. - panel()->SetBounds(work_area); - panel()->Show(); - - // Check that the popup does cascade due to the panel's existence. - gfx::Rect top_right = window_positioner()->GetPopupPosition(pop_position); - EXPECT_EQ(gfx::Rect(work_area.x() + grid_size_, work_area.y() + grid_size_, - pop_position.width(), pop_position.height()), - top_right); -} - -TEST_F(WindowPositionerTest, biggerThenBorder) { - const gfx::Rect work_area = gfx::Screen::GetPrimaryDisplay().work_area(); - - gfx::Rect pop_position(0, 0, work_area.width(), work_area.height()); - - // Check that the popup is placed full screen. - gfx::Rect full = window_positioner()->GetPopupPosition(pop_position); - EXPECT_EQ(gfx::Rect(work_area.x(), work_area.y(), - pop_position.width(), pop_position.height()), - full); -} - -} // namespace test -} // namespace ash diff --git a/chrome/browser/ui/views/constrained_window_views.cc b/chrome/browser/ui/views/constrained_window_views.cc index 964b3b9..91269ee 100644 --- a/chrome/browser/ui/views/constrained_window_views.cc +++ b/chrome/browser/ui/views/constrained_window_views.cc @@ -17,8 +17,8 @@ #include "chrome/browser/ui/views/constrained_window_frame_simple.h" #include "chrome/browser/ui/views/frame/browser_view.h" #include "chrome/common/chrome_constants.h" -#include "chrome/common/chrome_switches.h" #include "chrome/common/chrome_notification_types.h" +#include "chrome/common/chrome_switches.h" #include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents_view.h" #include "grit/chromium_strings.h" diff --git a/chrome/browser/ui/views/search_view_controller.cc b/chrome/browser/ui/views/search_view_controller.cc index a0502d8..118d301 100644 --- a/chrome/browser/ui/views/search_view_controller.cc +++ b/chrome/browser/ui/views/search_view_controller.cc @@ -14,9 +14,9 @@ #include "chrome/browser/ui/webui/instant_ui.h" #include "chrome/common/url_constants.h" #include "grit/theme_resources.h" +#include "ui/base/resource/resource_bundle.h" #include "ui/compositor/layer.h" #include "ui/compositor/scoped_layer_animation_settings.h" -#include "ui/base/resource/resource_bundle.h" #include "ui/gfx/canvas.h" #include "ui/views/controls/webview/webview.h" #include "ui/views/layout/fill_layout.h" diff --git a/chrome/browser/ui/views/select_file_dialog_extension_unittest.cc b/chrome/browser/ui/views/select_file_dialog_extension_unittest.cc index 70809b6..906a6ca 100644 --- a/chrome/browser/ui/views/select_file_dialog_extension_unittest.cc +++ b/chrome/browser/ui/views/select_file_dialog_extension_unittest.cc @@ -5,8 +5,8 @@ #include "chrome/browser/ui/views/select_file_dialog_extension.h" #include "base/file_path.h" -#include "ui/base/dialogs/selected_file_info.h" #include "testing/gtest/include/gtest/gtest.h" +#include "ui/base/dialogs/selected_file_info.h" class SelectFileDialogExtensionTest : public testing::Test { public: |