diff options
152 files changed, 385 insertions, 648 deletions
diff --git a/ash/display/display_manager.cc b/ash/display/display_manager.cc index 2ec5afb..f46fff7 100644 --- a/ash/display/display_manager.cc +++ b/ash/display/display_manager.cc @@ -145,15 +145,11 @@ DisplayManager::DisplayManager() unified_desktop_enabled_ = base::CommandLine::ForCurrentProcess()->HasSwitch( switches::kAshEnableUnifiedDesktop); #endif - gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_ALTERNATE, screen_.get()); - gfx::Screen* current_native = - gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_NATIVE); + gfx::Screen* current = gfx::Screen::GetScreen(); // If there is no native, or the native was for shutdown, // use ash's screen. - if (!current_native || - current_native == screen_for_shutdown) { - gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, screen_.get()); - } + if (!current || current == screen_for_shutdown) + gfx::Screen::SetScreenInstance(screen_.get()); } DisplayManager::~DisplayManager() { @@ -1068,16 +1064,9 @@ scoped_ptr<MouseWarpController> DisplayManager::CreateMouseWarpController( } void DisplayManager::CreateScreenForShutdown() const { - bool native_is_ash = - gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_NATIVE) == screen_.get(); delete screen_for_shutdown; screen_for_shutdown = screen_->CloneForShutdown(); - gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_ALTERNATE, - screen_for_shutdown); - if (native_is_ash) { - gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, - screen_for_shutdown); - } + gfx::Screen::SetScreenInstance(screen_for_shutdown); } void DisplayManager::UpdateInternalDisplayModeListForTest() { diff --git a/ash/display/display_manager_unittest.cc b/ash/display/display_manager_unittest.cc index 355e033..d773c08 100644 --- a/ash/display/display_manager_unittest.cc +++ b/ash/display/display_manager_unittest.cc @@ -30,7 +30,6 @@ #include "ui/gfx/display_observer.h" #include "ui/gfx/font_render_params.h" #include "ui/gfx/screen.h" -#include "ui/gfx/screen_type_delegate.h" namespace ash { @@ -1540,8 +1539,7 @@ TEST_F(DisplayManagerTest, UnifiedDesktopBasic) { display_manager()->SetUnifiedDesktopEnabled(true); // Defaults to the unified desktop. - gfx::Screen* screen = - gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_ALTERNATE); + gfx::Screen* screen = gfx::Screen::GetScreen(); // The 2nd display is scaled so that it has the same height as 1st display. // 300 * 500 / 200 + 400 = 1150. EXPECT_EQ("1150x500", screen->GetPrimaryDisplay().size().ToString()); @@ -1643,8 +1641,7 @@ TEST_F(DisplayManagerTest, UnifiedDesktopWith2xDSF) { Shell::GetPrimaryRootWindow()->RemoveObserver(this); display_manager()->SetUnifiedDesktopEnabled(true); - gfx::Screen* screen = - gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_ALTERNATE); + gfx::Screen* screen = gfx::Screen::GetScreen(); // 2nd display is 2x. UpdateDisplay("400x500,1000x800*2"); @@ -1765,8 +1762,7 @@ TEST_F(DisplayManagerTest, NoRotateUnifiedDesktop) { UpdateDisplay("400x500,300x200"); - gfx::Screen* screen = - gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_ALTERNATE); + gfx::Screen* screen = gfx::Screen::GetScreen(); const gfx::Display& display = screen->GetPrimaryDisplay(); EXPECT_EQ("1150x500", display.size().ToString()); display_manager()->SetDisplayRotation(display.id(), gfx::Display::ROTATE_90, @@ -1852,13 +1848,11 @@ class ScreenShutdownTest : public test::AshTestBase { ~ScreenShutdownTest() override {} void TearDown() override { - gfx::Screen* orig_screen = - gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_ALTERNATE); + gfx::Screen* orig_screen = gfx::Screen::GetScreen(); AshTestBase::TearDown(); if (!SupportsMultipleDisplays()) return; - gfx::Screen* screen = - gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_ALTERNATE); + gfx::Screen* screen = gfx::Screen::GetScreen(); EXPECT_NE(orig_screen, screen); EXPECT_EQ(2, screen->GetNumDisplays()); EXPECT_EQ("500x300", screen->GetPrimaryDisplay().size().ToString()); diff --git a/ash/display/unified_mouse_warp_controller_unittest.cc b/ash/display/unified_mouse_warp_controller_unittest.cc index e91ca26..8be6110 100644 --- a/ash/display/unified_mouse_warp_controller_unittest.cc +++ b/ash/display/unified_mouse_warp_controller_unittest.cc @@ -184,8 +184,7 @@ TEST_F(UnifiedMouseWarpControllerTest, WarpMouse) { if (!SupportsMultipleDisplays()) return; UpdateDisplay("500x500,600+0-500x500"); - ASSERT_EQ(1, gfx::Screen::GetScreenFor(Shell::GetPrimaryRootWindow()) - ->GetNumDisplays()); + ASSERT_EQ(1, gfx::Screen::GetScreen()->GetNumDisplays()); EXPECT_FALSE(TestIfMouseWarpsAt(gfx::Point(10, 10))); // Touch the right edge of the first display. Pointer should warp. @@ -204,8 +203,7 @@ TEST_F(UnifiedMouseWarpControllerTest, WarpMouse) { // With 2X and 1X displays UpdateDisplay("500x500*2,600+0-500x500"); - ASSERT_EQ(1, gfx::Screen::GetScreenFor(Shell::GetPrimaryRootWindow()) - ->GetNumDisplays()); + ASSERT_EQ(1, gfx::Screen::GetScreen()->GetNumDisplays()); EXPECT_FALSE(TestIfMouseWarpsAt(gfx::Point(10, 10))); // Touch the right edge of the first display. Pointer should warp. @@ -225,8 +223,7 @@ TEST_F(UnifiedMouseWarpControllerTest, WarpMouse) { // With 1X and 2X displays UpdateDisplay("500x500,600+0-500x500*2"); - ASSERT_EQ(1, gfx::Screen::GetScreenFor(Shell::GetPrimaryRootWindow()) - ->GetNumDisplays()); + ASSERT_EQ(1, gfx::Screen::GetScreen()->GetNumDisplays()); EXPECT_FALSE(TestIfMouseWarpsAt(gfx::Point(10, 10))); // Touch the right edge of the first display. Pointer should warp. @@ -245,8 +242,7 @@ TEST_F(UnifiedMouseWarpControllerTest, WarpMouse) { // With two 2X displays UpdateDisplay("500x500*2,600+0-500x500*2"); - ASSERT_EQ(1, gfx::Screen::GetScreenFor(Shell::GetPrimaryRootWindow()) - ->GetNumDisplays()); + ASSERT_EQ(1, gfx::Screen::GetScreen()->GetNumDisplays()); EXPECT_FALSE(TestIfMouseWarpsAt(gfx::Point(10, 10))); // Touch the right edge of the first display. Pointer should warp. diff --git a/ash/host/ash_window_tree_host_x11.cc b/ash/host/ash_window_tree_host_x11.cc index 50e29a4..c6ae8b4 100644 --- a/ash/host/ash_window_tree_host_x11.cc +++ b/ash/host/ash_window_tree_host_x11.cc @@ -218,7 +218,7 @@ bool AshWindowTreeHostX11::CanDispatchEvent(const ui::PlatformEvent& event) { !bounds().Contains(ui::EventLocationFromNative(xev))) return false; } else { - gfx::Screen* screen = gfx::Screen::GetScreenFor(window()); + gfx::Screen* screen = gfx::Screen::GetScreen(); gfx::Display display = screen->GetDisplayNearestWindow(window()); return touch_display_id == display.id(); } diff --git a/ash/magnifier/magnification_controller_unittest.cc b/ash/magnifier/magnification_controller_unittest.cc index 6c5a2d8..a18813f 100644 --- a/ash/magnifier/magnification_controller_unittest.cc +++ b/ash/magnifier/magnification_controller_unittest.cc @@ -703,8 +703,7 @@ TEST_F(MagnificationControllerTest, EnableMagnifierInUnifiedDesktop) { GetMagnificationController()->SetEnabled(true); - gfx::Screen* screen = - gfx::Screen::GetScreenFor(Shell::GetPrimaryRootWindow()); + gfx::Screen* screen = gfx::Screen::GetScreen(); UpdateDisplay("500x500, 500x500"); EXPECT_EQ("0,0 1000x500", screen->GetPrimaryDisplay().bounds().ToString()); diff --git a/ash/shelf/shelf_widget_unittest.cc b/ash/shelf/shelf_widget_unittest.cc index dcc7ee6..271fdc2 100644 --- a/ash/shelf/shelf_widget_unittest.cc +++ b/ash/shelf/shelf_widget_unittest.cc @@ -42,7 +42,7 @@ void TestLauncherAlignment(aura::Window* root, ShelfAlignment alignment, const std::string& expected) { Shell::GetInstance()->SetShelfAlignment(alignment, root); - gfx::Screen* screen = gfx::Screen::GetScreenFor(root); + gfx::Screen* screen = gfx::Screen::GetScreen(); EXPECT_EQ(expected, screen->GetDisplayNearestWindow(root).work_area().ToString()); } diff --git a/ash/shell.cc b/ash/shell.cc index d42c788..f31c36d 100644 --- a/ash/shell.cc +++ b/ash/shell.cc @@ -243,7 +243,7 @@ aura::Window* Shell::GetTargetRootWindow() { // static gfx::Screen* Shell::GetScreen() { - return gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_ALTERNATE); + return gfx::Screen::GetScreen(); } // static diff --git a/ash/test/display_manager_test_api.cc b/ash/test/display_manager_test_api.cc index 8de31dc..af757d8 100644 --- a/ash/test/display_manager_test_api.cc +++ b/ash/test/display_manager_test_api.cc @@ -59,14 +59,13 @@ std::vector<DisplayInfo> CreateDisplayInfoListFromString( bool DisplayManagerTestApi::TestIfMouseWarpsAt( ui::test::EventGenerator& event_generator, const gfx::Point& point_in_screen) { - aura::Window* context = Shell::GetAllRootWindows()[0]; DCHECK(!Shell::GetInstance()->display_manager()->IsInUnifiedMode()); static_cast<ExtendedMouseWarpController*>( Shell::GetInstance() ->mouse_cursor_filter() ->mouse_warp_controller_for_test()) ->allow_non_native_event_for_test(); - gfx::Screen* screen = gfx::Screen::GetScreenFor(context); + gfx::Screen* screen = gfx::Screen::GetScreen(); gfx::Display original_display = screen->GetDisplayNearestPoint(point_in_screen); event_generator.MoveMouseTo(point_in_screen); diff --git a/ash/wm/overview/window_grid.cc b/ash/wm/overview/window_grid.cc index ec3b362..33fc3fe 100644 --- a/ash/wm/overview/window_grid.cc +++ b/ash/wm/overview/window_grid.cc @@ -447,8 +447,8 @@ void WindowGrid::InitSelectionWidget(WindowSelector::Direction direction) { const gfx::Rect target_bounds = SelectedWindow()->target_bounds(); gfx::Vector2d fade_out_direction = GetSlideVectorForFadeIn(direction, target_bounds); - gfx::Display dst_display = gfx::Screen::GetScreenFor(root_window_)-> - GetDisplayMatching(target_bounds); + gfx::Display dst_display = + gfx::Screen::GetScreen()->GetDisplayMatching(target_bounds); selection_widget_->GetNativeWindow()->SetBoundsInScreen( target_bounds - fade_out_direction, dst_display); } diff --git a/ash/wm/window_state.cc b/ash/wm/window_state.cc index e009709..ac1ce8b 100644 --- a/ash/wm/window_state.cc +++ b/ash/wm/window_state.cc @@ -415,8 +415,10 @@ void WindowState::SetBoundsDirect(const gfx::Rect& bounds) { if (window_->delegate() && !IsMaximized() && !IsFullscreen()) { // Get the minimum usable size of the minimum size and the screen size. gfx::Size min_size = window_->delegate()->GetMinimumSize(); - min_size.SetToMin(gfx::Screen::GetScreenFor( - window_)->GetDisplayNearestWindow(window_).work_area().size()); + min_size.SetToMin(gfx::Screen::GetScreen() + ->GetDisplayNearestWindow(window_) + .work_area() + .size()); actual_new_bounds.set_width( std::max(min_size.width(), actual_new_bounds.width())); diff --git a/ash/wm/workspace/multi_window_resize_controller.cc b/ash/wm/workspace/multi_window_resize_controller.cc index 067275b..d0099b4 100644 --- a/ash/wm/workspace/multi_window_resize_controller.cc +++ b/ash/wm/workspace/multi_window_resize_controller.cc @@ -236,8 +236,7 @@ void MultiWindowResizeController::OnWindowDestroying( MultiWindowResizeController::ResizeWindows MultiWindowResizeController::DetermineWindowsFromScreenPoint( aura::Window* window) const { - gfx::Point mouse_location( - gfx::Screen::GetScreenFor(window)->GetCursorScreenPoint()); + gfx::Point mouse_location(gfx::Screen::GetScreen()->GetCursorScreenPoint()); ::wm::ConvertPointFromScreen(window, &mouse_location); const int component = window->delegate()->GetNonClientComponent(mouse_location); diff --git a/blimp/engine/browser/blimp_engine_session.cc b/blimp/engine/browser/blimp_engine_session.cc index 7e5b91a..97af6a1 100644 --- a/blimp/engine/browser/blimp_engine_session.cc +++ b/blimp/engine/browser/blimp_engine_session.cc @@ -183,8 +183,8 @@ BlimpEngineSession::~BlimpEngineSession() { } void BlimpEngineSession::Initialize() { - DCHECK(!gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_NATIVE)); - gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, screen_.get()); + DCHECK(!gfx::Screen::GetScreen()); + gfx::Screen::SetScreenInstance(screen_.get()); #if defined(USE_X11) window_tree_host_.reset(aura::WindowTreeHost::Create( diff --git a/chrome/browser/android/banners/app_banner_data_fetcher_android.cc b/chrome/browser/android/banners/app_banner_data_fetcher_android.cc index e367f54..c3d0874 100644 --- a/chrome/browser/android/banners/app_banner_data_fetcher_android.cc +++ b/chrome/browser/android/banners/app_banner_data_fetcher_android.cc @@ -63,10 +63,8 @@ void AppBannerDataFetcherAndroid::FetchWebappSplashScreenImage( DCHECK(web_contents); GURL image_url = ManifestIconSelector::FindBestMatchingIcon( - web_app_data().icons, - ideal_splash_image_size_in_dp_, - minimum_splash_image_size_in_dp_, - gfx::Screen::GetScreenFor(web_contents->GetNativeView())); + web_app_data().icons, ideal_splash_image_size_in_dp_, + minimum_splash_image_size_in_dp_); ShortcutHelper::FetchSplashScreenImage( web_contents, diff --git a/chrome/browser/android/webapps/add_to_homescreen_data_fetcher.cc b/chrome/browser/android/webapps/add_to_homescreen_data_fetcher.cc index d3a2ce59..3c023f6 100644 --- a/chrome/browser/android/webapps/add_to_homescreen_data_fetcher.cc +++ b/chrome/browser/android/webapps/add_to_homescreen_data_fetcher.cc @@ -113,10 +113,7 @@ void AddToHomescreenDataFetcher::OnDidGetManifest( } GURL icon_src = ManifestIconSelector::FindBestMatchingIcon( - manifest.icons, - ideal_icon_size_in_dp_, - minimum_icon_size_in_dp_, - gfx::Screen::GetScreenFor(web_contents()->GetNativeView())); + manifest.icons, ideal_icon_size_in_dp_, minimum_icon_size_in_dp_); // If fetching the Manifest icon fails, fallback to the best favicon // for the page. @@ -132,10 +129,8 @@ void AddToHomescreenDataFetcher::OnDidGetManifest( // Save the splash screen URL for the later download. splash_screen_url_ = ManifestIconSelector::FindBestMatchingIcon( - manifest.icons, - ideal_splash_image_size_in_dp_, - minimum_splash_image_size_in_dp_, - gfx::Screen::GetScreenFor(web_contents()->GetNativeView())); + manifest.icons, ideal_splash_image_size_in_dp_, + minimum_splash_image_size_in_dp_); weak_observer_->OnUserTitleAvailable(shortcut_info_.user_title); @@ -197,9 +192,9 @@ void AddToHomescreenDataFetcher::FetchFavicon() { // Using favicon if its size is not smaller than platform required size, // otherwise using the largest icon among all avaliable icons. - int ideal_icon_size_in_px = ideal_icon_size_in_dp_ * - gfx::Screen::GetScreenFor(web_contents()->GetNativeView())-> - GetPrimaryDisplay().device_scale_factor(); + int ideal_icon_size_in_px = + ideal_icon_size_in_dp_ * + gfx::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor(); int threshold_to_get_any_largest_icon = ideal_icon_size_in_px - 1; favicon_service->GetLargestRawFaviconForPageURL( shortcut_info_.url, diff --git a/chrome/browser/banners/app_banner_data_fetcher.cc b/chrome/browser/banners/app_banner_data_fetcher.cc index d953485..dd45729 100644 --- a/chrome/browser/banners/app_banner_data_fetcher.cc +++ b/chrome/browser/banners/app_banner_data_fetcher.cc @@ -344,12 +344,8 @@ void AppBannerDataFetcher::OnDidCheckHasServiceWorker( void AppBannerDataFetcher::OnHasServiceWorker( content::WebContents* web_contents) { - GURL icon_url = - ManifestIconSelector::FindBestMatchingIcon( - web_app_data_.icons, - ideal_icon_size_in_dp_, - minimum_icon_size_in_dp_, - gfx::Screen::GetScreenFor(web_contents->GetNativeView())); + GURL icon_url = ManifestIconSelector::FindBestMatchingIcon( + web_app_data_.icons, ideal_icon_size_in_dp_, minimum_icon_size_in_dp_); if (!FetchAppIcon(web_contents, icon_url)) { OutputDeveloperNotShownMessage(web_contents, kCannotDetermineBestIcon, diff --git a/chrome/browser/chromeos/display/display_preferences_unittest.cc b/chrome/browser/chromeos/display/display_preferences_unittest.cc index b2eb4c6..3557ceb 100644 --- a/chrome/browser/chromeos/display/display_preferences_unittest.cc +++ b/chrome/browser/chromeos/display/display_preferences_unittest.cc @@ -247,7 +247,7 @@ TEST_F(DisplayPreferencesTest, BasicStores) { ash::Shell::GetInstance()->display_manager(); UpdateDisplay("200x200*2, 400x300#400x400|300x200*1.25"); - int64_t id1 = gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().id(); + int64_t id1 = gfx::Screen::GetScreen()->GetPrimaryDisplay().id(); ash::test::ScopedSetInternalDisplayId set_internal(id1); int64_t id2 = ash::ScreenUtil::GetSecondaryDisplay().id(); int64_t dummy_id = id2 + 1; @@ -520,7 +520,7 @@ TEST_F(DisplayPreferencesTest, PreventStore) { TEST_F(DisplayPreferencesTest, StoreForSwappedDisplay) { UpdateDisplay("100x100,200x200"); - int64_t id1 = gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().id(); + int64_t id1 = gfx::Screen::GetScreen()->GetPrimaryDisplay().id(); int64_t id2 = ash::ScreenUtil::GetSecondaryDisplay().id(); ash::WindowTreeHostManager* window_tree_host_manager = @@ -558,7 +558,7 @@ TEST_F(DisplayPreferencesTest, RestoreColorProfiles) { ash::DisplayManager* display_manager = ash::Shell::GetInstance()->display_manager(); - int64_t id1 = gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().id(); + int64_t id1 = gfx::Screen::GetScreen()->GetPrimaryDisplay().id(); StoreColorProfile(id1, "dynamic"); @@ -612,7 +612,7 @@ TEST_F(DisplayPreferencesTest, DontStoreInGuestMode) { prefs::kDisplayProperties)->HasUserSetting()); // Settings are still notified to the system. - gfx::Screen* screen = gfx::Screen::GetNativeScreen(); + gfx::Screen* screen = gfx::Screen::GetScreen(); EXPECT_EQ(id2, screen->GetPrimaryDisplay().id()); EXPECT_EQ(ash::DisplayLayout::BOTTOM, display_manager->GetCurrentDisplayLayout().position); @@ -691,7 +691,7 @@ TEST_F(DisplayPreferencesTest, DontSaveAndRestoreAllOff) { TEST_F(DisplayPreferencesTest, DontSaveMaximizeModeControllerRotations) { ash::Shell* shell = ash::Shell::GetInstance(); gfx::Display::SetInternalDisplayId( - gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().id()); + gfx::Screen::GetScreen()->GetPrimaryDisplay().id()); ash::DisplayManager* display_manager = shell->display_manager(); LoggedInAsUser(); // Populate the properties. @@ -745,7 +745,7 @@ TEST_F(DisplayPreferencesTest, DontSaveMaximizeModeControllerRotations) { // Tests that the rotation state is saved without a user being logged in. TEST_F(DisplayPreferencesTest, StoreRotationStateNoLogin) { gfx::Display::SetInternalDisplayId( - gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().id()); + gfx::Screen::GetScreen()->GetPrimaryDisplay().id()); EXPECT_FALSE(local_state()->HasPrefPath(prefs::kDisplayRotationLock)); bool current_rotation_lock = IsRotationLocked(); @@ -767,7 +767,7 @@ TEST_F(DisplayPreferencesTest, StoreRotationStateNoLogin) { // Tests that the rotation state is saved when a guest is logged in. TEST_F(DisplayPreferencesTest, StoreRotationStateGuest) { gfx::Display::SetInternalDisplayId( - gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().id()); + gfx::Screen::GetScreen()->GetPrimaryDisplay().id()); EXPECT_FALSE(local_state()->HasPrefPath(prefs::kDisplayRotationLock)); LoggedInAsGuest(); @@ -790,7 +790,7 @@ TEST_F(DisplayPreferencesTest, StoreRotationStateGuest) { // Tests that the rotation state is saved when a normal user is logged in. TEST_F(DisplayPreferencesTest, StoreRotationStateNormalUser) { gfx::Display::SetInternalDisplayId( - gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().id()); + gfx::Screen::GetScreen()->GetPrimaryDisplay().id()); EXPECT_FALSE(local_state()->HasPrefPath(prefs::kDisplayRotationLock)); LoggedInAsGuest(); @@ -814,7 +814,7 @@ TEST_F(DisplayPreferencesTest, StoreRotationStateNormalUser) { // entering maximize mode applies the state. TEST_F(DisplayPreferencesTest, LoadRotationNoLogin) { gfx::Display::SetInternalDisplayId( - gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().id()); + gfx::Screen::GetScreen()->GetPrimaryDisplay().id()); ASSERT_FALSE(local_state()->HasPrefPath(prefs::kDisplayRotationLock)); ash::Shell* shell = ash::Shell::GetInstance(); @@ -865,7 +865,7 @@ TEST_F(DisplayPreferencesTest, LoadRotationNoLogin) { // Tests that rotation lock being set causes the rotation state to be saved. TEST_F(DisplayPreferencesTest, RotationLockTriggersStore) { gfx::Display::SetInternalDisplayId( - gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().id()); + gfx::Screen::GetScreen()->GetPrimaryDisplay().id()); ASSERT_FALSE(local_state()->HasPrefPath(prefs::kDisplayRotationLock)); ash::Shell::GetInstance()->screen_orientation_controller()->SetRotationLocked( @@ -888,9 +888,8 @@ TEST_F(DisplayPreferencesTest, SaveUnifiedMode) { UpdateDisplay("200x200,100x100"); ash::DisplayIdPair pair = display_manager->GetCurrentDisplayIdPair(); - EXPECT_EQ( - "400x200", - gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().size().ToString()); + EXPECT_EQ("400x200", + gfx::Screen::GetScreen()->GetPrimaryDisplay().size().ToString()); const base::DictionaryValue* secondary_displays = local_state()->GetDictionary(prefs::kSecondaryDisplays); @@ -905,14 +904,13 @@ TEST_F(DisplayPreferencesTest, SaveUnifiedMode) { const base::DictionaryValue* displays = local_state()->GetDictionary(prefs::kDisplayProperties); - int64_t unified_id = gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().id(); + int64_t unified_id = gfx::Screen::GetScreen()->GetPrimaryDisplay().id(); EXPECT_FALSE( displays->GetDictionary(base::Int64ToString(unified_id), &new_value)); ash::test::SetDisplayResolution(unified_id, gfx::Size(200, 100)); - EXPECT_EQ( - "200x100", - gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().size().ToString()); + EXPECT_EQ("200x100", + gfx::Screen::GetScreen()->GetPrimaryDisplay().size().ToString()); EXPECT_FALSE( displays->GetDictionary(base::Int64ToString(unified_id), &new_value)); @@ -942,7 +940,7 @@ TEST_F(DisplayPreferencesTest, SaveUnifiedMode) { } TEST_F(DisplayPreferencesTest, RestoreUnifiedMode) { - int64_t id1 = gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().id(); + int64_t id1 = gfx::Screen::GetScreen()->GetPrimaryDisplay().id(); ash::DisplayIdPair pair = std::make_pair(id1, id1 + 1); StoreDisplayBoolPropertyForPair(pair, "default_unified", true); StoreDisplayPropertyForPair( diff --git a/chrome/browser/chromeos/display/output_protection_delegate.cc b/chrome/browser/chromeos/display/output_protection_delegate.cc index 88e0f77..2c347d0 100644 --- a/chrome/browser/chromeos/display/output_protection_delegate.cc +++ b/chrome/browser/chromeos/display/output_protection_delegate.cc @@ -22,11 +22,10 @@ bool GetCurrentDisplayId(content::RenderFrameHost* rfh, int64_t* display_id) { DCHECK(rfh); DCHECK(display_id); - gfx::NativeView native_view = rfh->GetNativeView(); - gfx::Screen* screen = gfx::Screen::GetScreenFor(native_view); + gfx::Screen* screen = gfx::Screen::GetScreen(); if (!screen) return false; - gfx::Display display = screen->GetDisplayNearestWindow(native_view); + gfx::Display display = screen->GetDisplayNearestWindow(rfh->GetNativeView()); *display_id = display.id(); return true; } diff --git a/chrome/browser/chromeos/login/helper.cc b/chrome/browser/chromeos/login/helper.cc index 11ceb3d..f4345f4 100644 --- a/chrome/browser/chromeos/login/helper.cc +++ b/chrome/browser/chromeos/login/helper.cc @@ -87,8 +87,7 @@ content::StoragePartition* GetPartition(content::WebContents* embedder, } // namespace gfx::Rect CalculateScreenBounds(const gfx::Size& size) { - gfx::Rect bounds = - gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().bounds(); + gfx::Rect bounds = gfx::Screen::GetScreen()->GetPrimaryDisplay().bounds(); if (!size.IsEmpty()) { int horizontal_diff = bounds.width() - size.width(); int vertical_diff = bounds.height() - size.height(); diff --git a/chrome/browser/chromeos/login/lock/webui_screen_locker.cc b/chrome/browser/chromeos/login/lock/webui_screen_locker.cc index fc3fdca..48acb30 100644 --- a/chrome/browser/chromeos/login/lock/webui_screen_locker.cc +++ b/chrome/browser/chromeos/login/lock/webui_screen_locker.cc @@ -80,8 +80,7 @@ WebUIScreenLocker::WebUIScreenLocker(ScreenLocker* screen_locker) } void WebUIScreenLocker::LockScreen() { - gfx::Rect bounds = - gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().bounds(); + gfx::Rect bounds = gfx::Screen::GetScreen()->GetPrimaryDisplay().bounds(); lock_time_ = base::TimeTicks::Now(); LockWindow* lock_window = LockWindow::Create(); @@ -396,8 +395,7 @@ void WebUIScreenLocker::OnDisplayRemoved(const gfx::Display& old_display) { void WebUIScreenLocker::OnDisplayMetricsChanged(const gfx::Display& display, uint32_t changed_metrics) { - gfx::Display primary_display = - gfx::Screen::GetNativeScreen()->GetPrimaryDisplay(); + gfx::Display primary_display = gfx::Screen::GetScreen()->GetPrimaryDisplay(); if (display.id() != primary_display.id() || !(changed_metrics & DISPLAY_METRIC_BOUNDS)) { return; diff --git a/chrome/browser/chromeos/login/ui/login_display_host_impl.cc b/chrome/browser/chromeos/login/ui/login_display_host_impl.cc index f5252a7..a545b28 100644 --- a/chrome/browser/chromeos/login/ui/login_display_host_impl.cc +++ b/chrome/browser/chromeos/login/ui/login_display_host_impl.cc @@ -878,8 +878,7 @@ void LoginDisplayHostImpl::OnDisplayRemoved(const gfx::Display& old_display) { void LoginDisplayHostImpl::OnDisplayMetricsChanged(const gfx::Display& display, uint32_t changed_metrics) { - gfx::Display primary_display = - gfx::Screen::GetNativeScreen()->GetPrimaryDisplay(); + gfx::Display primary_display = gfx::Screen::GetScreen()->GetPrimaryDisplay(); if (display.id() != primary_display.id() || !(changed_metrics & DISPLAY_METRIC_BOUNDS)) { return; diff --git a/chrome/browser/chromeos/power/extension_event_observer_unittest.cc b/chrome/browser/chromeos/power/extension_event_observer_unittest.cc index 4557fa0..dfd58c1 100644 --- a/chrome/browser/chromeos/power/extension_event_observer_unittest.cc +++ b/chrome/browser/chromeos/power/extension_event_observer_unittest.cc @@ -64,7 +64,7 @@ class ExtensionEventObserverTest : public ::testing::Test { void SetUp() override { ::testing::Test::SetUp(); - gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, test_screen_.get()); + gfx::Screen::SetScreenInstance(test_screen_.get()); // Must be called from ::testing::Test::SetUp. ASSERT_TRUE(profile_manager_->SetUp()); @@ -81,7 +81,7 @@ class ExtensionEventObserverTest : public ::testing::Test { void TearDown() override { profile_ = NULL; profile_manager_->DeleteAllTestingProfiles(); - gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, nullptr); + gfx::Screen::SetScreenInstance(nullptr); ::testing::Test::TearDown(); } diff --git a/chrome/browser/chromeos/ui/accessibility_focus_ring_controller.cc b/chrome/browser/chromeos/ui/accessibility_focus_ring_controller.cc index 12eab38..c34aa44 100644 --- a/chrome/browser/chromeos/ui/accessibility_focus_ring_controller.cc +++ b/chrome/browser/chromeos/ui/accessibility_focus_ring_controller.cc @@ -73,8 +73,7 @@ void AccessibilityFocusRingController::Update() { } gfx::Rect bounds = rings_[0].GetBounds(); - gfx::Display display = - gfx::Screen::GetNativeScreen()->GetDisplayMatching(bounds); + gfx::Display display = gfx::Screen::GetScreen()->GetDisplayMatching(bounds); aura::Window* root_window = ash::Shell::GetInstance() ->window_tree_host_manager() ->GetRootWindowForDisplayId(display.id()); diff --git a/chrome/browser/chromeos/ui/accessibility_focus_ring_layer.cc b/chrome/browser/chromeos/ui/accessibility_focus_ring_layer.cc index 28ced6c..8303aac 100644 --- a/chrome/browser/chromeos/ui/accessibility_focus_ring_layer.cc +++ b/chrome/browser/chromeos/ui/accessibility_focus_ring_layer.cc @@ -102,8 +102,7 @@ void AccessibilityFocusRingLayer::Set(const AccessibilityFocusRing& ring) { int inset = kGradientWidth; bounds.Inset(-inset, -inset, -inset, -inset); - gfx::Display display = - gfx::Screen::GetNativeScreen()->GetDisplayMatching(bounds); + gfx::Display display = gfx::Screen::GetScreen()->GetDisplayMatching(bounds); aura::Window* root_window = ash::Shell::GetInstance() ->window_tree_host_manager() ->GetRootWindowForDisplayId(display.id()); diff --git a/chrome/browser/download/drag_download_item_views.cc b/chrome/browser/download/drag_download_item_views.cc index 1859647..43c25a5 100644 --- a/chrome/browser/download/drag_download_item_views.cc +++ b/chrome/browser/download/drag_download_item_views.cc @@ -62,7 +62,7 @@ void DragDownloadItem(const content::DownloadItem* download, if (!root_window || !aura::client::GetDragDropClient(root_window)) return; - gfx::Point location = gfx::Screen::GetScreenFor(view)->GetCursorScreenPoint(); + gfx::Point location = gfx::Screen::GetScreen()->GetCursorScreenPoint(); // TODO(varunjain): Properly determine and send DRAG_EVENT_SOURCE below. aura::client::GetDragDropClient(root_window)->StartDragAndDrop( data, diff --git a/chrome/browser/extensions/display_info_provider_aura.cc b/chrome/browser/extensions/display_info_provider_aura.cc index 65c2823..a880d89 100644 --- a/chrome/browser/extensions/display_info_provider_aura.cc +++ b/chrome/browser/extensions/display_info_provider_aura.cc @@ -33,7 +33,7 @@ void DisplayInfoProviderAura::UpdateDisplayUnitInfoForPlatform( } gfx::Screen* DisplayInfoProviderAura::GetActiveScreen() { - return gfx::Screen::GetNativeScreen(); + return gfx::Screen::GetScreen(); } // static diff --git a/chrome/browser/extensions/display_info_provider_chromeos.cc b/chrome/browser/extensions/display_info_provider_chromeos.cc index 070682f0..3327b38 100644 --- a/chrome/browser/extensions/display_info_provider_chromeos.cc +++ b/chrome/browser/extensions/display_info_provider_chromeos.cc @@ -302,9 +302,7 @@ bool DisplayInfoProviderChromeOS::SetInfo(const std::string& display_id_str, } int64_t display_id = target.id(); - // TODO(scottmg): Native is wrong http://crbug.com/133312 - const gfx::Display& primary = - gfx::Screen::GetNativeScreen()->GetPrimaryDisplay(); + const gfx::Display& primary = gfx::Screen::GetScreen()->GetPrimaryDisplay(); if (!ValidateParamsForDisplay( info, target, display_manager, primary.id(), error)) { diff --git a/chrome/browser/extensions/display_info_provider_mac.cc b/chrome/browser/extensions/display_info_provider_mac.cc index c49c3f1..c0bc440 100644 --- a/chrome/browser/extensions/display_info_provider_mac.cc +++ b/chrome/browser/extensions/display_info_provider_mac.cc @@ -33,7 +33,7 @@ void DisplayInfoProviderMac::UpdateDisplayUnitInfoForPlatform( } gfx::Screen* DisplayInfoProviderMac::GetActiveScreen() { - return gfx::Screen::GetNativeScreen(); + return gfx::Screen::GetScreen(); } // static diff --git a/chrome/browser/extensions/display_info_provider_win.cc b/chrome/browser/extensions/display_info_provider_win.cc index 39a8ab3..041bee85 100644 --- a/chrome/browser/extensions/display_info_provider_win.cc +++ b/chrome/browser/extensions/display_info_provider_win.cc @@ -83,8 +83,7 @@ void DisplayInfoProviderWin::UpdateDisplayUnitInfoForPlatform( } gfx::Screen* DisplayInfoProviderWin::GetActiveScreen() { - // TODO(scottmg): native screen is wrong http://crbug.com/133312 - return gfx::Screen::GetNativeScreen(); + return gfx::Screen::GetScreen(); } // static diff --git a/chrome/browser/manifest/manifest_icon_downloader.cc b/chrome/browser/manifest/manifest_icon_downloader.cc index ec8de3a..3f9eb8b 100644 --- a/chrome/browser/manifest/manifest_icon_downloader.cc +++ b/chrome/browser/manifest/manifest_icon_downloader.cc @@ -55,11 +55,8 @@ bool ManifestIconDownloader::Download( if (!web_contents || !icon_url.is_valid()) return false; - const gfx::Screen* screen = - gfx::Screen::GetScreenFor(web_contents->GetNativeView()); - const float device_scale_factor = - screen->GetPrimaryDisplay().device_scale_factor(); + gfx::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor(); const int ideal_icon_size_in_px = static_cast<int>(round(ideal_icon_size_in_dp * device_scale_factor)); const int minimum_icon_size_in_px = diff --git a/chrome/browser/manifest/manifest_icon_selector.cc b/chrome/browser/manifest/manifest_icon_selector.cc index 26bbbe1..c44c29e 100644 --- a/chrome/browser/manifest/manifest_icon_selector.cc +++ b/chrome/browser/manifest/manifest_icon_selector.cc @@ -166,12 +166,11 @@ std::vector<Manifest::Icon> ManifestIconSelector::FilterIconsByType( GURL ManifestIconSelector::FindBestMatchingIcon( const std::vector<Manifest::Icon>& unfiltered_icons, const int ideal_icon_size_in_dp, - const int minimum_icon_size_in_dp, - const gfx::Screen* screen) { + const int minimum_icon_size_in_dp) { DCHECK(minimum_icon_size_in_dp <= ideal_icon_size_in_dp); const float device_scale_factor = - screen->GetPrimaryDisplay().device_scale_factor(); + gfx::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor(); const int ideal_icon_size_in_px = static_cast<int>(round(ideal_icon_size_in_dp * device_scale_factor)); const int minimum_icon_size_in_px = diff --git a/chrome/browser/manifest/manifest_icon_selector.h b/chrome/browser/manifest/manifest_icon_selector.h index b3dc645..da2b7f6 100644 --- a/chrome/browser/manifest/manifest_icon_selector.h +++ b/chrome/browser/manifest/manifest_icon_selector.h @@ -40,8 +40,7 @@ class ManifestIconSelector { static GURL FindBestMatchingIcon( const std::vector<content::Manifest::Icon>& icons, int ideal_icon_size_in_dp, - int minimum_icon_size_in_dp, - const gfx::Screen* screen); + int minimum_icon_size_in_dp); private: ManifestIconSelector(int ideal_icon_size_in_px, diff --git a/chrome/browser/manifest/manifest_icon_selector_unittest.cc b/chrome/browser/manifest/manifest_icon_selector_unittest.cc index fbd3eb1..6750957 100644 --- a/chrome/browser/manifest/manifest_icon_selector_unittest.cc +++ b/chrome/browser/manifest/manifest_icon_selector_unittest.cc @@ -11,7 +11,6 @@ #include "base/strings/utf_string_conversions.h" #include "testing/gtest/include/gtest/gtest.h" #include "ui/gfx/screen.h" -#include "ui/gfx/screen_type_delegate.h" #include "ui/gfx/test/test_screen.h" class ManifestIconSelectorTest : public testing::Test { @@ -19,16 +18,18 @@ class ManifestIconSelectorTest : public testing::Test { ManifestIconSelectorTest() { test_screen_.display()->set_id(0x1337); test_screen_.display()->set_bounds(gfx::Rect(0, 0, 2560, 1440)); + gfx::Screen::SetScreenInstance(&test_screen_); } - ~ManifestIconSelectorTest() override {} + ~ManifestIconSelectorTest() override { + gfx::Screen::SetScreenInstance(nullptr); + } GURL FindBestMatchingIconWithMinimum( const std::vector<content::Manifest::Icon>& icons, int minimum_icon_size_in_dp) { return ManifestIconSelector::FindBestMatchingIcon( - icons, GetPreferredIconSizeInDp(), - minimum_icon_size_in_dp, &test_screen_); + icons, GetPreferredIconSizeInDp(), minimum_icon_size_in_dp); } GURL FindBestMatchingIcon(const std::vector<content::Manifest::Icon>& icons) { diff --git a/chrome/browser/metrics/chrome_browser_main_extra_parts_metrics.cc b/chrome/browser/metrics/chrome_browser_main_extra_parts_metrics.cc index 525ab33..180d838 100644 --- a/chrome/browser/metrics/chrome_browser_main_extra_parts_metrics.cc +++ b/chrome/browser/metrics/chrome_browser_main_extra_parts_metrics.cc @@ -300,7 +300,7 @@ ChromeBrowserMainExtraPartsMetrics::ChromeBrowserMainExtraPartsMetrics() ChromeBrowserMainExtraPartsMetrics::~ChromeBrowserMainExtraPartsMetrics() { if (is_screen_observer_) - gfx::Screen::GetNativeScreen()->RemoveObserver(this); + gfx::Screen::GetScreen()->RemoveObserver(this); } void ChromeBrowserMainExtraPartsMetrics::PreProfileInit() { @@ -345,9 +345,9 @@ void ChromeBrowserMainExtraPartsMetrics::PostBrowserStart() { base::Bind(&RecordStartupMetricsOnBlockingPool), base::TimeDelta::FromSeconds(kStartupMetricsGatheringDelaySeconds)); - display_count_ = gfx::Screen::GetNativeScreen()->GetNumDisplays(); + display_count_ = gfx::Screen::GetScreen()->GetNumDisplays(); UMA_HISTOGRAM_COUNTS_100("Hardware.Display.Count.OnStartup", display_count_); - gfx::Screen::GetNativeScreen()->AddObserver(this); + gfx::Screen::GetScreen()->AddObserver(this); is_screen_observer_ = true; #if !defined(OS_ANDROID) @@ -371,7 +371,7 @@ void ChromeBrowserMainExtraPartsMetrics::OnDisplayMetricsChanged( } void ChromeBrowserMainExtraPartsMetrics::EmitDisplaysChangedMetric() { - int display_count = gfx::Screen::GetNativeScreen()->GetNumDisplays(); + int display_count = gfx::Screen::GetScreen()->GetNumDisplays(); if (display_count != display_count_) { display_count_ = display_count; UMA_HISTOGRAM_COUNTS_100("Hardware.Display.Count.OnChange", display_count_); diff --git a/chrome/browser/metrics/chrome_browser_main_extra_parts_metrics_unittest.cc b/chrome/browser/metrics/chrome_browser_main_extra_parts_metrics_unittest.cc index ace798f7..d6cbf6d 100644 --- a/chrome/browser/metrics/chrome_browser_main_extra_parts_metrics_unittest.cc +++ b/chrome/browser/metrics/chrome_browser_main_extra_parts_metrics_unittest.cc @@ -42,12 +42,12 @@ class ChromeBrowserMainExtraPartsMetricsTest : public testing::Test { ChromeBrowserMainExtraPartsMetricsTest::ChromeBrowserMainExtraPartsMetricsTest() : device_data_manager_test_api_() { - gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, &test_screen_); + gfx::Screen::SetScreenInstance(&test_screen_); } ChromeBrowserMainExtraPartsMetricsTest:: ~ChromeBrowserMainExtraPartsMetricsTest() { - gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, nullptr); + gfx::Screen::SetScreenInstance(nullptr); } // Verify a TouchEventsEnabled value isn't recorded during construction. diff --git a/chrome/browser/plugins/plugin_power_saver_browsertest.cc b/chrome/browser/plugins/plugin_power_saver_browsertest.cc index 234c0a9..cb66ea6 100644 --- a/chrome/browser/plugins/plugin_power_saver_browsertest.cc +++ b/chrome/browser/plugins/plugin_power_saver_browsertest.cc @@ -295,7 +295,7 @@ class PluginPowerSaverBrowserTest : public InProcessBrowserTest { if (PixelTestsEnabled()) { gfx::Rect bounds(gfx::Rect(0, 0, kBrowserWidth, kBrowserHeight)); gfx::Rect screen_bounds = - gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().bounds(); + gfx::Screen::GetScreen()->GetPrimaryDisplay().bounds(); ASSERT_GT(screen_bounds.width(), kBrowserWidth); ASSERT_GT(screen_bounds.height(), kBrowserHeight); browser()->window()->SetBounds(bounds); diff --git a/chrome/browser/signin/signin_error_notifier_ash_unittest.cc b/chrome/browser/signin/signin_error_notifier_ash_unittest.cc index e28f6ec..8fe2d43 100644 --- a/chrome/browser/signin/signin_error_notifier_ash_unittest.cc +++ b/chrome/browser/signin/signin_error_notifier_ash_unittest.cc @@ -31,7 +31,6 @@ #include "chrome/browser/ui/ash/ash_util.h" #include "ui/aura/test/test_screen.h" #include "ui/gfx/screen.h" -#include "ui/gfx/screen_type_delegate.h" #endif namespace ash { @@ -47,20 +46,6 @@ static const std::string kNotificationId = "chrome://settings/signin/testuser@test.com"; } -#if defined(OS_WIN) -class ScreenTypeDelegateDesktop : public gfx::ScreenTypeDelegate { - public: - ScreenTypeDelegateDesktop() {} - gfx::ScreenType GetScreenTypeForNativeView(gfx::NativeView view) override { - return chrome::IsNativeViewInAsh(view) ? - gfx::SCREEN_TYPE_ALTERNATE : - gfx::SCREEN_TYPE_NATIVE; - } - private: - DISALLOW_COPY_AND_ASSIGN(ScreenTypeDelegateDesktop); -}; -#endif - class SigninErrorNotifierTest : public AshTestBase { public: void SetUp() override { @@ -81,8 +66,7 @@ class SigninErrorNotifierTest : public AshTestBase { // Set up screen for Windows. #if defined(OS_WIN) test_screen_.reset(aura::TestScreen::Create(gfx::Size())); - gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, test_screen_.get()); - gfx::Screen::SetScreenTypeDelegate(&screen_type_delegate_); + gfx::Screen::SetScreenInstance(test_screen_.get()); #endif error_controller_ = SigninErrorControllerFactory::GetForProfile( @@ -93,8 +77,7 @@ class SigninErrorNotifierTest : public AshTestBase { void TearDown() override { #if defined(OS_WIN) - gfx::Screen::SetScreenTypeDelegate(nullptr); - gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, nullptr); + gfx::Screen::SetScreenInstance(nullptr); test_screen_.reset(); #endif profile_manager_.reset(); @@ -113,7 +96,6 @@ class SigninErrorNotifierTest : public AshTestBase { } #if defined(OS_WIN) - ScreenTypeDelegateDesktop screen_type_delegate_; scoped_ptr<gfx::Screen> test_screen_; #endif scoped_ptr<TestingProfileManager> profile_manager_; diff --git a/chrome/browser/sync/sync_error_notifier_ash_unittest.cc b/chrome/browser/sync/sync_error_notifier_ash_unittest.cc index 03c0f01..edc7acc 100644 --- a/chrome/browser/sync/sync_error_notifier_ash_unittest.cc +++ b/chrome/browser/sync/sync_error_notifier_ash_unittest.cc @@ -30,7 +30,6 @@ #include "chrome/browser/ui/ash/ash_util.h" #include "ui/aura/test/test_screen.h" #include "ui/gfx/screen.h" -#include "ui/gfx/screen_type_delegate.h" #endif using ::testing::NiceMock; @@ -49,22 +48,6 @@ static const char kTestAccountId[] = "testuser@test.com"; static const std::string kNotificationId = "chrome://settings/sync/testuser@test.com"; -#if defined(OS_WIN) -class ScreenTypeDelegateDesktop : public gfx::ScreenTypeDelegate { - public: - ScreenTypeDelegateDesktop() {} - ~ScreenTypeDelegateDesktop() override {} - gfx::ScreenType GetScreenTypeForNativeView(gfx::NativeView view) override { - return chrome::IsNativeViewInAsh(view) ? - gfx::SCREEN_TYPE_ALTERNATE : - gfx::SCREEN_TYPE_NATIVE; - } - - private: - DISALLOW_COPY_AND_ASSIGN(ScreenTypeDelegateDesktop); -}; -#endif - class FakeLoginUIService: public LoginUIService { public: FakeLoginUIService() : LoginUIService(NULL) {} @@ -104,8 +87,7 @@ class SyncErrorNotifierTest : public AshTestBase { // adding desktop widgets (i.e., message center notifications). #if defined(OS_WIN) test_screen_.reset(aura::TestScreen::Create(gfx::Size())); - gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, test_screen_.get()); - gfx::Screen::SetScreenTypeDelegate(&screen_type_delegate_); + gfx::Screen::SetScreenInstance(test_screen_.get()); #endif AshTestBase::SetUp(); @@ -139,8 +121,7 @@ class SyncErrorNotifierTest : public AshTestBase { AshTestBase::TearDown(); #if defined(OS_WIN) - gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, nullptr); - gfx::Screen::SetScreenTypeDelegate(nullptr); + gfx::Screen::SetScreenInstance(nullptr); test_screen_.reset(); #endif @@ -176,7 +157,6 @@ class SyncErrorNotifierTest : public AshTestBase { } #if defined(OS_WIN) - ScreenTypeDelegateDesktop screen_type_delegate_; scoped_ptr<gfx::Screen> test_screen_; #endif scoped_ptr<TestingProfileManager> profile_manager_; diff --git a/chrome/browser/ui/app_list/app_list_service_mac.mm b/chrome/browser/ui/app_list/app_list_service_mac.mm index 03a81b1..bba9cf1 100644 --- a/chrome/browser/ui/app_list/app_list_service_mac.mm +++ b/chrome/browser/ui/app_list/app_list_service_mac.mm @@ -229,7 +229,7 @@ void AdjustWorkAreaForDock(const gfx::Display& display, void GetAppListWindowOrigins( NSWindow* window, NSPoint* target_origin, NSPoint* start_origin) { - gfx::Screen* const screen = gfx::Screen::GetScreenFor([window contentView]); + gfx::Screen* const screen = gfx::Screen::GetScreen(); // Ensure y coordinates are flipped back into AppKit's coordinate system. bool cursor_is_visible = CGCursorIsVisible(); gfx::Display display; diff --git a/chrome/browser/ui/app_list/app_list_shower_views.cc b/chrome/browser/ui/app_list/app_list_shower_views.cc index fbd0e7d..72139ca 100644 --- a/chrome/browser/ui/app_list/app_list_shower_views.cc +++ b/chrome/browser/ui/app_list/app_list_shower_views.cc @@ -117,7 +117,7 @@ app_list::AppListView* AppListShower::MakeViewForCurrentProfile() { view = new app_list::AppListView(delegate_->GetViewDelegateForCreate()); } - gfx::Point cursor = gfx::Screen::GetNativeScreen()->GetCursorScreenPoint(); + gfx::Point cursor = gfx::Screen::GetScreen()->GetCursorScreenPoint(); view->InitAsBubbleAtFixedLocation(NULL, 0, cursor, diff --git a/chrome/browser/ui/ash/launcher/chrome_launcher_controller.cc b/chrome/browser/ui/ash/launcher/chrome_launcher_controller.cc index f8c9c91..128de1d 100644 --- a/chrome/browser/ui/ash/launcher/chrome_launcher_controller.cc +++ b/chrome/browser/ui/ash/launcher/chrome_launcher_controller.cc @@ -121,8 +121,8 @@ namespace { const char kAppShelfIdPlaceholder[] = "AppShelfIDPlaceholder--------"; std::string GetPrefKeyForRootWindow(aura::Window* root_window) { - gfx::Display display = gfx::Screen::GetScreenFor( - root_window)->GetDisplayNearestWindow(root_window); + gfx::Display display = + gfx::Screen::GetScreen()->GetDisplayNearestWindow(root_window); DCHECK(display.is_valid()); return base::Int64ToString(display.id()); diff --git a/chrome/browser/ui/ash/multi_user/user_switch_animator_chromeos.cc b/chrome/browser/ui/ash/multi_user/user_switch_animator_chromeos.cc index c3b5757..627c8e1 100644 --- a/chrome/browser/ui/ash/multi_user/user_switch_animator_chromeos.cc +++ b/chrome/browser/ui/ash/multi_user/user_switch_animator_chromeos.cc @@ -140,8 +140,8 @@ bool UserSwitchAnimatorChromeOS::CoversScreen(aura::Window* window) { if (ash::wm::GetWindowState(window)->IsFullscreen()) return true; gfx::Rect bounds = window->GetBoundsInRootWindow(); - gfx::Rect work_area = gfx::Screen::GetScreenFor(window)-> - GetDisplayNearestWindow(window).work_area(); + gfx::Rect work_area = + gfx::Screen::GetScreen()->GetDisplayNearestWindow(window).work_area(); bounds.Intersect(work_area); return work_area == bounds; } diff --git a/chrome/browser/ui/aura/chrome_browser_main_extra_parts_aura.cc b/chrome/browser/ui/aura/chrome_browser_main_extra_parts_aura.cc index a42ea33..1a13594 100644 --- a/chrome/browser/ui/aura/chrome_browser_main_extra_parts_aura.cc +++ b/chrome/browser/ui/aura/chrome_browser_main_extra_parts_aura.cc @@ -146,7 +146,7 @@ void ChromeBrowserMainExtraPartsAura::PreCreateThreads() { #endif if (!should_open_ash) { gfx::Screen* screen = views::CreateDesktopScreen(); - gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, screen); + gfx::Screen::SetScreenInstance(screen); #if defined(USE_X11) views::LinuxUI::instance()->UpdateDeviceScaleFactor( screen->GetPrimaryDisplay().device_scale_factor()); diff --git a/chrome/browser/ui/autofill/popup_view_common.cc b/chrome/browser/ui/autofill/popup_view_common.cc index 9169ae0..a342aac 100644 --- a/chrome/browser/ui/autofill/popup_view_common.cc +++ b/chrome/browser/ui/autofill/popup_view_common.cc @@ -128,8 +128,7 @@ gfx::Rect PopupViewCommon::CalculatePopupBounds(int desired_width, gfx::Display PopupViewCommon::GetDisplayNearestPoint( const gfx::Point& point, gfx::NativeView container_view) { - return gfx::Screen::GetScreenFor(container_view) - ->GetDisplayNearestPoint(point); + return gfx::Screen::GetScreen()->GetDisplayNearestPoint(point); } } // namespace autofill diff --git a/chrome/browser/ui/panels/display_settings_provider.cc b/chrome/browser/ui/panels/display_settings_provider.cc index d3700a3..039d6ce 100644 --- a/chrome/browser/ui/panels/display_settings_provider.cc +++ b/chrome/browser/ui/panels/display_settings_provider.cc @@ -66,8 +66,7 @@ void DisplaySettingsProvider::RemoveFullScreenObserver( // TODO(scottmg): This should be moved to ui/. gfx::Rect DisplaySettingsProvider::GetPrimaryDisplayArea() const { - // TODO(scottmg): NativeScreen is wrong. http://crbug.com/133312 - return gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().bounds(); + return gfx::Screen::GetScreen()->GetPrimaryDisplay().bounds(); } gfx::Rect DisplaySettingsProvider::GetPrimaryWorkArea() const { @@ -76,8 +75,7 @@ gfx::Rect DisplaySettingsProvider::GetPrimaryWorkArea() const { // screen (and overlap Dock). And we also want to exclude the system menu // area. Note that the rect returned from gfx::Screen util functions is in // platform-independent screen coordinates with (0, 0) as the top-left corner. - // TODO(scottmg): NativeScreen is wrong. http://crbug.com/133312 - gfx::Display display = gfx::Screen::GetNativeScreen()->GetPrimaryDisplay(); + gfx::Display display = gfx::Screen::GetScreen()->GetPrimaryDisplay(); gfx::Rect display_area = display.bounds(); gfx::Rect work_area = display.work_area(); int system_menu_height = work_area.y() - display_area.y(); @@ -87,21 +85,18 @@ gfx::Rect DisplaySettingsProvider::GetPrimaryWorkArea() const { } return display_area; #else - // TODO(scottmg): NativeScreen is wrong. http://crbug.com/133312 - return gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().work_area(); + return gfx::Screen::GetScreen()->GetPrimaryDisplay().work_area(); #endif } gfx::Rect DisplaySettingsProvider::GetDisplayAreaMatching( const gfx::Rect& bounds) const { - // TODO(scottmg): NativeScreen is wrong. http://crbug.com/133312 - return gfx::Screen::GetNativeScreen()->GetDisplayMatching(bounds).bounds(); + return gfx::Screen::GetScreen()->GetDisplayMatching(bounds).bounds(); } gfx::Rect DisplaySettingsProvider::GetWorkAreaMatching( const gfx::Rect& bounds) const { - // TODO(scottmg): NativeScreen is wrong. http://crbug.com/133312 - gfx::Screen* screen = gfx::Screen::GetNativeScreen(); + gfx::Screen* screen = gfx::Screen::GetScreen(); gfx::Display display = screen->GetDisplayMatching(bounds); if (display.bounds() == screen->GetPrimaryDisplay().bounds()) return GetPrimaryWorkArea(); diff --git a/chrome/browser/ui/panels/panel_mouse_watcher_timer.cc b/chrome/browser/ui/panels/panel_mouse_watcher_timer.cc index 7480f21..dab6dcc 100644 --- a/chrome/browser/ui/panels/panel_mouse_watcher_timer.cc +++ b/chrome/browser/ui/panels/panel_mouse_watcher_timer.cc @@ -66,8 +66,7 @@ bool PanelMouseWatcherTimer::IsActive() const { } gfx::Point PanelMouseWatcherTimer::GetMousePosition() const { - // TODO(scottmg): NativeScreen is wrong. http://crbug.com/133312 - return gfx::Screen::GetNativeScreen()->GetCursorScreenPoint(); + return gfx::Screen::GetScreen()->GetCursorScreenPoint(); } void PanelMouseWatcherTimer::DoWork() { diff --git a/chrome/browser/ui/views/app_list/linux/app_list_linux.cc b/chrome/browser/ui/views/app_list/linux/app_list_linux.cc index a8ef48a..07b707d 100644 --- a/chrome/browser/ui/views/app_list/linux/app_list_linux.cc +++ b/chrome/browser/ui/views/app_list/linux/app_list_linux.cc @@ -84,9 +84,8 @@ gfx::Point AppListLinux::FindAnchorPoint(const gfx::Size& view_size, // static void AppListLinux::MoveNearCursor(app_list::AppListView* view) { - gfx::Point cursor = gfx::Screen::GetNativeScreen()->GetCursorScreenPoint(); - gfx::Screen* screen = - gfx::Screen::GetScreenFor(view->GetWidget()->GetNativeView()); + gfx::Screen* screen = gfx::Screen::GetScreen(); + gfx::Point cursor = screen->GetCursorScreenPoint(); gfx::Display display = screen->GetDisplayNearestPoint(cursor); view->SetBubbleArrow(views::BubbleBorder::FLOAT); diff --git a/chrome/browser/ui/views/app_list/win/app_list_win.cc b/chrome/browser/ui/views/app_list/win/app_list_win.cc index f2d4e82..462b627 100644 --- a/chrome/browser/ui/views/app_list/win/app_list_win.cc +++ b/chrome/browser/ui/views/app_list/win/app_list_win.cc @@ -79,9 +79,8 @@ gfx::Point AppListWin::FindAnchorPoint(const gfx::Size& view_size, // static void AppListWin::MoveNearCursor(app_list::AppListView* view) { - gfx::Point cursor = gfx::Screen::GetNativeScreen()->GetCursorScreenPoint(); - gfx::Screen* screen = - gfx::Screen::GetScreenFor(view->GetWidget()->GetNativeView()); + gfx::Screen* screen = gfx::Screen::GetScreen(); + gfx::Point cursor = screen->GetCursorScreenPoint(); gfx::Display display = screen->GetDisplayNearestPoint(cursor); view->SetBubbleArrow(views::BubbleBorder::FLOAT); diff --git a/chrome/browser/ui/views/ash/chrome_browser_main_extra_parts_ash.cc b/chrome/browser/ui/views/ash/chrome_browser_main_extra_parts_ash.cc index 5ea6ab2..c356a04 100644 --- a/chrome/browser/ui/views/ash/chrome_browser_main_extra_parts_ash.cc +++ b/chrome/browser/ui/views/ash/chrome_browser_main_extra_parts_ash.cc @@ -18,7 +18,6 @@ #include "chrome/common/chrome_switches.h" #include "ui/aura/env.h" #include "ui/gfx/screen.h" -#include "ui/gfx/screen_type_delegate.h" #include "ui/keyboard/content/keyboard.h" #include "ui/keyboard/keyboard_controller.h" @@ -27,20 +26,6 @@ #include "chrome/browser/ui/views/select_file_dialog_extension_factory.h" #endif -#if !defined(OS_CHROMEOS) -class ScreenTypeDelegateWin : public gfx::ScreenTypeDelegate { - public: - ScreenTypeDelegateWin() {} - gfx::ScreenType GetScreenTypeForNativeView(gfx::NativeView view) override { - return chrome::IsNativeViewInAsh(view) ? - gfx::SCREEN_TYPE_ALTERNATE : - gfx::SCREEN_TYPE_NATIVE; - } - private: - DISALLOW_COPY_AND_ASSIGN(ScreenTypeDelegateWin); -}; -#endif // !OS_CHROMEOS - ChromeBrowserMainExtraPartsAsh::ChromeBrowserMainExtraPartsAsh() { } @@ -55,10 +40,6 @@ void ChromeBrowserMainExtraPartsAsh::PreProfileInit() { ash::Shell::GetInstance()->CreateShelf(); ash::Shell::GetInstance()->ShowShelf(); #endif - } else { -#if !defined(OS_CHROMEOS) - gfx::Screen::SetScreenTypeDelegate(new ScreenTypeDelegateWin); -#endif } #if defined(OS_CHROMEOS) // For OS_CHROMEOS, virtual keyboard needs to be initialized before profile diff --git a/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc b/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc index 8e42608..9bb367b 100644 --- a/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc +++ b/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc @@ -709,8 +709,7 @@ base::string16 BookmarkBarView::CreateToolTipForURLAndTitle( const base::string16& title, Profile* profile) { const views::TooltipManager* tooltip_manager = widget->GetTooltipManager(); - int max_width = tooltip_manager->GetMaxWidth(screen_loc, - widget->GetNativeView()); + int max_width = tooltip_manager->GetMaxWidth(screen_loc); const gfx::FontList tt_fonts = tooltip_manager->GetFontList(); base::string16 result; diff --git a/chrome/browser/ui/views/chrome_views_delegate.cc b/chrome/browser/ui/views/chrome_views_delegate.cc index 0f1a967..4a743b3 100644 --- a/chrome/browser/ui/views/chrome_views_delegate.cc +++ b/chrome/browser/ui/views/chrome_views_delegate.cc @@ -195,8 +195,9 @@ void ChromeViewsDelegate::SaveWindowPlacement(const views::Widget* window, window_preferences->SetBoolean("maximized", show_state == ui::SHOW_STATE_MAXIMIZED); window_preferences->SetBoolean("docked", show_state == ui::SHOW_STATE_DOCKED); - gfx::Rect work_area(gfx::Screen::GetScreenFor(window->GetNativeView())-> - GetDisplayNearestWindow(window->GetNativeView()).work_area()); + gfx::Rect work_area(gfx::Screen::GetScreen() + ->GetDisplayNearestWindow(window->GetNativeView()) + .work_area()); window_preferences->SetInteger("work_area_left", work_area.x()); window_preferences->SetInteger("work_area_top", work_area.y()); window_preferences->SetInteger("work_area_right", work_area.right()); @@ -237,8 +238,8 @@ bool ChromeViewsDelegate::GetSavedWindowPlacement( gfx::NativeView window = widget->GetNativeView(); if (chrome::GetHostDesktopTypeForNativeView(window) == chrome::HOST_DESKTOP_TYPE_ASH) { - gfx::Display display = gfx::Screen::GetScreenFor(window)-> - GetDisplayMatching(*bounds); + gfx::Display display = + gfx::Screen::GetScreen()->GetDisplayMatching(*bounds); bounds->AdjustToFit(display.work_area()); ash::wm::GetWindowState(window)->set_minimum_visibility(true); } diff --git a/chrome/browser/ui/views/exclusive_access_bubble_views.cc b/chrome/browser/ui/views/exclusive_access_bubble_views.cc index 5028490..7b34b1a 100644 --- a/chrome/browser/ui/views/exclusive_access_bubble_views.cc +++ b/chrome/browser/ui/views/exclusive_access_bubble_views.cc @@ -612,10 +612,7 @@ gfx::Rect ExclusiveAccessBubbleViews::GetPopupRect( } gfx::Point ExclusiveAccessBubbleViews::GetCursorScreenPoint() { - gfx::Point cursor_pos = - gfx::Screen::GetScreenFor( - bubble_view_context_->GetBubbleAssociatedWidget()->GetNativeView()) - ->GetCursorScreenPoint(); + gfx::Point cursor_pos = gfx::Screen::GetScreen()->GetCursorScreenPoint(); views::View::ConvertPointFromScreen(GetBrowserRootView(), &cursor_pos); return cursor_pos; } diff --git a/chrome/browser/ui/views/extensions/extension_dialog.cc b/chrome/browser/ui/views/extensions/extension_dialog.cc index 51c8d6e..36b883b 100644 --- a/chrome/browser/ui/views/extensions/extension_dialog.cc +++ b/chrome/browser/ui/views/extensions/extension_dialog.cc @@ -110,8 +110,7 @@ void ExtensionDialog::InitWindow(gfx::NativeWindow parent, // Ensure the top left and top right of the window are on screen, with // priority given to the top left. gfx::Rect screen_rect = - gfx::Screen::GetScreenFor(parent_widget->GetNativeView()) - ->GetDisplayNearestPoint(center).bounds(); + gfx::Screen::GetScreen()->GetDisplayNearestPoint(center).bounds(); gfx::Rect bounds_rect = gfx::Rect(x, y, width, height); bounds_rect.AdjustToFit(screen_rect); window->SetBounds(bounds_rect); diff --git a/chrome/browser/ui/views/frame/browser_view_interactive_uitest.cc b/chrome/browser/ui/views/frame/browser_view_interactive_uitest.cc index 4cbe787..8d334ad 100644 --- a/chrome/browser/ui/views/frame/browser_view_interactive_uitest.cc +++ b/chrome/browser/ui/views/frame/browser_view_interactive_uitest.cc @@ -78,7 +78,7 @@ IN_PROC_BROWSER_TEST_P(BrowserViewTestParam, BrowserRemembersDockedState) { window->SetBounds(original_bounds); window->Show(); // Dock the browser window using |kShowStateKey| property. - gfx::Rect work_area = gfx::Screen::GetScreenFor(window) + gfx::Rect work_area = gfx::Screen::GetScreen() ->GetDisplayNearestPoint(window->bounds().origin()) .work_area(); window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_DOCKED); diff --git a/chrome/browser/ui/views/link_disambiguation/link_disambiguation_popup.cc b/chrome/browser/ui/views/link_disambiguation/link_disambiguation_popup.cc index 50104f9..ba8b98f 100644 --- a/chrome/browser/ui/views/link_disambiguation/link_disambiguation_popup.cc +++ b/chrome/browser/ui/views/link_disambiguation/link_disambiguation_popup.cc @@ -185,7 +185,7 @@ void LinkDisambiguationPopup::Show( zoomed_bitmap.width(), zoomed_bitmap.height()); const gfx::Display display = - gfx::Screen::GetScreenFor(content)->GetDisplayNearestWindow(content); + gfx::Screen::GetScreen()->GetDisplayNearestWindow(content); window_bounds.AdjustToFit(display.work_area()); view_->GetWidget()->SetBounds(window_bounds); view_->GetWidget()->Show(); diff --git a/chrome/browser/ui/views/message_center/web_notification_tray.cc b/chrome/browser/ui/views/message_center/web_notification_tray.cc index 0e7a396..69f90d4 100644 --- a/chrome/browser/ui/views/message_center/web_notification_tray.cc +++ b/chrome/browser/ui/views/message_center/web_notification_tray.cc @@ -38,7 +38,7 @@ message_center::MessageCenter* WebNotificationTray::message_center() { } bool WebNotificationTray::ShowPopups() { - alignment_delegate_->StartObserving(gfx::Screen::GetNativeScreen()); + alignment_delegate_->StartObserving(gfx::Screen::GetScreen()); popup_collection_->DoUpdateIfPossible(); return true; } diff --git a/chrome/browser/ui/views/panels/panel_frame_view.cc b/chrome/browser/ui/views/panels/panel_frame_view.cc index c26a1c7..09be1e0 100644 --- a/chrome/browser/ui/views/panels/panel_frame_view.cc +++ b/chrome/browser/ui/views/panels/panel_frame_view.cc @@ -593,7 +593,7 @@ bool PanelFrameView::OnMouseDragged(const ui::MouseEvent& event) { // Converting the mouse location to screen coordinates returns an incorrect // location while the panel is moving. See crbug.com/353393 for more details. // TODO(pkotwicz): Fix conversion to screen coordinates - gfx::Screen* screen = gfx::Screen::GetNativeScreen(); + gfx::Screen* screen = gfx::Screen::GetScreen(); gfx::Point mouse_location = screen->GetCursorScreenPoint(); #else // |event.location| is in the view's coordinate system. Convert it to the diff --git a/chrome/browser/ui/views/panels/panel_view.cc b/chrome/browser/ui/views/panels/panel_view.cc index ddb61fb..78bf7d8 100644 --- a/chrome/browser/ui/views/panels/panel_view.cc +++ b/chrome/browser/ui/views/panels/panel_view.cc @@ -1011,8 +1011,8 @@ void PanelView::OnWidgetActivationChanged(views::Widget* widget, bool active) { #if defined(OS_WIN) if (focused_ && panel_->IsMinimized() && panel_->collection()->type() == PanelCollection::DOCKED && - gfx::Screen::GetScreenFor(widget->GetNativeWindow())-> - GetWindowUnderCursor() != widget->GetNativeWindow()) { + gfx::Screen::GetScreen()->GetWindowUnderCursor() != + widget->GetNativeWindow()) { panel_->Restore(); } #endif diff --git a/chrome/browser/ui/views/profiles/user_manager_view.cc b/chrome/browser/ui/views/profiles/user_manager_view.cc index 342099b..34e67ec 100644 --- a/chrome/browser/ui/views/profiles/user_manager_view.cc +++ b/chrome/browser/ui/views/profiles/user_manager_view.cc @@ -291,8 +291,9 @@ void UserManagerView::Init(Profile* system_profile, const GURL& url) { gfx::NativeView native_view = views::Widget::GetWidgetForNativeWindow( browser->window()->GetNativeWindow())->GetNativeView(); - bounds = gfx::Screen::GetScreenFor(native_view)-> - GetDisplayNearestWindow(native_view).work_area(); + bounds = gfx::Screen::GetScreen() + ->GetDisplayNearestWindow(native_view) + .work_area(); bounds.ClampToCenteredSize(gfx::Size(UserManager::kWindowWidth, UserManager::kWindowHeight)); } diff --git a/chrome/browser/ui/views/screen_capture_notification_ui_views.cc b/chrome/browser/ui/views/screen_capture_notification_ui_views.cc index 03e0ef7..0851a9f 100644 --- a/chrome/browser/ui/views/screen_capture_notification_ui_views.cc +++ b/chrome/browser/ui/views/screen_capture_notification_ui_views.cc @@ -195,7 +195,7 @@ gfx::NativeViewId ScreenCaptureNotificationUIViews::OnStarted( set_background(views::Background::CreateSolidBackground(GetNativeTheme()-> GetSystemColor(ui::NativeTheme::kColorId_DialogBackground))); - gfx::Screen* screen = gfx::Screen::GetNativeScreen(); + gfx::Screen* screen = gfx::Screen::GetScreen(); // TODO(sergeyu): Move the notification to the display being captured when // per-display screen capture is supported. gfx::Rect work_area = screen->GetPrimaryDisplay().work_area(); diff --git a/chrome/browser/ui/views/status_bubble_views.cc b/chrome/browser/ui/views/status_bubble_views.cc index ef57b75..e2b21bd 100644 --- a/chrome/browser/ui/views/status_bubble_views.cc +++ b/chrome/browser/ui/views/status_bubble_views.cc @@ -804,8 +804,8 @@ void StatusBubbleViews::AvoidMouse(const gfx::Point& location) { // Check if the bubble sticks out from the monitor or will obscure // download shelf. gfx::NativeView window = base_view_->GetWidget()->GetNativeView(); - gfx::Rect monitor_rect = gfx::Screen::GetScreenFor(window)-> - GetDisplayNearestWindow(window).work_area(); + gfx::Rect monitor_rect = + gfx::Screen::GetScreen()->GetDisplayNearestWindow(window).work_area(); const int bubble_bottom_y = top_left.y() + position_.y() + size_.height(); if (bubble_bottom_y + offset > monitor_rect.height() || diff --git a/chrome/browser/ui/views/status_icons/status_tray_win.cc b/chrome/browser/ui/views/status_icons/status_tray_win.cc index c1f692d..301001d 100644 --- a/chrome/browser/ui/views/status_icons/status_tray_win.cc +++ b/chrome/browser/ui/views/status_icons/status_tray_win.cc @@ -192,8 +192,7 @@ LRESULT CALLBACK StatusTrayWin::WndProc(HWND hwnd, case WM_CONTEXTMENU: // Walk our icons, find which one was clicked on, and invoke its // HandleClickEvent() method. - gfx::Point cursor_pos( - gfx::Screen::GetNativeScreen()->GetCursorScreenPoint()); + gfx::Point cursor_pos(gfx::Screen::GetScreen()->GetCursorScreenPoint()); win_icon->HandleClickEvent(cursor_pos, lparam == WM_LBUTTONDOWN); return TRUE; } diff --git a/chrome/browser/ui/views/tabs/tab_drag_controller.cc b/chrome/browser/ui/views/tabs/tab_drag_controller.cc index 8542c62..bd8325fd 100644 --- a/chrome/browser/ui/views/tabs/tab_drag_controller.cc +++ b/chrome/browser/ui/views/tabs/tab_drag_controller.cc @@ -198,7 +198,6 @@ TabDragController::TabDragController() : event_source_(EVENT_SOURCE_MOUSE), source_tabstrip_(NULL), attached_tabstrip_(NULL), - screen_(NULL), host_desktop_type_(chrome::HOST_DESKTOP_TYPE_NATIVE), can_release_capture_(true), offset_to_width_ratio_(0), @@ -263,8 +262,6 @@ void TabDragController::Init( source_tabstrip_ = source_tabstrip; was_source_maximized_ = source_tabstrip->GetWidget()->IsMaximized(); was_source_fullscreen_ = source_tabstrip->GetWidget()->IsFullscreen(); - screen_ = gfx::Screen::GetScreenFor( - source_tabstrip->GetWidget()->GetNativeView()); host_desktop_type_ = chrome::GetHostDesktopTypeForNativeView( source_tabstrip->GetWidget()->GetNativeView()); // Do not release capture when transferring capture between widgets on: @@ -482,7 +479,8 @@ gfx::Point TabDragController::GetWindowCreatePoint( const gfx::Point& origin) const { // If the cursor is outside the monitor area, move it inside. For example, // dropping a tab onto the task bar on Windows produces this situation. - gfx::Rect work_area = screen_->GetDisplayNearestPoint(origin).work_area(); + gfx::Rect work_area = + gfx::Screen::GetScreen()->GetDisplayNearestPoint(origin).work_area(); gfx::Point create_point(origin); if (!work_area.IsEmpty()) { if (create_point.x() < work_area.x()) @@ -1647,8 +1645,9 @@ gfx::Rect TabDragController::CalculateDraggedBrowserBounds( views::View::ConvertPointToWidget(source, ¢er); gfx::Rect new_bounds(source->GetWidget()->GetRestoredBounds()); - gfx::Rect work_area = - screen_->GetDisplayNearestPoint(last_point_in_screen_).work_area(); + gfx::Rect work_area = gfx::Screen::GetScreen() + ->GetDisplayNearestPoint(last_point_in_screen_) + .work_area(); if (new_bounds.size().width() >= work_area.size().width() && new_bounds.size().height() >= work_area.size().height()) { new_bounds = work_area; @@ -1782,7 +1781,7 @@ gfx::Point TabDragController::GetCursorScreenPoint() { } #endif - return screen_->GetCursorScreenPoint(); + return gfx::Screen::GetScreen()->GetCursorScreenPoint(); } gfx::Vector2d TabDragController::GetWindowOffset( diff --git a/chrome/browser/ui/views/tabs/tab_drag_controller.h b/chrome/browser/ui/views/tabs/tab_drag_controller.h index 63b04d4..637a651 100644 --- a/chrome/browser/ui/views/tabs/tab_drag_controller.h +++ b/chrome/browser/ui/views/tabs/tab_drag_controller.h @@ -462,10 +462,6 @@ class TabDragController : public content::NotificationObserver, // dragged Tab is detached. TabStrip* attached_tabstrip_; - // The screen that this drag is associated with. Cached, because other UI - // elements are NULLd at various points during the lifetime of this object. - gfx::Screen* screen_; - // The desktop type that this drag is associated with. Cached, because other // UI elements are NULLd at various points during the lifetime of this // object. diff --git a/chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest.cc b/chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest.cc index ce52192..d4c3887 100644 --- a/chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest.cc +++ b/chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest.cc @@ -188,8 +188,10 @@ Browser* TabDragControllerTest::CreateAnotherWindowBrowserAndRelayout() { ResetIDs(browser2->tab_strip_model(), 100); // Resize the two windows so they're right next to each other. - gfx::Rect work_area = gfx::Screen::GetNativeScreen()->GetDisplayNearestWindow( - browser()->window()->GetNativeWindow()).work_area(); + gfx::Rect work_area = + gfx::Screen::GetScreen() + ->GetDisplayNearestWindow(browser()->window()->GetNativeWindow()) + .work_area(); gfx::Size half_size = gfx::Size(work_area.width() / 3 - 10, work_area.height() / 2 - 10); browser()->window()->SetBounds(gfx::Rect(work_area.origin(), half_size)); @@ -808,7 +810,7 @@ IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest, MAYBE_DetachFromFullsizeWindow) { // Resize the browser window so that it is as big as the work area. gfx::Rect work_area = - gfx::Screen::GetNativeScreen() + gfx::Screen::GetScreen() ->GetDisplayNearestWindow(browser()->window()->GetNativeWindow()) .work_area(); browser()->window()->SetBounds(work_area); @@ -1718,8 +1720,9 @@ IN_PROC_BROWSER_TEST_P(DetachToBrowserInSeparateDisplayTabDragControllerTest, aura::Window::Windows roots = ash::Shell::GetAllRootWindows(); ASSERT_EQ(2u, roots.size()); aura::Window* second_root = roots[1]; - gfx::Rect work_area = gfx::Screen::GetNativeScreen()->GetDisplayNearestWindow( - second_root).work_area(); + gfx::Rect work_area = gfx::Screen::GetScreen() + ->GetDisplayNearestWindow(second_root) + .work_area(); browser2->window()->SetBounds(work_area); EXPECT_EQ(second_root, browser2->window()->GetNativeWindow()->GetRootWindow()); @@ -1768,8 +1771,9 @@ IN_PROC_BROWSER_TEST_P(DetachToBrowserInSeparateDisplayTabDragControllerTest, aura::Window::Windows roots = ash::Shell::GetAllRootWindows(); ASSERT_EQ(2u, roots.size()); aura::Window* second_root = roots[1]; - gfx::Rect work_area = gfx::Screen::GetNativeScreen()->GetDisplayNearestWindow( - second_root).work_area(); + gfx::Rect work_area = gfx::Screen::GetScreen() + ->GetDisplayNearestWindow(second_root) + .work_area(); browser()->window()->SetBounds(work_area); // position both browser windows side by side on the second screen. @@ -1828,8 +1832,9 @@ IN_PROC_BROWSER_TEST_P(DetachToBrowserInSeparateDisplayTabDragControllerTest, ASSERT_EQ(2u, roots.size()); aura::Window* first_root = roots[0]; aura::Window* second_root = roots[1]; - gfx::Rect work_area = gfx::Screen::GetNativeScreen()->GetDisplayNearestWindow( - second_root).work_area(); + gfx::Rect work_area = gfx::Screen::GetScreen() + ->GetDisplayNearestWindow(second_root) + .work_area(); work_area.Inset(20, 20, 20, 60); Browser::CreateParams params(browser()->profile(), browser()->host_desktop_type()); @@ -1898,8 +1903,9 @@ IN_PROC_BROWSER_TEST_P(DetachToBrowserInSeparateDisplayTabDragControllerTest, aura::Window::Windows roots = ash::Shell::GetAllRootWindows(); ASSERT_EQ(2u, roots.size()); aura::Window* second_root = roots[1]; - gfx::Rect work_area = gfx::Screen::GetNativeScreen()->GetDisplayNearestWindow( - second_root).work_area(); + gfx::Rect work_area = gfx::Screen::GetScreen() + ->GetDisplayNearestWindow(second_root) + .work_area(); browser2->window()->SetBounds(work_area); EXPECT_EQ(second_root, browser2->window()->GetNativeWindow()->GetRootWindow()); @@ -2144,9 +2150,10 @@ IN_PROC_BROWSER_TEST_F( // Move the second browser to the second display. aura::Window::Windows roots = ash::Shell::GetAllRootWindows(); ASSERT_EQ(2u, roots.size()); - gfx::Point final_destination = - gfx::Screen::GetNativeScreen()->GetDisplayNearestWindow( - roots[1]).work_area().CenterPoint(); + gfx::Point final_destination = gfx::Screen::GetScreen() + ->GetDisplayNearestWindow(roots[1]) + .work_area() + .CenterPoint(); // Move to the first tab and drag it enough so that it detaches, but not // enough to move to another display. @@ -2183,15 +2190,16 @@ IN_PROC_BROWSER_TEST_F( EXPECT_EQ("0 1", IDString(browser()->tab_strip_model())); EXPECT_EQ(roots[0], browser()->window()->GetNativeWindow()->GetRootWindow()); - gfx::Rect work_area = gfx::Screen::GetNativeScreen()-> - GetDisplayNearestWindow(roots[1]).work_area(); + gfx::Rect work_area = + gfx::Screen::GetScreen()->GetDisplayNearestWindow(roots[1]).work_area(); browser()->window()->SetBounds(work_area); EXPECT_EQ(roots[1], browser()->window()->GetNativeWindow()->GetRootWindow()); // Move the second browser to the display. - gfx::Point final_destination = - gfx::Screen::GetNativeScreen()->GetDisplayNearestWindow( - roots[0]).work_area().CenterPoint(); + gfx::Point final_destination = gfx::Screen::GetScreen() + ->GetDisplayNearestWindow(roots[0]) + .work_area() + .CenterPoint(); // Move to the first tab and drag it enough so that it detaches, but not // enough to move to another display. diff --git a/chrome/browser/ui/views/tabs/tab_strip.cc b/chrome/browser/ui/views/tabs/tab_strip.cc index d60676d..8fed116c 100644 --- a/chrome/browser/ui/views/tabs/tab_strip.cc +++ b/chrome/browser/ui/views/tabs/tab_strip.cc @@ -2344,7 +2344,7 @@ gfx::Rect TabStrip::GetDropBounds(int drop_index, drop_indicator_height); // If the rect doesn't fit on the monitor, push the arrow to the bottom. - gfx::Screen* screen = gfx::Screen::GetScreenFor(GetWidget()->GetNativeView()); + gfx::Screen* screen = gfx::Screen::GetScreen(); gfx::Display display = screen->GetDisplayMatching(drop_bounds); *is_beneath = !display.bounds().Contains(drop_bounds); if (*is_beneath) diff --git a/chrome/browser/ui/views/tabs/window_finder_x11.cc b/chrome/browser/ui/views/tabs/window_finder_x11.cc index 18c9c02..313f412 100644 --- a/chrome/browser/ui/views/tabs/window_finder_x11.cc +++ b/chrome/browser/ui/views/tabs/window_finder_x11.cc @@ -11,8 +11,7 @@ namespace { float GetDeviceScaleFactor() { - gfx::Display display = gfx::Screen::GetNativeScreen()->GetPrimaryDisplay(); - return display.device_scale_factor(); + return gfx::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor(); } gfx::Point DIPToPixelPoint(const gfx::Point& dip_point) { diff --git a/chrome/browser/ui/views/toolbar/toolbar_button.cc b/chrome/browser/ui/views/toolbar/toolbar_button.cc index 31fe494..3e33387 100644 --- a/chrome/browser/ui/views/toolbar/toolbar_button.cc +++ b/chrome/browser/ui/views/toolbar/toolbar_button.cc @@ -222,14 +222,13 @@ void ToolbarButton::ShowDropDownMenu(ui::MenuSourceType source_type) { // Use the left bound of the display on which // the menu button exists. gfx::NativeView view = GetWidget()->GetNativeView(); - gfx::Display display = gfx::Screen::GetScreenFor( - view)->GetDisplayNearestWindow(view); + gfx::Display display = + gfx::Screen::GetScreen()->GetDisplayNearestWindow(view); int left_bound = display.bounds().x(); #else // The window might be positioned over the edge between two screens. We'll // want to position the dropdown on the screen the mouse cursor is on. - gfx::NativeView view = GetWidget()->GetNativeView(); - gfx::Screen* screen = gfx::Screen::GetScreenFor(view); + gfx::Screen* screen = gfx::Screen::GetScreen(); gfx::Display display = screen->GetDisplayNearestPoint( screen->GetCursorScreenPoint()); int left_bound = display.bounds().x(); diff --git a/chrome/browser/ui/webui/chromeos/login/core_oobe_handler.cc b/chrome/browser/ui/webui/chromeos/login/core_oobe_handler.cc index 7aa2886..810aa23 100644 --- a/chrome/browser/ui/webui/chromeos/login/core_oobe_handler.cc +++ b/chrome/browser/ui/webui/chromeos/login/core_oobe_handler.cc @@ -396,8 +396,7 @@ void CoreOobeHandler::UpdateKeyboardState() { } void CoreOobeHandler::UpdateClientAreaSize() { - const gfx::Size& size = - gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().size(); + const gfx::Size& size = gfx::Screen::GetScreen()->GetPrimaryDisplay().size(); SetClientAreaSize(size.width(), size.height()); } diff --git a/chrome/browser/ui/window_sizer/window_sizer.cc b/chrome/browser/ui/window_sizer/window_sizer.cc index 051b162..d731a96 100644 --- a/chrome/browser/ui/window_sizer/window_sizer.cc +++ b/chrome/browser/ui/window_sizer/window_sizer.cc @@ -197,8 +197,7 @@ WindowSizer::WindowSizer( const Browser* browser) : state_provider_(std::move(state_provider)), target_display_provider_(std::move(target_display_provider)), - // TODO(scottmg): NativeScreen is wrong. http://crbug.com/133312 - screen_(gfx::Screen::GetNativeScreen()), + screen_(gfx::Screen::GetScreen()), browser_(browser) {} WindowSizer::WindowSizer( diff --git a/chrome/test/base/view_event_test_platform_part_default.cc b/chrome/test/base/view_event_test_platform_part_default.cc index ff855df..8a3de63 100644 --- a/chrome/test/base/view_event_test_platform_part_default.cc +++ b/chrome/test/base/view_event_test_platform_part_default.cc @@ -18,7 +18,7 @@ class ViewEventTestPlatformPartDefault : public ViewEventTestPlatformPart { ui::ContextFactory* context_factory) { #if defined(USE_AURA) screen_.reset(views::CreateDesktopScreen()); - gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, screen_.get()); + gfx::Screen::SetScreenInstance(screen_.get()); aura::Env::CreateInstance(true); aura::Env::GetInstance()->set_context_factory(context_factory); #endif @@ -27,7 +27,7 @@ class ViewEventTestPlatformPartDefault : public ViewEventTestPlatformPart { ~ViewEventTestPlatformPartDefault() override { #if defined(USE_AURA) aura::Env::DeleteInstance(); - gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, nullptr); + gfx::Screen::SetScreenInstance(nullptr); #endif } diff --git a/chromecast/browser/cast_browser_main_parts.cc b/chromecast/browser/cast_browser_main_parts.cc index 48671a4..92e3a48 100644 --- a/chromecast/browser/cast_browser_main_parts.cc +++ b/chromecast/browser/cast_browser_main_parts.cc @@ -326,9 +326,8 @@ int CastBrowserMainParts::PreCreateThreads() { // code. See CastContentWindow::CreateWindowTree for update when resolution // is available. cast_browser_process_->SetCastScreen(make_scoped_ptr(new CastScreen)); - DCHECK(!gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_NATIVE)); - gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, - cast_browser_process_->cast_screen()); + DCHECK(!gfx::Screen::GetScreen()); + gfx::Screen::SetScreenInstance(cast_browser_process_->cast_screen()); #endif content::ChildProcessSecurityPolicy::GetInstance()->RegisterWebSafeScheme( diff --git a/chromecast/browser/cast_content_window.cc b/chromecast/browser/cast_content_window.cc index 99f0a77..a5f63ea 100644 --- a/chromecast/browser/cast_content_window.cc +++ b/chromecast/browser/cast_content_window.cc @@ -75,8 +75,8 @@ void CastContentWindow::CreateWindowTree( // Aura initialization CastScreen* cast_screen = shell::CastBrowserProcess::GetInstance()->cast_screen(); - if (!gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_NATIVE)) - gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, cast_screen); + if (!gfx::Screen::GetScreen()) + gfx::Screen::SetScreenInstance(cast_screen); if (cast_screen->GetPrimaryDisplay().size() != initial_size) cast_screen->UpdateDisplaySize(initial_size); media::VideoPlaneController::GetInstance()->SetGraphicsPlaneResolution( diff --git a/components/autofill/content/browser/risk/fingerprint.cc b/components/autofill/content/browser/risk/fingerprint.cc index dacbd5f..c6f3956 100644 --- a/components/autofill/content/browser/risk/fingerprint.cc +++ b/components/autofill/content/browser/risk/fingerprint.cc @@ -126,12 +126,10 @@ void AddAcceptLanguagesToFingerprint( // into the |machine|. void AddScreenInfoToFingerprint(const WebScreenInfo& screen_info, Fingerprint::MachineCharacteristics* machine) { - // TODO(scottmg): NativeScreen maybe wrong. http://crbug.com/133312 - machine->set_screen_count( - gfx::Screen::GetNativeScreen()->GetNumDisplays()); + machine->set_screen_count(gfx::Screen::GetScreen()->GetNumDisplays()); const gfx::Size screen_size = - gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().GetSizeInPixel(); + gfx::Screen::GetScreen()->GetPrimaryDisplay().GetSizeInPixel(); machine->mutable_screen_size()->set_width(screen_size.width()); machine->mutable_screen_size()->set_height(screen_size.height()); diff --git a/components/dom_distiller/content/browser/distiller_page_web_contents.cc b/components/dom_distiller/content/browser/distiller_page_web_contents.cc index a1fc869..e458cf9 100644 --- a/components/dom_distiller/content/browser/distiller_page_web_contents.cc +++ b/components/dom_distiller/content/browser/distiller_page_web_contents.cc @@ -143,7 +143,7 @@ gfx::Size DistillerPageWebContents::GetSizeForNewRenderView( // in the executed domdistiller.js won't be 0. if (size.IsEmpty()) { DVLOG(1) << "Using fullscreen as default RenderView size"; - size = gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().size(); + size = gfx::Screen::GetScreen()->GetPrimaryDisplay().size(); } return size; } diff --git a/components/metrics/ui/screen_info_metrics_provider.cc b/components/metrics/ui/screen_info_metrics_provider.cc index 72a87fc..3d31e98 100644 --- a/components/metrics/ui/screen_info_metrics_provider.cc +++ b/components/metrics/ui/screen_info_metrics_provider.cc @@ -78,17 +78,15 @@ void ScreenInfoMetricsProvider::ProvideSystemProfileMetrics( } gfx::Size ScreenInfoMetricsProvider::GetScreenSize() const { - return gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().GetSizeInPixel(); + return gfx::Screen::GetScreen()->GetPrimaryDisplay().GetSizeInPixel(); } float ScreenInfoMetricsProvider::GetScreenDeviceScaleFactor() const { - return gfx::Screen::GetNativeScreen()-> - GetPrimaryDisplay().device_scale_factor(); + return gfx::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor(); } int ScreenInfoMetricsProvider::GetScreenCount() const { - // TODO(scottmg): NativeScreen maybe wrong. http://crbug.com/133312 - return gfx::Screen::GetNativeScreen()->GetNumDisplays(); + return gfx::Screen::GetScreen()->GetNumDisplays(); } } // namespace metrics diff --git a/content/browser/media/capture/web_contents_video_capture_device_unittest.cc b/content/browser/media/capture/web_contents_video_capture_device_unittest.cc index 9e3bf83..0d50e4d 100644 --- a/content/browser/media/capture/web_contents_video_capture_device_unittest.cc +++ b/content/browser/media/capture/web_contents_video_capture_device_unittest.cc @@ -590,8 +590,8 @@ class MAYBE_WebContentsVideoCaptureDeviceTest : public testing::Test { test_screen_.display()->set_bounds(gfx::Rect(0, 0, 2560, 1440)); test_screen_.display()->set_device_scale_factor(kTestDeviceScaleFactor); - gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, &test_screen_); - ASSERT_EQ(&test_screen_, gfx::Screen::GetNativeScreen()); + gfx::Screen::SetScreenInstance(&test_screen_); + ASSERT_EQ(&test_screen_, gfx::Screen::GetScreen()); // TODO(nick): Sadness and woe! Much "mock-the-world" boilerplate could be // eliminated here, if only we could use RenderViewHostTestHarness. The @@ -649,7 +649,7 @@ class MAYBE_WebContentsVideoCaptureDeviceTest : public testing::Test { render_view_host_factory_.reset(); render_process_host_factory_.reset(); - gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, NULL); + gfx::Screen::SetScreenInstance(nullptr); } // Accessors. diff --git a/content/browser/renderer_host/render_widget_host_unittest.cc b/content/browser/renderer_host/render_widget_host_unittest.cc index 26619d7..3080295 100644 --- a/content/browser/renderer_host/render_widget_host_unittest.cc +++ b/content/browser/renderer_host/render_widget_host_unittest.cc @@ -463,7 +463,7 @@ class RenderWidgetHostTest : public testing::Test { #endif #if defined(USE_AURA) screen_.reset(aura::TestScreen::Create(gfx::Size())); - gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, screen_.get()); + gfx::Screen::SetScreenInstance(screen_.get()); #endif host_.reset(new MockRenderWidgetHost(delegate_.get(), process_, process_->GetNextRoutingID())); @@ -483,7 +483,7 @@ class RenderWidgetHostTest : public testing::Test { browser_context_.reset(); #if defined(USE_AURA) - gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, nullptr); + gfx::Screen::SetScreenInstance(nullptr); screen_.reset(); #endif #if defined(USE_AURA) || (defined(OS_MACOSX) && !defined(OS_IOS)) diff --git a/content/browser/renderer_host/render_widget_host_view_android.cc b/content/browser/renderer_host/render_widget_host_view_android.cc index 8417546..8b52e6b 100644 --- a/content/browser/renderer_host/render_widget_host_view_android.cc +++ b/content/browser/renderer_host/render_widget_host_view_android.cc @@ -429,8 +429,7 @@ void RenderWidgetHostViewAndroid::GetScaledContentBitmap( src_subrect = gfx::Rect(bounds); DCHECK_LE(src_subrect.width() + src_subrect.x(), bounds.width()); DCHECK_LE(src_subrect.height() + src_subrect.y(), bounds.height()); - const gfx::Display& display = - gfx::Screen::GetNativeScreen()->GetPrimaryDisplay(); + const gfx::Display& display = gfx::Screen::GetScreen()->GetPrimaryDisplay(); float device_scale_factor = display.device_scale_factor(); DCHECK_GT(device_scale_factor, 0); gfx::Size dst_size( @@ -885,8 +884,7 @@ void RenderWidgetHostViewAndroid::CopyFromCompositingSurface( callback.Run(SkBitmap(), READBACK_SURFACE_UNAVAILABLE); return; } - const gfx::Display& display = - gfx::Screen::GetNativeScreen()->GetPrimaryDisplay(); + const gfx::Display& display = gfx::Screen::GetScreen()->GetPrimaryDisplay(); float device_scale_factor = display.device_scale_factor(); gfx::Size dst_size_in_pixel = gfx::ConvertRectToPixel(device_scale_factor, gfx::Rect(dst_size)).size(); @@ -2057,8 +2055,7 @@ void RenderWidgetHostViewAndroid::OnStylusSelectTap(base::TimeTicks time, // static void RenderWidgetHostViewBase::GetDefaultScreenInfo( blink::WebScreenInfo* results) { - const gfx::Display& display = - gfx::Screen::GetNativeScreen()->GetPrimaryDisplay(); + const gfx::Display& display = gfx::Screen::GetScreen()->GetPrimaryDisplay(); results->rect = display.bounds(); // TODO(husky): Remove any system controls from availableRect. results->availableRect = display.work_area(); diff --git a/content/browser/renderer_host/render_widget_host_view_aura.cc b/content/browser/renderer_host/render_widget_host_view_aura.cc index 7767a94..02e38ec 100644 --- a/content/browser/renderer_host/render_widget_host_view_aura.cc +++ b/content/browser/renderer_host/render_widget_host_view_aura.cc @@ -261,9 +261,9 @@ bool IsXButtonUpEvent(const ui::MouseEvent* event) { } void GetScreenInfoForWindow(WebScreenInfo* results, aura::Window* window) { - const gfx::Display display = window ? - gfx::Screen::GetScreenFor(window)->GetDisplayNearestWindow(window) : - gfx::Screen::GetScreenFor(window)->GetPrimaryDisplay(); + gfx::Screen* screen = gfx::Screen::GetScreen(); + const gfx::Display display = window ? screen->GetDisplayNearestWindow(window) + : screen->GetPrimaryDisplay(); results->rect = display.bounds(); results->availableRect = display.work_area(); // TODO(derat|oshima): Don't hardcode this. Get this from display object. @@ -527,7 +527,7 @@ void RenderWidgetHostViewAura::InitAsChild( parent_view->AddChild(GetNativeView()); const gfx::Display display = - gfx::Screen::GetScreenFor(window_)->GetDisplayNearestWindow(window_); + gfx::Screen::GetScreen()->GetDisplayNearestWindow(window_); device_scale_factor_ = display.device_scale_factor(); } @@ -580,7 +580,7 @@ void RenderWidgetHostViewAura::InitAsPopup( event_filter_for_popup_exit_.reset(new EventFilterForPopupExit(this)); const gfx::Display display = - gfx::Screen::GetScreenFor(window_)->GetDisplayNearestWindow(window_); + gfx::Screen::GetScreen()->GetDisplayNearestWindow(window_); device_scale_factor_ = display.device_scale_factor(); } @@ -603,8 +603,8 @@ void RenderWidgetHostViewAura::InitAsFullscreen( host_tracker_.reset(new aura::WindowTracker); host_tracker_->Add(reference_window); } - gfx::Display display = gfx::Screen::GetScreenFor(window_)-> - GetDisplayNearestWindow(reference_window); + gfx::Display display = + gfx::Screen::GetScreen()->GetDisplayNearestWindow(reference_window); parent = reference_window->GetRootWindow(); bounds = display.bounds(); } @@ -613,7 +613,7 @@ void RenderWidgetHostViewAura::InitAsFullscreen( Focus(); const gfx::Display display = - gfx::Screen::GetScreenFor(window_)->GetDisplayNearestWindow(window_); + gfx::Screen::GetScreen()->GetDisplayNearestWindow(window_); device_scale_factor_ = display.device_scale_factor(); } @@ -993,8 +993,8 @@ void RenderWidgetHostViewAura::SetInsets(const gfx::Insets& insets) { void RenderWidgetHostViewAura::UpdateCursor(const WebCursor& cursor) { current_cursor_ = cursor; - const gfx::Display display = gfx::Screen::GetScreenFor(window_)-> - GetDisplayNearestWindow(window_); + const gfx::Display display = + gfx::Screen::GetScreen()->GetDisplayNearestWindow(window_); current_cursor_.SetDisplayInfo(display); UpdateCursorIfOverSelf(); } @@ -1191,12 +1191,9 @@ void RenderWidgetHostViewAura::UpdateConstrainedWindowRects( } void RenderWidgetHostViewAura::UpdateMouseLockRegion() { - // Clip the cursor if chrome is running on regular desktop. - if (gfx::Screen::GetScreenFor(window_) == gfx::Screen::GetNativeScreen()) { - RECT window_rect = - gfx::win::DIPToScreenRect(window_->GetBoundsInScreen()).ToRECT(); - ::ClipCursor(&window_rect); - } + RECT window_rect = + gfx::win::DIPToScreenRect(window_->GetBoundsInScreen()).ToRECT(); + ::ClipCursor(&window_rect); } void RenderWidgetHostViewAura::OnLegacyWindowDestroyed() { @@ -1851,7 +1848,7 @@ void RenderWidgetHostViewAura::OnDisplayRemoved( void RenderWidgetHostViewAura::OnDisplayMetricsChanged( const gfx::Display& display, uint32_t metrics) { // The screen info should be updated regardless of the metric change. - gfx::Screen* screen = gfx::Screen::GetScreenFor(window_); + gfx::Screen* screen = gfx::Screen::GetScreen(); if (display.id() == screen->GetDisplayNearestWindow(window_).id()) { UpdateScreenInfo(window_); current_cursor_.SetDisplayInfo(display); @@ -1921,7 +1918,7 @@ void RenderWidgetHostViewAura::OnDeviceScaleFactorChanged( UpdateScreenInfo(window_); device_scale_factor_ = device_scale_factor; - const gfx::Display display = gfx::Screen::GetScreenFor(window_)-> + const gfx::Display display = gfx::Screen::GetScreen()-> GetDisplayNearestWindow(window_); DCHECK_EQ(device_scale_factor, display.device_scale_factor()); current_cursor_.SetDisplayInfo(display); @@ -2446,7 +2443,7 @@ void RenderWidgetHostViewAura::OnWindowFocused(aura::Window* gained_focus, // If we lose the focus while fullscreen, close the window; Pepper Flash // won't do it for us (unlike NPAPI Flash). However, we do not close the // window if we lose the focus to a window on another display. - gfx::Screen* screen = gfx::Screen::GetScreenFor(window_); + gfx::Screen* screen = gfx::Screen::GetScreen(); bool focusing_other_display = gained_focus && screen->GetNumDisplays() > 1 && (screen->GetDisplayNearestWindow(window_).id() != @@ -2508,7 +2505,7 @@ RenderWidgetHostViewAura::~RenderWidgetHostViewAura() { window_->GetHost()->RemoveObserver(this); UnlockMouse(); aura::client::SetTooltipText(window_, NULL); - gfx::Screen::GetScreenFor(window_)->RemoveObserver(this); + gfx::Screen::GetScreen()->RemoveObserver(this); // This call is usually no-op since |this| object is already removed from // the Aura root window and we don't have a way to get an input method @@ -2544,7 +2541,7 @@ void RenderWidgetHostViewAura::CreateAuraWindow() { aura::client::SetActivationDelegate(window_, this); aura::client::SetFocusChangeObserver(window_, this); window_->set_layer_owner_delegate(delegated_frame_host_.get()); - gfx::Screen::GetScreenFor(window_)->AddObserver(this); + gfx::Screen::GetScreen()->AddObserver(this); } void RenderWidgetHostViewAura::UpdateCursorIfOverSelf() { @@ -2555,7 +2552,7 @@ void RenderWidgetHostViewAura::UpdateCursorIfOverSelf() { if (!root_window) return; - gfx::Screen* screen = gfx::Screen::GetScreenFor(GetNativeView()); + gfx::Screen* screen = gfx::Screen::GetScreen(); DCHECK(screen); gfx::Point cursor_screen_point = screen->GetCursorScreenPoint(); @@ -2703,15 +2700,7 @@ void RenderWidgetHostViewAura::SnapToPhysicalPixelBoundary() { // to avoid the web contents area looking blurry we translate the web contents // in the +x, +y direction to land on the nearest pixel boundary. This may // cause the bottom and right edges to be clipped slightly, but that's ok. - aura::Window* snapped = NULL; - // On desktop, use the root window. On alternative environment (ash), - // use the toplevel window which must be already snapped. - if (gfx::Screen::GetScreenFor(window_) != - gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_ALTERNATE)) { - snapped = window_->GetRootWindow(); - } else { - snapped = window_->GetToplevelWindow(); - } + aura::Window* snapped = window_->GetRootWindow(); if (snapped && snapped != window_) ui::SnapLayerToPhysicalPixelBoundary(snapped->layer(), window_->layer()); diff --git a/content/browser/renderer_host/render_widget_host_view_base.cc b/content/browser/renderer_host/render_widget_host_view_base.cc index 3bd1ffc..6adada7 100644 --- a/content/browser/renderer_host/render_widget_host_view_base.cc +++ b/content/browser/renderer_host/render_widget_host_view_base.cc @@ -401,9 +401,8 @@ bool RenderWidgetHostViewBase::GetBackgroundOpaque() { } gfx::Size RenderWidgetHostViewBase::GetPhysicalBackingSize() const { - gfx::NativeView view = GetNativeView(); gfx::Display display = - gfx::Screen::GetScreenFor(view)->GetDisplayNearestWindow(view); + gfx::Screen::GetScreen()->GetDisplayNearestWindow(GetNativeView()); return gfx::ScaleToCeiledSize(GetRequestedRendererSize(), display.device_scale_factor()); } @@ -535,7 +534,7 @@ void RenderWidgetHostViewBase::UpdateScreenInfo(gfx::NativeView view) { bool RenderWidgetHostViewBase::HasDisplayPropertyChanged(gfx::NativeView view) { gfx::Display display = - gfx::Screen::GetScreenFor(view)->GetDisplayNearestWindow(view); + gfx::Screen::GetScreen()->GetDisplayNearestWindow(view); if (current_display_area_ == display.work_area() && current_device_scale_factor_ == display.device_scale_factor() && current_display_rotation_ == display.rotation()) { diff --git a/content/browser/renderer_host/render_widget_host_view_mac.mm b/content/browser/renderer_host/render_widget_host_view_mac.mm index 18dcf46..87b86b0 100644 --- a/content/browser/renderer_host/render_widget_host_view_mac.mm +++ b/content/browser/renderer_host/render_widget_host_view_mac.mm @@ -396,7 +396,7 @@ NSWindow* ApparentWindowForView(NSView* view) { blink::WebScreenInfo GetWebScreenInfo(NSView* view) { gfx::Display display = - gfx::Screen::GetNativeScreen()->GetDisplayNearestWindow(view); + gfx::Screen::GetScreen()->GetDisplayNearestWindow(view); NSScreen* screen = [NSScreen deepestScreen]; @@ -539,7 +539,7 @@ RenderWidgetHostViewMac::RenderWidgetHostViewMac(RenderWidgetHost* widget, root_layer_.reset(new ui::Layer(ui::LAYER_SOLID_COLOR)); delegated_frame_host_.reset(new DelegatedFrameHost(this)); - gfx::Screen::GetScreenFor(cocoa_view_)->AddObserver(this); + gfx::Screen::GetScreen()->AddObserver(this); if (!is_guest_view_hack_) render_widget_host_->SetView(this); @@ -555,7 +555,7 @@ RenderWidgetHostViewMac::RenderWidgetHostViewMac(RenderWidgetHost* widget, } RenderWidgetHostViewMac::~RenderWidgetHostViewMac() { - gfx::Screen::GetScreenFor(cocoa_view_)->RemoveObserver(this); + gfx::Screen::GetScreen()->RemoveObserver(this); // This is being called from |cocoa_view_|'s destructor, so invalidate the // pointer. @@ -1574,7 +1574,7 @@ uint32_t RenderWidgetHostViewMac::SurfaceIdNamespaceAtPoint( gfx::Point* transformed_point) { // The surface hittest happens in device pixels, so we need to convert the // |point| from DIPs to pixels before hittesting. - float scale_factor = gfx::Screen::GetScreenFor(cocoa_view_) + float scale_factor = gfx::Screen::GetScreen() ->GetDisplayNearestWindow(cocoa_view_) .device_scale_factor(); gfx::Point point_in_pixels = gfx::ConvertPointToPixel(scale_factor, point); @@ -1759,7 +1759,7 @@ void RenderWidgetHostViewMac::OnDisplayRemoved(const gfx::Display& display) { void RenderWidgetHostViewMac::OnDisplayMetricsChanged( const gfx::Display& display, uint32_t metrics) { - gfx::Screen* screen = gfx::Screen::GetScreenFor(cocoa_view_); + gfx::Screen* screen = gfx::Screen::GetScreen(); if (display.id() != screen->GetDisplayNearestWindow(cocoa_view_).id()) return; diff --git a/content/browser/web_contents/web_contents_view_aura.cc b/content/browser/web_contents/web_contents_view_aura.cc index 6de5575..30db92b 100644 --- a/content/browser/web_contents/web_contents_view_aura.cc +++ b/content/browser/web_contents/web_contents_view_aura.cc @@ -695,8 +695,7 @@ void WebContentsViewAura::SizeChangedCommon(const gfx::Size& size) { void WebContentsViewAura::EndDrag(blink::WebDragOperationsMask ops) { aura::Window* root_window = GetNativeView()->GetRootWindow(); - gfx::Point screen_loc = - gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint(); + gfx::Point screen_loc = gfx::Screen::GetScreen()->GetCursorScreenPoint(); gfx::Point client_loc = screen_loc; RenderViewHost* rvh = web_contents_->GetRenderViewHost(); aura::Window* window = rvh->GetWidget()->GetView()->GetNativeView(); @@ -1205,8 +1204,7 @@ void WebContentsViewAura::OnMouseEvent(ui::MouseEvent* event) { web_contents_->GetDelegate()->ActivateContents(web_contents_); web_contents_->GetDelegate()->ContentsMouseEvent( - web_contents_, - gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint(), + web_contents_, gfx::Screen::GetScreen()->GetCursorScreenPoint(), type == ui::ET_MOUSE_MOVED, type == ui::ET_MOUSE_EXITED); } @@ -1231,8 +1229,7 @@ void WebContentsViewAura::OnDragEntered(const ui::DropTargetEvent& event) { if (drag_dest_delegate_) drag_dest_delegate_->DragInitialize(web_contents_); - gfx::Point screen_pt = - gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint(); + gfx::Point screen_pt = gfx::Screen::GetScreen()->GetCursorScreenPoint(); web_contents_->GetRenderViewHost()->DragTargetDragEnter( *current_drop_data_.get(), event.location(), screen_pt, op, ConvertAuraEventFlagsToWebInputEventModifiers(event.flags())); @@ -1252,8 +1249,7 @@ int WebContentsViewAura::OnDragUpdated(const ui::DropTargetEvent& event) { return ui::DragDropTypes::DRAG_NONE; blink::WebDragOperationsMask op = ConvertToWeb(event.source_operations()); - gfx::Point screen_pt = - gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint(); + gfx::Point screen_pt = gfx::Screen::GetScreen()->GetCursorScreenPoint(); web_contents_->GetRenderViewHost()->DragTargetDragOver( event.location(), screen_pt, op, ConvertAuraEventFlagsToWebInputEventModifiers(event.flags())); @@ -1288,8 +1284,7 @@ int WebContentsViewAura::OnPerformDrop(const ui::DropTargetEvent& event) { return ui::DragDropTypes::DRAG_NONE; web_contents_->GetRenderViewHost()->DragTargetDrop( - event.location(), - gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint(), + event.location(), gfx::Screen::GetScreen()->GetCursorScreenPoint(), ConvertAuraEventFlagsToWebInputEventModifiers(event.flags())); if (drag_dest_delegate_) drag_dest_delegate_->OnDrop(); diff --git a/content/common/page_state_serialization.cc b/content/common/page_state_serialization.cc index 53ddf09..68974ae 100644 --- a/content/common/page_state_serialization.cc +++ b/content/common/page_state_serialization.cc @@ -606,8 +606,7 @@ void ReadFrameState(SerializeObject* obj, bool is_top, float device_scale_factor = g_device_scale_factor_for_testing; if (!device_scale_factor) { device_scale_factor = - gfx::Screen::GetNativeScreen()->GetPrimaryDisplay(). - device_scale_factor(); + gfx::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor(); } state->scroll_offset = gfx::Point(state->scroll_offset.x() / state->page_scale_factor, diff --git a/content/shell/browser/shell_aura.cc b/content/shell/browser/shell_aura.cc index edc83ef..47ad012 100644 --- a/content/shell/browser/shell_aura.cc +++ b/content/shell/browser/shell_aura.cc @@ -17,7 +17,7 @@ namespace content { void Shell::PlatformInitialize(const gfx::Size& default_window_size) { CHECK(!platform_); aura::TestScreen* screen = aura::TestScreen::Create(gfx::Size()); - gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, screen); + gfx::Screen::SetScreenInstance(screen); platform_ = new ShellPlatformDataAura(default_window_size); } diff --git a/content/shell/browser/shell_views.cc b/content/shell/browser/shell_views.cc index a16fdc0..2de6867 100644 --- a/content/shell/browser/shell_views.cc +++ b/content/shell/browser/shell_views.cc @@ -397,12 +397,11 @@ void Shell::PlatformInitialize(const gfx::Size& default_window_size) { #endif #if defined(OS_CHROMEOS) test_screen_ = aura::TestScreen::Create(gfx::Size()); - gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, test_screen_); + gfx::Screen::SetScreenInstance(test_screen_); wm_test_helper_ = new wm::WMTestHelper(default_window_size, GetContextFactory()); #else - gfx::Screen::SetScreenInstance( - gfx::SCREEN_TYPE_NATIVE, views::CreateDesktopScreen()); + gfx::Screen::SetScreenInstance(views::CreateDesktopScreen()); #endif views_delegate_ = new views::DesktopTestViewsDelegate(); } diff --git a/extensions/browser/api/capture_web_contents_function.cc b/extensions/browser/api/capture_web_contents_function.cc index e10842d..77c8a3e 100644 --- a/extensions/browser/api/capture_web_contents_function.cc +++ b/extensions/browser/api/capture_web_contents_function.cc @@ -78,7 +78,7 @@ bool CaptureWebContentsFunction::RunAsync() { const gfx::Size view_size = view->GetViewBounds().size(); gfx::Size bitmap_size = view_size; const gfx::NativeView native_view = view->GetNativeView(); - gfx::Screen* const screen = gfx::Screen::GetScreenFor(native_view); + gfx::Screen* const screen = gfx::Screen::GetScreen(); const float scale = screen->GetDisplayNearestWindow(native_view).device_scale_factor(); if (scale > 1.0f) diff --git a/extensions/browser/api/system_display/display_info_provider.cc b/extensions/browser/api/system_display/display_info_provider.cc index b49949b..df7b26a 100644 --- a/extensions/browser/api/system_display/display_info_provider.cc +++ b/extensions/browser/api/system_display/display_info_provider.cc @@ -77,8 +77,7 @@ DisplayInfoProvider::CreateDisplayUnitInfo(const gfx::Display& display, void DisplayInfoProvider::EnableUnifiedDesktop(bool enable) {} DisplayInfo DisplayInfoProvider::GetAllDisplaysInfo() { - // TODO(scottmg): Native is wrong http://crbug.com/133312 - gfx::Screen* screen = gfx::Screen::GetNativeScreen(); + gfx::Screen* screen = gfx::Screen::GetScreen(); int64_t primary_id = screen->GetPrimaryDisplay().id(); std::vector<gfx::Display> displays = screen->GetAllDisplays(); DisplayInfo all_displays; diff --git a/extensions/browser/api/system_display/system_display_apitest.cc b/extensions/browser/api/system_display/system_display_apitest.cc index 1f3974e..cdcb519 100644 --- a/extensions/browser/api/system_display/system_display_apitest.cc +++ b/extensions/browser/api/system_display/system_display_apitest.cc @@ -142,9 +142,8 @@ class SystemDisplayApiTest : public ShellApiTest { void SetUpOnMainThread() override { ShellApiTest::SetUpOnMainThread(); - ANNOTATE_LEAKING_OBJECT_PTR( - gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_NATIVE)); - gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, screen_.get()); + ANNOTATE_LEAKING_OBJECT_PTR(gfx::Screen::GetScreen()); + gfx::Screen::SetScreenInstance(screen_.get()); DisplayInfoProvider::InitializeForTesting(provider_.get()); } diff --git a/extensions/browser/app_window/app_window.cc b/extensions/browser/app_window/app_window.cc index 75d5d40..5881f30 100644 --- a/extensions/browser/app_window/app_window.cc +++ b/extensions/browser/app_window/app_window.cc @@ -851,7 +851,7 @@ void AppWindow::SetNativeWindowFullscreen() { bool AppWindow::IntersectsWithTaskbar() const { #if defined(OS_WIN) - gfx::Screen* screen = gfx::Screen::GetNativeScreen(); + gfx::Screen* screen = gfx::Screen::GetScreen(); gfx::Rect window_bounds = native_app_window_->GetRestoredBounds(); std::vector<gfx::Display> displays = screen->GetAllDisplays(); @@ -1012,7 +1012,7 @@ void AppWindow::SaveWindowPosition() { gfx::Rect bounds = native_app_window_->GetRestoredBounds(); gfx::Rect screen_bounds = - gfx::Screen::GetNativeScreen()->GetDisplayMatching(bounds).work_area(); + gfx::Screen::GetScreen()->GetDisplayMatching(bounds).work_area(); ui::WindowShowState window_state = native_app_window_->GetRestoredState(); cache->SaveGeometry( extension_id(), window_key_, bounds, screen_bounds, window_state); @@ -1078,7 +1078,7 @@ AppWindow::CreateParams AppWindow::LoadDefaults(CreateParams params) &cached_state)) { // App window has cached screen bounds, make sure it fits on screen in // case the screen resolution changed. - gfx::Screen* screen = gfx::Screen::GetNativeScreen(); + gfx::Screen* screen = gfx::Screen::GetScreen(); gfx::Display display = screen->GetDisplayMatching(cached_bounds); gfx::Rect current_screen_bounds = display.work_area(); SizeConstraints constraints(params.GetWindowMinimumSize(gfx::Insets()), diff --git a/extensions/shell/browser/shell_desktop_controller_aura.cc b/extensions/shell/browser/shell_desktop_controller_aura.cc index 9fc1876..18474de 100644 --- a/extensions/shell/browser/shell_desktop_controller_aura.cc +++ b/extensions/shell/browser/shell_desktop_controller_aura.cc @@ -269,8 +269,7 @@ void ShellDesktopControllerAura::InitWindowManager() { cursor_manager_.reset( new wm::CursorManager(scoped_ptr<wm::NativeCursorManager>( new ShellNativeCursorManager(host_.get())))); - cursor_manager_->SetDisplay( - gfx::Screen::GetNativeScreen()->GetPrimaryDisplay()); + cursor_manager_->SetDisplay(gfx::Screen::GetScreen()->GetPrimaryDisplay()); cursor_manager_->SetCursor(ui::kCursorPointer); aura::client::SetCursorClient(host_->window(), cursor_manager_.get()); @@ -298,7 +297,7 @@ void ShellDesktopControllerAura::CreateRootWindow() { size = gfx::Size(1920, 1080); screen_.reset(new ShellScreen(size)); - gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, screen_.get()); + gfx::Screen::SetScreenInstance(screen_.get()); // TODO(mukai): Set up input method. host_.reset(screen_->CreateHostForPrimaryDisplay()); diff --git a/extensions/shell/browser/shell_desktop_controller_mac.mm b/extensions/shell/browser/shell_desktop_controller_mac.mm index 9789787..7731b0a 100644 --- a/extensions/shell/browser/shell_desktop_controller_mac.mm +++ b/extensions/shell/browser/shell_desktop_controller_mac.mm @@ -26,7 +26,7 @@ ShellDesktopControllerMac::~ShellDesktopControllerMac() { gfx::Size ShellDesktopControllerMac::GetWindowSize() { // This is the full screen size. - return gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().bounds().size(); + return gfx::Screen::GetScreen()->GetPrimaryDisplay().bounds().size(); } AppWindow* ShellDesktopControllerMac::CreateAppWindow( diff --git a/media/capture/video/linux/video_capture_device_chromeos.cc b/media/capture/video/linux/video_capture_device_chromeos.cc index a8f6e5e..5c5e397 100644 --- a/media/capture/video/linux/video_capture_device_chromeos.cc +++ b/media/capture/video/linux/video_capture_device_chromeos.cc @@ -59,8 +59,7 @@ class VideoCaptureDeviceChromeOS::ScreenObserverDelegate void AddObserverOnUIThread() { DCHECK(ui_task_runner_->BelongsToCurrentThread()); - gfx::Screen* screen = - gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_ALTERNATE); + gfx::Screen* screen = gfx::Screen::GetScreen(); if (screen) { screen->AddObserver(this); SendDisplayRotation(screen->GetPrimaryDisplay()); @@ -69,8 +68,7 @@ class VideoCaptureDeviceChromeOS::ScreenObserverDelegate void RemoveObserverOnUIThread() { DCHECK(ui_task_runner_->BelongsToCurrentThread()); - gfx::Screen* screen = - gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_ALTERNATE); + gfx::Screen* screen = gfx::Screen::GetScreen(); if (screen) screen->RemoveObserver(this); } diff --git a/ui/aura/bench/bench_main.cc b/ui/aura/bench/bench_main.cc index 918990a..03f66cb 100644 --- a/ui/aura/bench/bench_main.cc +++ b/ui/aura/bench/bench_main.cc @@ -328,7 +328,7 @@ int main(int argc, char** argv) { aura::Env::GetInstance()->set_context_factory(context_factory.get()); scoped_ptr<aura::TestScreen> test_screen( aura::TestScreen::Create(GetFullscreenSize())); - gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, test_screen.get()); + gfx::Screen::SetScreenInstance(test_screen.get()); scoped_ptr<aura::WindowTreeHost> host( test_screen->CreateHostForPrimaryDisplay()); aura::client::SetCaptureClient( diff --git a/ui/aura/demo/demo_main.cc b/ui/aura/demo/demo_main.cc index f485a8c..4a2467f 100644 --- a/ui/aura/demo/demo_main.cc +++ b/ui/aura/demo/demo_main.cc @@ -150,7 +150,7 @@ int DemoMain() { aura::Env::GetInstance()->set_context_factory(context_factory.get()); scoped_ptr<aura::TestScreen> test_screen( aura::TestScreen::Create(gfx::Size())); - gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, test_screen.get()); + gfx::Screen::SetScreenInstance(test_screen.get()); scoped_ptr<aura::WindowTreeHost> host( test_screen->CreateHostForPrimaryDisplay()); scoped_ptr<DemoWindowTreeClient> window_tree_client( diff --git a/ui/aura/test/aura_test_helper.cc b/ui/aura/test/aura_test_helper.cc index 9d8c305..bc7f0ca 100644 --- a/ui/aura/test/aura_test_helper.cc +++ b/ui/aura/test/aura_test_helper.cc @@ -72,7 +72,7 @@ void AuraTestHelper::SetUp(ui::ContextFactory* context_factory) { gfx::Size host_size(800, 600); test_screen_.reset(TestScreen::Create(host_size)); - gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, test_screen_.get()); + gfx::Screen::SetScreenInstance(test_screen_.get()); host_.reset(test_screen_->CreateHostForPrimaryDisplay()); focus_client_.reset(new TestFocusClient); @@ -94,7 +94,7 @@ void AuraTestHelper::TearDown() { host_.reset(); ui::GestureRecognizer::Reset(); test_screen_.reset(); - gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, NULL); + gfx::Screen::SetScreenInstance(NULL); #if defined(USE_X11) ui::test::ResetXCursorCache(); diff --git a/ui/aura/window.cc b/ui/aura/window.cc index bd9f023..0b848e9 100644 --- a/ui/aura/window.cc +++ b/ui/aura/window.cc @@ -67,8 +67,7 @@ class ScopedCursorHider { client::CursorClient* cursor_client = client::GetCursorClient(window_); if (cursor_client) { const gfx::Display& display = - gfx::Screen::GetScreenFor(window_)->GetDisplayNearestWindow( - window_); + gfx::Screen::GetScreen()->GetDisplayNearestWindow(window_); cursor_client->SetDisplay(display); cursor_client->ShowCursor(); } diff --git a/ui/aura/window_tree_host.cc b/ui/aura/window_tree_host.cc index bb988e1..aa6fb73 100644 --- a/ui/aura/window_tree_host.cc +++ b/ui/aura/window_tree_host.cc @@ -32,8 +32,8 @@ const char kWindowTreeHostForAcceleratedWidget[] = "__AURA_WINDOW_TREE_HOST_ACCELERATED_WIDGET__"; float GetDeviceScaleFactorFromDisplay(Window* window) { - gfx::Display display = gfx::Screen::GetScreenFor(window)-> - GetDisplayNearestWindow(window); + gfx::Display display = + gfx::Screen::GetScreen()->GetDisplayNearestWindow(window); DCHECK(display.is_valid()); return display.device_scale_factor(); } @@ -314,7 +314,7 @@ void WindowTreeHost::MoveCursorToInternal(const gfx::Point& root_location, client::CursorClient* cursor_client = client::GetCursorClient(window()); if (cursor_client) { const gfx::Display& display = - gfx::Screen::GetScreenFor(window())->GetDisplayNearestWindow(window()); + gfx::Screen::GetScreen()->GetDisplayNearestWindow(window()); cursor_client->SetDisplay(display); } dispatcher()->OnCursorMovedToRootLocation(root_location); diff --git a/ui/aura/window_tree_host_platform.cc b/ui/aura/window_tree_host_platform.cc index 1e4baf6..d2781e4 100644 --- a/ui/aura/window_tree_host_platform.cc +++ b/ui/aura/window_tree_host_platform.cc @@ -125,7 +125,7 @@ void WindowTreeHostPlatform::OnCursorVisibilityChangedNative(bool show) { void WindowTreeHostPlatform::OnBoundsChanged(const gfx::Rect& new_bounds) { float current_scale = compositor()->device_scale_factor(); - float new_scale = gfx::Screen::GetScreenFor(window()) + float new_scale = gfx::Screen::GetScreen() ->GetDisplayNearestWindow(window()) .device_scale_factor(); gfx::Rect old_bounds = bounds_; diff --git a/ui/aura/window_tree_host_x11.cc b/ui/aura/window_tree_host_x11.cc index f06a806..43f7265 100644 --- a/ui/aura/window_tree_host_x11.cc +++ b/ui/aura/window_tree_host_x11.cc @@ -256,8 +256,8 @@ uint32_t WindowTreeHostX11::DispatchEvent(const ui::PlatformEvent& event) { client::CursorClient* cursor_client = client::GetCursorClient(root_window); if (cursor_client) { - const gfx::Display display = gfx::Screen::GetScreenFor( - root_window)->GetDisplayNearestWindow(root_window); + const gfx::Display display = + gfx::Screen::GetScreen()->GetDisplayNearestWindow(root_window); cursor_client->SetDisplay(display); } // EnterNotify creates ET_MOUSE_MOVE. Mark as synthesized as this is @@ -398,8 +398,9 @@ void WindowTreeHostX11::SetBounds(const gfx::Rect& bounds) { // Even if the host window's size doesn't change, aura's root window // size, which is in DIP, changes when the scale changes. float current_scale = compositor()->device_scale_factor(); - float new_scale = gfx::Screen::GetScreenFor(window())-> - GetDisplayNearestWindow(window()).device_scale_factor(); + float new_scale = gfx::Screen::GetScreen() + ->GetDisplayNearestWindow(window()) + .device_scale_factor(); bool origin_changed = bounds_.origin() != bounds.origin(); bool size_changed = bounds_.size() != bounds.size(); XWindowChanges changes = {0}; diff --git a/ui/aura/window_unittest.cc b/ui/aura/window_unittest.cc index 60792c2..f2699eb 100644 --- a/ui/aura/window_unittest.cc +++ b/ui/aura/window_unittest.cc @@ -358,19 +358,19 @@ TEST_F(WindowTest, MoveCursorTo) { Window* root = root_window(); root->MoveCursorTo(gfx::Point(10, 10)); EXPECT_EQ("10,10", - gfx::Screen::GetScreenFor(root)->GetCursorScreenPoint().ToString()); + gfx::Screen::GetScreen()->GetCursorScreenPoint().ToString()); w1->MoveCursorTo(gfx::Point(10, 10)); EXPECT_EQ("20,20", - gfx::Screen::GetScreenFor(root)->GetCursorScreenPoint().ToString()); + gfx::Screen::GetScreen()->GetCursorScreenPoint().ToString()); w11->MoveCursorTo(gfx::Point(10, 10)); EXPECT_EQ("25,25", - gfx::Screen::GetScreenFor(root)->GetCursorScreenPoint().ToString()); + gfx::Screen::GetScreen()->GetCursorScreenPoint().ToString()); w111->MoveCursorTo(gfx::Point(10, 10)); EXPECT_EQ("30,30", - gfx::Screen::GetScreenFor(root)->GetCursorScreenPoint().ToString()); + gfx::Screen::GetScreen()->GetCursorScreenPoint().ToString()); w1111->MoveCursorTo(gfx::Point(10, 10)); EXPECT_EQ("35,35", - gfx::Screen::GetScreenFor(root)->GetCursorScreenPoint().ToString()); + gfx::Screen::GetScreen()->GetCursorScreenPoint().ToString()); } TEST_F(WindowTest, ContainsMouse) { @@ -398,8 +398,8 @@ TEST_F(WindowTest, MoveCursorToWithTransformRootWindow) { // TODO(yoshiki): fix this to build on Windows. See crbug.com/133413.OD EXPECT_EQ("50,120", QueryLatestMousePositionRequestInHost(host()).ToString()); #endif - EXPECT_EQ("10,10", gfx::Screen::GetScreenFor( - root_window())->GetCursorScreenPoint().ToString()); + EXPECT_EQ("10,10", + gfx::Screen::GetScreen()->GetCursorScreenPoint().ToString()); } // Tests Window::ConvertPointToWindow() with transform to non-root windows. @@ -413,21 +413,21 @@ TEST_F(WindowTest, MoveCursorToWithTransformWindow) { w1->SetTransform(transform1); w1->MoveCursorTo(gfx::Point(10, 10)); EXPECT_EQ("30,30", - gfx::Screen::GetScreenFor(w1.get())->GetCursorScreenPoint().ToString()); + gfx::Screen::GetScreen()->GetCursorScreenPoint().ToString()); gfx::Transform transform2; transform2.Translate(-10, 20); w1->SetTransform(transform2); w1->MoveCursorTo(gfx::Point(10, 10)); EXPECT_EQ("10,40", - gfx::Screen::GetScreenFor(w1.get())->GetCursorScreenPoint().ToString()); + gfx::Screen::GetScreen()->GetCursorScreenPoint().ToString()); gfx::Transform transform3; transform3.Rotate(90.0); w1->SetTransform(transform3); w1->MoveCursorTo(gfx::Point(5, 5)); EXPECT_EQ("5,15", - gfx::Screen::GetScreenFor(w1.get())->GetCursorScreenPoint().ToString()); + gfx::Screen::GetScreen()->GetCursorScreenPoint().ToString()); gfx::Transform transform4; transform4.Translate(100.0, 100.0); @@ -436,7 +436,7 @@ TEST_F(WindowTest, MoveCursorToWithTransformWindow) { w1->SetTransform(transform4); w1->MoveCursorTo(gfx::Point(10, 10)); EXPECT_EQ("60,130", - gfx::Screen::GetScreenFor(w1.get())->GetCursorScreenPoint().ToString()); + gfx::Screen::GetScreen()->GetCursorScreenPoint().ToString()); } // Test Window::ConvertPointToWindow() with complex transforms to both root and @@ -453,8 +453,6 @@ TEST_F(WindowTest, MoveCursorToWithComplexTransform) { scoped_ptr<Window> w1111( CreateTestWindow(SK_ColorRED, 1111, gfx::Rect(5, 5, 50, 50), w111.get())); - Window* root = root_window(); - // The root window expects transforms that produce integer rects. gfx::Transform root_transform; root_transform.Translate(60.0, 70.0); @@ -479,7 +477,7 @@ TEST_F(WindowTest, MoveCursorToWithComplexTransform) { EXPECT_EQ("169,80", QueryLatestMousePositionRequestInHost(host()).ToString()); #endif EXPECT_EQ("20,53", - gfx::Screen::GetScreenFor(root)->GetCursorScreenPoint().ToString()); + gfx::Screen::GetScreen()->GetCursorScreenPoint().ToString()); } // Tests that we do not crash when a Window is destroyed by going out of @@ -1588,7 +1586,7 @@ TEST_F(WindowTest, IgnoreEventsTest) { TEST_F(WindowTest, Transform) { gfx::Size size = host()->GetBounds().size(); EXPECT_EQ(gfx::Rect(size), - gfx::Screen::GetScreenFor(root_window())->GetDisplayNearestPoint( + gfx::Screen::GetScreen()->GetDisplayNearestPoint( gfx::Point()).bounds()); // Rotate it clock-wise 90 degrees. @@ -1603,7 +1601,7 @@ TEST_F(WindowTest, Transform) { root_window()->bounds().size().ToString()); EXPECT_EQ( gfx::Rect(transformed_size).ToString(), - gfx::Screen::GetScreenFor(root_window())->GetDisplayNearestPoint( + gfx::Screen::GetScreen()->GetDisplayNearestPoint( gfx::Point()).bounds().ToString()); // Host size shouldn't change. diff --git a/ui/base/layout.cc b/ui/base/layout.cc index f4ebc01..54ae5e6 100644 --- a/ui/base/layout.cc +++ b/ui/base/layout.cc @@ -115,9 +115,9 @@ ScopedSetSupportedScaleFactors::~ScopedSetSupportedScaleFactors() { #if !defined(OS_MACOSX) float GetScaleFactorForNativeView(gfx::NativeView view) { - gfx::Screen* screen = gfx::Screen::GetScreenFor(view); - gfx::Display display = screen->GetDisplayNearestWindow(view); - return display.device_scale_factor(); + return gfx::Screen::GetScreen() + ->GetDisplayNearestWindow(view) + .device_scale_factor(); } #endif // !defined(OS_MACOSX) diff --git a/ui/base/resource/resource_bundle.cc b/ui/base/resource/resource_bundle.cc index 9ab84df..840c345 100644 --- a/ui/base/resource/resource_bundle.cc +++ b/ui/base/resource/resource_bundle.cc @@ -621,7 +621,7 @@ void ResourceBundle::InitSharedInstance(Delegate* delegate) { if (closest != SCALE_FACTOR_100P) supported_scale_factors.push_back(closest); #elif defined(OS_IOS) - gfx::Display display = gfx::Screen::GetNativeScreen()->GetPrimaryDisplay(); + gfx::Display display = gfx::Screen::GetScreen()->GetPrimaryDisplay(); if (display.device_scale_factor() > 2.0) { DCHECK_EQ(3.0, display.device_scale_factor()); supported_scale_factors.push_back(SCALE_FACTOR_300P); diff --git a/ui/chromeos/ime/candidate_window_view.cc b/ui/chromeos/ime/candidate_window_view.cc index 6007778..cd4aa8a 100644 --- a/ui/chromeos/ime/candidate_window_view.cc +++ b/ui/chromeos/ime/candidate_window_view.cc @@ -55,8 +55,8 @@ class CandidateWindowBorder : public views::BubbleBorder { // It cannot use the normal logic of arrow offset for horizontal offscreen, // because the arrow must be in the content's edge. But CandidateWindow has // to be visible even when |anchor_rect| is out of the screen. - gfx::Rect work_area = gfx::Screen::GetNativeScreen()-> - GetDisplayNearestWindow(parent_).work_area(); + gfx::Rect work_area = + gfx::Screen::GetScreen()->GetDisplayNearestWindow(parent_).work_area(); if (bounds.right() > work_area.right()) bounds.set_x(work_area.right() - bounds.width()); if (bounds.x() < work_area.x()) diff --git a/ui/chromeos/ime/mode_indicator_view.cc b/ui/chromeos/ime/mode_indicator_view.cc index a9105eb..8fbcd1d 100644 --- a/ui/chromeos/ime/mode_indicator_view.cc +++ b/ui/chromeos/ime/mode_indicator_view.cc @@ -34,8 +34,9 @@ class ModeIndicatorFrameView : public views::BubbleFrameView { private: // views::BubbleFrameView overrides: gfx::Rect GetAvailableScreenBounds(const gfx::Rect& rect) const override { - return gfx::Screen::GetNativeScreen()->GetDisplayNearestPoint( - rect.CenterPoint()).bounds(); + return gfx::Screen::GetScreen() + ->GetDisplayNearestPoint(rect.CenterPoint()) + .bounds(); } DISALLOW_COPY_AND_ASSIGN(ModeIndicatorFrameView); diff --git a/ui/events/event_utils.cc b/ui/events/event_utils.cc index cb4788d..aa9ed7b 100644 --- a/ui/events/event_utils.cc +++ b/ui/events/event_utils.cc @@ -71,7 +71,7 @@ bool ShouldDefaultToNaturalScroll() { } gfx::Display::TouchSupport GetInternalDisplayTouchSupport() { - gfx::Screen* screen = gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_NATIVE); + gfx::Screen* screen = gfx::Screen::GetScreen(); // No screen in some unit tests. if (!screen) return gfx::Display::TOUCH_SUPPORT_UNKNOWN; diff --git a/ui/events/gesture_detection/gesture_provider_config_helper.cc b/ui/events/gesture_detection/gesture_provider_config_helper.cc index 2708102..c136366 100644 --- a/ui/events/gesture_detection/gesture_provider_config_helper.cc +++ b/ui/events/gesture_detection/gesture_provider_config_helper.cc @@ -90,7 +90,7 @@ GestureProvider::Config GetGestureProviderConfig( break; } - gfx::Screen* screen = gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_NATIVE); + gfx::Screen* screen = gfx::Screen::GetScreen(); // |screen| is sometimes NULL during tests. if (screen) config.display = screen->GetPrimaryDisplay(); diff --git a/ui/gfx/font_render_params_linux.cc b/ui/gfx/font_render_params_linux.cc index a9afcf3..526c19d 100644 --- a/ui/gfx/font_render_params_linux.cc +++ b/ui/gfx/font_render_params_linux.cc @@ -210,7 +210,7 @@ FontRenderParams GetFontRenderParams(const FontRenderParamsQuery& query, #else // Linux does not support per-display DPI, so we use a slightly simpler // code path than on Chrome OS to figure out the device scale factor. - gfx::Screen* screen = gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_NATIVE); + gfx::Screen* screen = gfx::Screen::GetScreen(); if (screen) { gfx::Display display = screen->GetPrimaryDisplay(); actual_query.device_scale_factor = display.device_scale_factor(); diff --git a/ui/gfx/screen.cc b/ui/gfx/screen.cc index 06ec78e..27662e7 100644 --- a/ui/gfx/screen.cc +++ b/ui/gfx/screen.cc @@ -4,14 +4,12 @@ #include "base/logging.h" #include "ui/gfx/screen.h" -#include "ui/gfx/screen_type_delegate.h" namespace gfx { namespace { -Screen* g_screen_[SCREEN_TYPE_LAST + 1]; -ScreenTypeDelegate* g_screen_type_delegate_ = NULL; +Screen* g_screen; } // namespace @@ -22,37 +20,18 @@ Screen::~Screen() { } // static -Screen* Screen::GetScreenFor(NativeView view) { - ScreenType type = SCREEN_TYPE_NATIVE; - if (g_screen_type_delegate_) - type = g_screen_type_delegate_->GetScreenTypeForNativeView(view); - if (type == SCREEN_TYPE_NATIVE) - return GetNativeScreen(); - DCHECK(g_screen_[type]); - return g_screen_[type]; +Screen* Screen::GetScreen() { +#if defined(OS_MACOSX) || defined(OS_ANDROID) + // TODO(scottmg): https://crbug.com/558054 + if (!g_screen) + g_screen = CreateNativeScreen(); +#endif + return g_screen; } // static -void Screen::SetScreenInstance(ScreenType type, Screen* instance) { - DCHECK_LE(type, SCREEN_TYPE_LAST); - g_screen_[type] = instance; -} - -// static -Screen* Screen::GetScreenByType(ScreenType type) { - return g_screen_[type]; -} - -// static -void Screen::SetScreenTypeDelegate(ScreenTypeDelegate* delegate) { - g_screen_type_delegate_ = delegate; -} - -// static -Screen* Screen::GetNativeScreen() { - if (!g_screen_[SCREEN_TYPE_NATIVE]) - g_screen_[SCREEN_TYPE_NATIVE] = CreateNativeScreen(); - return g_screen_[SCREEN_TYPE_NATIVE]; +void Screen::SetScreenInstance(Screen* instance) { + g_screen = instance; } } // namespace gfx diff --git a/ui/gfx/screen.h b/ui/gfx/screen.h index 107ee44..c1eccb8 100644 --- a/ui/gfx/screen.h +++ b/ui/gfx/screen.h @@ -12,7 +12,6 @@ #include "ui/gfx/geometry/point.h" #include "ui/gfx/gfx_export.h" #include "ui/gfx/native_widget_types.h" -#include "ui/gfx/screen_type_delegate.h" namespace gfx { class DisplayObserver; @@ -22,38 +21,20 @@ class Rect; // cursor position, etc. // // Note that this class does not represent an individual display connected to a -// computer -- see the Display class for that. A single Screen object exists on -// most operating systems regardless of the number of connected displays. On -// Windows 8, two Screens exist: one for Metro UI and another for the desktop. +// computer -- see the Display class for that. A single Screen object exists +// regardless of the number of connected displays. class GFX_EXPORT Screen { public: - // Retrieves the Screen that the specified NativeView belongs to. A value of - // NULL is treated as |SCREEN_TYPE_NATIVE|. - static Screen* GetScreenFor(NativeView view); - - // Returns the SCREEN_TYPE_NATIVE Screen. This should be used with caution, - // as it is likely to be incorrect for code that runs on Windows. - static Screen* GetNativeScreen(); - - // Sets the global screen for a particular screen type. Only the _NATIVE - // ScreenType must be provided. - // NOTE: this does not take ownership of |screen|. Tests must be sure to - // reset any state they install. - static void SetScreenInstance(ScreenType type, Screen* instance); - - // Returns the global screen for a particular type. Types other than _NATIVE - // may be NULL. - static Screen* GetScreenByType(ScreenType type); - - // Sets the global ScreenTypeDelegate. May be left unset if the platform - // uses only the _NATIVE ScreenType. - // NOTE: this does not take ownership of |delegate|. Tests must be sure to - // reset any state they install. - static void SetScreenTypeDelegate(ScreenTypeDelegate* delegate); - Screen(); virtual ~Screen(); + // Retrieves the single Screen object. + static Screen* GetScreen(); + + // Sets the global screen. NOTE: this does not take ownership of |screen|. + // Tests must be sure to reset any state they install. + static void SetScreenInstance(Screen* instance); + // Returns the current absolute position of the mouse pointer. virtual gfx::Point GetCursorScreenPoint() = 0; diff --git a/ui/gfx/screen_type_delegate.h b/ui/gfx/screen_type_delegate.h deleted file mode 100644 index 03dad8f..0000000 --- a/ui/gfx/screen_type_delegate.h +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 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 UI_GFX_SCREEN_TYPE_DELEGATE_H_ -#define UI_GFX_SCREEN_TYPE_DELEGATE_H_ - -#include "build/build_config.h" -#include "ui/gfx/native_widget_types.h" - -namespace gfx { - -enum ScreenType { - SCREEN_TYPE_NATIVE = 0, -#if defined(OS_CHROMEOS) - SCREEN_TYPE_ALTERNATE = SCREEN_TYPE_NATIVE, -#else - SCREEN_TYPE_ALTERNATE, -#endif - SCREEN_TYPE_LAST = SCREEN_TYPE_ALTERNATE, -}; - -class GFX_EXPORT ScreenTypeDelegate { - public: - virtual ~ScreenTypeDelegate() {} - - // Determines which ScreenType a given |view| belongs to. - virtual ScreenType GetScreenTypeForNativeView(NativeView view) = 0; -}; - -} // namespace gfx - -#endif // UI_GFX_SCREEN_TYPE_DELEGATE_H_ diff --git a/ui/gfx/screen_unittest.cc b/ui/gfx/screen_unittest.cc index db5a03f..8b63ac7 100644 --- a/ui/gfx/screen_unittest.cc +++ b/ui/gfx/screen_unittest.cc @@ -10,15 +10,14 @@ namespace { TEST(ScreenTest, GetPrimaryDisplaySize) { // We aren't actually testing that it's correct, just that it's sane. - const gfx::Size size = - gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().size(); + const gfx::Size size = gfx::Screen::GetScreen()->GetPrimaryDisplay().size(); EXPECT_GE(size.width(), 1); EXPECT_GE(size.height(), 1); } TEST(ScreenTest, GetNumDisplays) { // We aren't actually testing that it's correct, just that it's sane. - EXPECT_GE(gfx::Screen::GetNativeScreen()->GetNumDisplays(), 1); + EXPECT_GE(gfx::Screen::GetScreen()->GetNumDisplays(), 1); } } // namespace diff --git a/ui/message_center/views/toast_contents_view.cc b/ui/message_center/views/toast_contents_view.cc index a11b3b9..fd2cb46 100644 --- a/ui/message_center/views/toast_contents_view.cc +++ b/ui/message_center/views/toast_contents_view.cc @@ -250,7 +250,7 @@ void ToastContentsView::OnDisplayChanged() { return; collection_->OnDisplayMetricsChanged( - Screen::GetScreenFor(native_view)->GetDisplayNearestWindow(native_view)); + Screen::GetScreen()->GetDisplayNearestWindow(native_view)); } void ToastContentsView::OnWorkAreaChanged() { @@ -263,7 +263,7 @@ void ToastContentsView::OnWorkAreaChanged() { return; collection_->OnDisplayMetricsChanged( - Screen::GetScreenFor(native_view)->GetDisplayNearestWindow(native_view)); + Screen::GetScreen()->GetDisplayNearestWindow(native_view)); } // views::View diff --git a/ui/mojo/init/ui_init.cc b/ui/mojo/init/ui_init.cc index 7be35c7..34b0ae3 100644 --- a/ui/mojo/init/ui_init.cc +++ b/ui/mojo/init/ui_init.cc @@ -43,7 +43,7 @@ class GestureConfigurationMojo : public ui::GestureConfiguration { UIInit::UIInit(const std::vector<gfx::Display>& displays) : screen_(new ScreenMojo(displays)) { - gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, screen_.get()); + gfx::Screen::SetScreenInstance(screen_.get()); #if defined(OS_ANDROID) gesture_configuration_.reset(new GestureConfigurationMojo); ui::GestureConfiguration::SetInstance(gesture_configuration_.get()); @@ -51,7 +51,7 @@ UIInit::UIInit(const std::vector<gfx::Display>& displays) } UIInit::~UIInit() { - gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, nullptr); + gfx::Screen::SetScreenInstance(nullptr); #if defined(OS_ANDROID) ui::GestureConfiguration::SetInstance(nullptr); #endif diff --git a/ui/snapshot/snapshot_android.cc b/ui/snapshot/snapshot_android.cc index 0a123b9..fb7d40d 100644 --- a/ui/snapshot/snapshot_android.cc +++ b/ui/snapshot/snapshot_android.cc @@ -41,8 +41,7 @@ static void MakeAsyncCopyRequest( scoped_ptr<cc::CopyOutputRequest> request = cc::CopyOutputRequest::CreateBitmapRequest(callback); - const gfx::Display& display = - gfx::Screen::GetNativeScreen()->GetPrimaryDisplay(); + const gfx::Display& display = gfx::Screen::GetScreen()->GetPrimaryDisplay(); float device_scale_factor = display.device_scale_factor(); gfx::Rect source_rect_in_pixel = gfx::ScaleToEnclosingRect(source_rect, device_scale_factor); diff --git a/ui/views/bubble/bubble_frame_view.cc b/ui/views/bubble/bubble_frame_view.cc index b11ee79..3d1f195 100644 --- a/ui/views/bubble/bubble_frame_view.cc +++ b/ui/views/bubble/bubble_frame_view.cc @@ -370,9 +370,9 @@ gfx::Rect BubbleFrameView::GetUpdatedWindowBounds(const gfx::Rect& anchor_rect, gfx::Rect BubbleFrameView::GetAvailableScreenBounds( const gfx::Rect& rect) const { // The bubble attempts to fit within the current screen bounds. - // TODO(scottmg): Native is wrong. http://crbug.com/133312 - return gfx::Screen::GetNativeScreen()->GetDisplayNearestPoint( - rect.CenterPoint()).work_area(); + return gfx::Screen::GetScreen() + ->GetDisplayNearestPoint(rect.CenterPoint()) + .work_area(); } bool BubbleFrameView::IsCloseButtonVisible() const { diff --git a/ui/views/cocoa/bridged_native_widget.mm b/ui/views/cocoa/bridged_native_widget.mm index 24bba74..6e69b92 100644 --- a/ui/views/cocoa/bridged_native_widget.mm +++ b/ui/views/cocoa/bridged_native_widget.mm @@ -96,7 +96,7 @@ int kWindowPropertiesKey; float GetDeviceScaleFactorFromView(NSView* view) { gfx::Display display = - gfx::Screen::GetScreenFor(view)->GetDisplayNearestWindow(view); + gfx::Screen::GetScreen()->GetDisplayNearestWindow(view); DCHECK(display.is_valid()); return display.device_scale_factor(); } diff --git a/ui/views/cocoa/tooltip_manager_mac.h b/ui/views/cocoa/tooltip_manager_mac.h index a7977a9..208fb4e 100644 --- a/ui/views/cocoa/tooltip_manager_mac.h +++ b/ui/views/cocoa/tooltip_manager_mac.h @@ -18,8 +18,7 @@ class TooltipManagerMac : public TooltipManager { ~TooltipManagerMac() override; // TooltipManager: - int GetMaxWidth(const gfx::Point& location, - gfx::NativeView context) const override; + int GetMaxWidth(const gfx::Point& location) const override; const gfx::FontList& GetFontList() const override; void UpdateTooltip() override; void TooltipTextChanged(View* view) override; diff --git a/ui/views/cocoa/tooltip_manager_mac.mm b/ui/views/cocoa/tooltip_manager_mac.mm index b96d122..3101ee1 100644 --- a/ui/views/cocoa/tooltip_manager_mac.mm +++ b/ui/views/cocoa/tooltip_manager_mac.mm @@ -25,8 +25,7 @@ TooltipManagerMac::TooltipManagerMac(BridgedNativeWidget* widget) TooltipManagerMac::~TooltipManagerMac() { } -int TooltipManagerMac::GetMaxWidth(const gfx::Point& location, - gfx::NativeView context) const { +int TooltipManagerMac::GetMaxWidth(const gfx::Point& location) const { return kTooltipMaxWidthPixels; } diff --git a/ui/views/controls/button/custom_button_unittest.cc b/ui/views/controls/button/custom_button_unittest.cc index 41de346..0ff9f95 100644 --- a/ui/views/controls/button/custom_button_unittest.cc +++ b/ui/views/controls/button/custom_button_unittest.cc @@ -443,8 +443,7 @@ TEST_F(CustomButtonTest, AsCustomButton) { // Note: Ink drop is not hidden upon release because CustomButton descendants // may enter a different ink drop state. TEST_F(CustomButtonTest, ButtonClickTogglesInkDrop) { - gfx::Point old_cursor = gfx::Screen::GetScreenFor( - widget()->GetNativeView())->GetCursorScreenPoint(); + gfx::Point old_cursor = gfx::Screen::GetScreen()->GetCursorScreenPoint(); CreateButtonWithInkDrop(); ui::test::EventGenerator generator(GetContext(), widget()->GetNativeWindow()); @@ -459,8 +458,7 @@ TEST_F(CustomButtonTest, ButtonClickTogglesInkDrop) { // Tests that pressing a button shows and releasing capture hides ink drop. TEST_F(CustomButtonTest, CaptureLossHidesInkDrop) { - gfx::Point old_cursor = gfx::Screen::GetScreenFor( - widget()->GetNativeView())->GetCursorScreenPoint(); + gfx::Point old_cursor = gfx::Screen::GetScreen()->GetCursorScreenPoint(); CreateButtonWithInkDrop(); ui::test::EventGenerator generator(GetContext(), widget()->GetNativeWindow()); diff --git a/ui/views/controls/menu/menu_controller.cc b/ui/views/controls/menu/menu_controller.cc index 86be859..221e55e 100644 --- a/ui/views/controls/menu/menu_controller.cc +++ b/ui/views/controls/menu/menu_controller.cc @@ -889,7 +889,7 @@ ui::PostDispatchAction MenuController::OnWillDispatchKeyEvent( void MenuController::UpdateSubmenuSelection(SubmenuView* submenu) { if (submenu->IsShowing()) { - gfx::Point point = GetScreen()->GetCursorScreenPoint(); + gfx::Point point = gfx::Screen::GetScreen()->GetCursorScreenPoint(); const SubmenuView* root_submenu = submenu->GetMenuItem()->GetRootMenuItem()->GetSubmenu(); View::ConvertPointFromScreen( @@ -1235,14 +1235,16 @@ void MenuController::UpdateInitialLocation(const gfx::Rect& bounds, // Calculate the bounds of the monitor we'll show menus on. Do this once to // avoid repeated system queries for the info. - pending_state_.monitor_bounds = GetScreen()->GetDisplayNearestPoint( - bounds.origin()).work_area(); + pending_state_.monitor_bounds = gfx::Screen::GetScreen() + ->GetDisplayNearestPoint(bounds.origin()) + .work_area(); if (!pending_state_.monitor_bounds.Contains(bounds)) { // Use the monitor area if the work area doesn't contain the bounds. This // handles showing a menu from the launcher. - gfx::Rect monitor_area = GetScreen()->GetDisplayNearestPoint( - bounds.origin()).bounds(); + gfx::Rect monitor_area = gfx::Screen::GetScreen() + ->GetDisplayNearestPoint(bounds.origin()) + .bounds(); if (monitor_area.Contains(bounds)) pending_state_.monitor_bounds = monitor_area; } @@ -1275,7 +1277,8 @@ bool MenuController::ShowSiblingMenu(SubmenuView* source, return false; } - gfx::NativeWindow window_under_mouse = GetScreen()->GetWindowUnderCursor(); + gfx::NativeWindow window_under_mouse = + gfx::Screen::GetScreen()->GetWindowUnderCursor(); // TODO(oshima): Replace with views only API. if (!owner_ || window_under_mouse != owner_->GetNativeWindow()) return false; @@ -2274,7 +2277,7 @@ void MenuController::RepostEventAndCancel(SubmenuView* source, gfx::NativeView native_view = source->GetWidget()->GetNativeView(); gfx::NativeWindow window = nullptr; if (native_view) { - gfx::Screen* screen = gfx::Screen::GetScreenFor(native_view); + gfx::Screen* screen = gfx::Screen::GetScreen(); window = screen->GetWindowAtScreenPoint(screen_loc); } #endif @@ -2571,10 +2574,4 @@ void MenuController::HandleMouseLocation(SubmenuView* source, } } -gfx::Screen* MenuController::GetScreen() { - Widget* root = owner_ ? owner_->GetTopLevelWidget() : NULL; - return root ? gfx::Screen::GetScreenFor(root->GetNativeView()) - : gfx::Screen::GetNativeScreen(); -} - } // namespace views diff --git a/ui/views/controls/menu/menu_controller.h b/ui/views/controls/menu/menu_controller.h index 12af0aa..7502677 100644 --- a/ui/views/controls/menu/menu_controller.h +++ b/ui/views/controls/menu/menu_controller.h @@ -565,9 +565,6 @@ class VIEWS_EXPORT MenuController : public WidgetObserver { void HandleMouseLocation(SubmenuView* source, const gfx::Point& mouse_location); - // Retrieve an appropriate Screen. - gfx::Screen* GetScreen(); - // The active instance. static MenuController* active_instance_; diff --git a/ui/views/controls/scrollbar/base_scroll_bar_button.cc b/ui/views/controls/scrollbar/base_scroll_bar_button.cc index 54dbe75..d3fb707 100644 --- a/ui/views/controls/scrollbar/base_scroll_bar_button.cc +++ b/ui/views/controls/scrollbar/base_scroll_bar_button.cc @@ -36,9 +36,7 @@ void BaseScrollBarButton::OnMouseCaptureLost() { void BaseScrollBarButton::RepeaterNotifyClick() { // TODO(sky): See if we can convert to using |Screen| everywhere. - // TODO(scottmg): Native is wrong: http://crbug.com/133312 - gfx::Point cursor_point = - gfx::Screen::GetNativeScreen()->GetCursorScreenPoint(); + gfx::Point cursor_point = gfx::Screen::GetScreen()->GetCursorScreenPoint(); ui::MouseEvent event(ui::ET_MOUSE_RELEASED, cursor_point, cursor_point, ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); diff --git a/ui/views/controls/textfield/textfield.cc b/ui/views/controls/textfield/textfield.cc index a115af7..101f385 100644 --- a/ui/views/controls/textfield/textfield.cc +++ b/ui/views/controls/textfield/textfield.cc @@ -1090,8 +1090,8 @@ void Textfield::WriteDragDataForView(View* sender, label.SetSubpixelRenderingEnabled(false); gfx::Size size(label.GetPreferredSize()); gfx::NativeView native_view = GetWidget()->GetNativeView(); - gfx::Display display = gfx::Screen::GetScreenFor(native_view)-> - GetDisplayNearestWindow(native_view); + gfx::Display display = + gfx::Screen::GetScreen()->GetDisplayNearestWindow(native_view); size.SetToMin(gfx::Size(display.size().width(), height())); label.SetBoundsRect(gfx::Rect(size)); scoped_ptr<gfx::Canvas> canvas( diff --git a/ui/views/corewm/tooltip.h b/ui/views/corewm/tooltip.h index b8e6803..387fa3c 100644 --- a/ui/views/corewm/tooltip.h +++ b/ui/views/corewm/tooltip.h @@ -26,8 +26,7 @@ class VIEWS_EXPORT Tooltip { virtual ~Tooltip() {} // Returns the max width of the tooltip when shown at the specified location. - virtual int GetMaxWidth(const gfx::Point& location, - aura::Window* context) const = 0; + virtual int GetMaxWidth(const gfx::Point& location) const = 0; // Updates the text on the tooltip and resizes to fit. virtual void SetText(aura::Window* window, diff --git a/ui/views/corewm/tooltip_aura.cc b/ui/views/corewm/tooltip_aura.cc index 060d434..80dac9f 100644 --- a/ui/views/corewm/tooltip_aura.cc +++ b/ui/views/corewm/tooltip_aura.cc @@ -138,7 +138,7 @@ void TooltipAura::SetTooltipBounds(const gfx::Point& mouse_pos, const gfx::Size& tooltip_size) { gfx::Rect tooltip_rect(mouse_pos, tooltip_size); tooltip_rect.Offset(kCursorOffsetX, kCursorOffsetY); - gfx::Screen* screen = gfx::Screen::GetScreenFor(tooltip_window_); + gfx::Screen* screen = gfx::Screen::GetScreen(); gfx::Rect display_bounds(screen->GetDisplayNearestPoint(mouse_pos).bounds()); // If tooltip is out of bounds on the x axis, we simply shift it @@ -165,9 +165,8 @@ void TooltipAura::DestroyWidget() { } } -int TooltipAura::GetMaxWidth(const gfx::Point& location, - aura::Window* context) const { - gfx::Screen* screen = gfx::Screen::GetScreenFor(context); +int TooltipAura::GetMaxWidth(const gfx::Point& location) const { + gfx::Screen* screen = gfx::Screen::GetScreen(); gfx::Rect display_bounds(screen->GetDisplayNearestPoint(location).bounds()); return std::min(kTooltipMaxWidthPixels, (display_bounds.width() + 1) / 2); } @@ -176,7 +175,7 @@ void TooltipAura::SetText(aura::Window* window, const base::string16& tooltip_text, const gfx::Point& location) { tooltip_window_ = window; - tooltip_view_->SetMaxWidth(GetMaxWidth(location, window)); + tooltip_view_->SetMaxWidth(GetMaxWidth(location)); tooltip_view_->SetText(tooltip_text); if (!widget_) { diff --git a/ui/views/corewm/tooltip_aura.h b/ui/views/corewm/tooltip_aura.h index a905fbb..781acf9 100644 --- a/ui/views/corewm/tooltip_aura.h +++ b/ui/views/corewm/tooltip_aura.h @@ -7,7 +7,6 @@ #include "base/macros.h" #include "base/memory/scoped_ptr.h" -#include "ui/gfx/screen_type_delegate.h" #include "ui/views/corewm/tooltip.h" #include "ui/views/widget/widget_observer.h" @@ -40,8 +39,7 @@ class VIEWS_EXPORT TooltipAura : public Tooltip, public WidgetObserver { void DestroyWidget(); // Tooltip: - int GetMaxWidth(const gfx::Point& location, - aura::Window* context) const override; + int GetMaxWidth(const gfx::Point& location) const override; void SetText(aura::Window* window, const base::string16& tooltip_text, const gfx::Point& location) override; diff --git a/ui/views/corewm/tooltip_controller.cc b/ui/views/corewm/tooltip_controller.cc index ca27ffd..c7f466b 100644 --- a/ui/views/corewm/tooltip_controller.cc +++ b/ui/views/corewm/tooltip_controller.cc @@ -97,7 +97,7 @@ aura::Window* GetTooltipTarget(const ui::MouseEvent& event, gfx::Point screen_loc(event.location()); aura::client::GetScreenPositionClient(event_target->GetRootWindow())-> ConvertPointToScreen(event_target, &screen_loc); - gfx::Screen* screen = gfx::Screen::GetScreenFor(event_target); + gfx::Screen* screen = gfx::Screen::GetScreen(); aura::Window* target = screen->GetWindowAtScreenPoint(screen_loc); if (!target) return NULL; @@ -140,9 +140,8 @@ TooltipController::~TooltipController() { tooltip_window_->RemoveObserver(this); } -int TooltipController::GetMaxWidth(const gfx::Point& location, - gfx::NativeView context) const { - return tooltip_->GetMaxWidth(location, context); +int TooltipController::GetMaxWidth(const gfx::Point& location) const { + return tooltip_->GetMaxWidth(location); } void TooltipController::UpdateTooltip(aura::Window* target) { diff --git a/ui/views/corewm/tooltip_controller.h b/ui/views/corewm/tooltip_controller.h index ee42e72..5171726 100644 --- a/ui/views/corewm/tooltip_controller.h +++ b/ui/views/corewm/tooltip_controller.h @@ -39,8 +39,7 @@ class VIEWS_EXPORT TooltipController : public aura::client::TooltipClient, ~TooltipController() override; // Overridden from aura::client::TooltipClient. - int GetMaxWidth(const gfx::Point& location, - aura::Window* context) const override; + int GetMaxWidth(const gfx::Point& location) const override; void UpdateTooltip(aura::Window* target) override; void SetTooltipShownTimeout(aura::Window* target, int timeout_in_ms) override; void SetTooltipsEnabled(bool enable) override; diff --git a/ui/views/corewm/tooltip_controller_unittest.cc b/ui/views/corewm/tooltip_controller_unittest.cc index ca66322..4fc0bc8 100644 --- a/ui/views/corewm/tooltip_controller_unittest.cc +++ b/ui/views/corewm/tooltip_controller_unittest.cc @@ -19,7 +19,6 @@ #include "ui/gfx/font.h" #include "ui/gfx/geometry/point.h" #include "ui/gfx/screen.h" -#include "ui/gfx/screen_type_delegate.h" #include "ui/gfx/text_elider.h" #include "ui/views/corewm/tooltip_aura.h" #include "ui/views/corewm/tooltip_controller_test_helper.h" @@ -427,14 +426,13 @@ class TooltipControllerCaptureTest : public TooltipControllerTest { &screen_position_client_); #if !defined(OS_CHROMEOS) desktop_screen_.reset(CreateDesktopScreen()); - gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, - desktop_screen_.get()); + gfx::Screen::SetScreenInstance(desktop_screen_.get()); #endif } void TearDown() override { #if !defined(OS_CHROMEOS) - gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, test_screen()); + gfx::Screen::SetScreenInstance(test_screen()); desktop_screen_.reset(); #endif aura::client::SetScreenPositionClient(GetRootWindow(), NULL); @@ -534,8 +532,7 @@ class TestTooltip : public Tooltip { const base::string16& tooltip_text() const { return tooltip_text_; } // Tooltip: - int GetMaxWidth(const gfx::Point& location, - aura::Window* context) const override { + int GetMaxWidth(const gfx::Point& location) const override { return 100; } void SetText(aura::Window* window, diff --git a/ui/views/corewm/tooltip_win.cc b/ui/views/corewm/tooltip_win.cc index 46635d2..b892d38 100644 --- a/ui/views/corewm/tooltip_win.cc +++ b/ui/views/corewm/tooltip_win.cc @@ -77,7 +77,6 @@ bool TooltipWin::EnsureTooltipWindow() { } void TooltipWin::PositionTooltip() { - // This code only runs for non-metro, so GetNativeScreen() is fine. gfx::Point screen_point = gfx::win::DIPToScreenPoint(location_); const int cursoroffset = GetCurrentCursorVisibleHeight(); screen_point.Offset(0, cursoroffset); @@ -87,7 +86,7 @@ void TooltipWin::PositionTooltip() { const gfx::Size size(LOWORD(tooltip_size), HIWORD(tooltip_size)); const gfx::Display display( - gfx::Screen::GetNativeScreen()->GetDisplayNearestPoint(screen_point)); + gfx::Screen::GetScreen()->GetDisplayNearestPoint(screen_point)); gfx::Rect tooltip_bounds(screen_point, size); tooltip_bounds.AdjustToFit(gfx::win::DIPToScreenRect(display.work_area())); @@ -95,12 +94,10 @@ void TooltipWin::PositionTooltip() { 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE); } -int TooltipWin::GetMaxWidth(const gfx::Point& location, - aura::Window* context) const { - // This code only runs for non-metro, so GetNativeScreen() is fine. +int TooltipWin::GetMaxWidth(const gfx::Point& location) const { const gfx::Point screen_point = gfx::win::DIPToScreenPoint(location); gfx::Display display( - gfx::Screen::GetNativeScreen()->GetDisplayNearestPoint(screen_point)); + gfx::Screen::GetScreen()->GetDisplayNearestPoint(screen_point)); const gfx::Rect monitor_bounds = display.bounds(); return (monitor_bounds.width() + 1) / 2; } @@ -126,7 +123,7 @@ void TooltipWin::SetText(aura::Window* window, SendMessage(tooltip_hwnd_, TTM_SETTOOLINFO, 0, reinterpret_cast<LPARAM>(&toolinfo_)); - int max_width = GetMaxWidth(location_, window); + int max_width = GetMaxWidth(location_); SendMessage(tooltip_hwnd_, TTM_SETMAXTIPWIDTH, 0, max_width); } diff --git a/ui/views/corewm/tooltip_win.h b/ui/views/corewm/tooltip_win.h index 0b8ea61..eb9e520 100644 --- a/ui/views/corewm/tooltip_win.h +++ b/ui/views/corewm/tooltip_win.h @@ -37,8 +37,7 @@ class VIEWS_EXPORT TooltipWin : public Tooltip { void PositionTooltip(); // Tooltip: - int GetMaxWidth(const gfx::Point& location, - aura::Window* context) const override; + int GetMaxWidth(const gfx::Point& location) const override; void SetText(aura::Window* window, const base::string16& tooltip_text, const gfx::Point& location) override; diff --git a/ui/views/drag_utils.cc b/ui/views/drag_utils.cc index 5c64f48..9eae9f6 100644 --- a/ui/views/drag_utils.cc +++ b/ui/views/drag_utils.cc @@ -16,8 +16,8 @@ float GetDeviceScaleForNativeView(views::Widget* widget) { float device_scale = 1.0f; if (widget && widget->GetNativeView()) { gfx::NativeView view = widget->GetNativeView(); - gfx::Display display = gfx::Screen::GetScreenFor(view)-> - GetDisplayNearestWindow(view); + gfx::Display display = + gfx::Screen::GetScreen()->GetDisplayNearestWindow(view); device_scale = display.device_scale_factor(); } return device_scale; diff --git a/ui/views/examples/examples_main.cc b/ui/views/examples/examples_main.cc index 67ed52f..572552e 100644 --- a/ui/views/examples/examples_main.cc +++ b/ui/views/examples/examples_main.cc @@ -93,8 +93,7 @@ int main(int argc, char** argv) { #endif #if !defined(OS_CHROMEOS) && defined(USE_AURA) scoped_ptr<gfx::Screen> desktop_screen(views::CreateDesktopScreen()); - gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, - desktop_screen.get()); + gfx::Screen::SetScreenInstance(desktop_screen.get()); #endif views::examples::ShowExamplesWindow( diff --git a/ui/views/mouse_watcher_view_host.cc b/ui/views/mouse_watcher_view_host.cc index 54412cf..ac02b3c 100644 --- a/ui/views/mouse_watcher_view_host.cc +++ b/ui/views/mouse_watcher_view_host.cc @@ -49,8 +49,8 @@ bool MouseWatcherViewHost::IsMouseOverWindow() { if (!widget) return false; - return gfx::Screen::GetScreenFor(widget->GetNativeView())-> - GetWindowUnderCursor() == widget->GetNativeWindow(); + return gfx::Screen::GetScreen()->GetWindowUnderCursor() == + widget->GetNativeWindow(); } } // namespace views diff --git a/ui/views/mus/screen_mus.cc b/ui/views/mus/screen_mus.cc index 88311b6..b918faa 100644 --- a/ui/views/mus/screen_mus.cc +++ b/ui/views/mus/screen_mus.cc @@ -76,7 +76,7 @@ ScreenMus::ScreenMus(ScreenMusDelegate* delegate) ScreenMus::~ScreenMus() {} void ScreenMus::Init(mojo::ApplicationImpl* app) { - gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, this); + gfx::Screen::SetScreenInstance(this); app->ConnectToService("mojo:mus", &display_manager_); diff --git a/ui/views/test/desktop_screen_x11_test_api.cc b/ui/views/test/desktop_screen_x11_test_api.cc index 55c17bf..72a49b6 100644 --- a/ui/views/test/desktop_screen_x11_test_api.cc +++ b/ui/views/test/desktop_screen_x11_test_api.cc @@ -12,7 +12,7 @@ namespace test { void DesktopScreenX11TestApi::UpdateDisplays() { DesktopScreenX11* screen = - static_cast<DesktopScreenX11*>(gfx::Screen::GetNativeScreen()); + static_cast<DesktopScreenX11*>(gfx::Screen::GetScreen()); screen->ConfigureTimerFired(); } diff --git a/ui/views/view.cc b/ui/views/view.cc index 45467ab..9ee7272 100644 --- a/ui/views/view.cc +++ b/ui/views/view.cc @@ -946,8 +946,7 @@ bool View::IsMouseHovered() const { if (!GetWidget()->IsMouseEventsEnabled()) return false; - gfx::Point cursor_pos(gfx::Screen::GetScreenFor( - GetWidget()->GetNativeView())->GetCursorScreenPoint()); + gfx::Point cursor_pos(gfx::Screen::GetScreen()->GetCursorScreenPoint()); ConvertPointFromScreen(this, &cursor_pos); return HitTestPoint(cursor_pos); } diff --git a/ui/views/widget/desktop_aura/desktop_drag_drop_client_aurax11.cc b/ui/views/widget/desktop_aura/desktop_drag_drop_client_aurax11.cc index 3ef11e8..e9907e2 100644 --- a/ui/views/widget/desktop_aura/desktop_drag_drop_client_aurax11.cc +++ b/ui/views/widget/desktop_aura/desktop_drag_drop_client_aurax11.cc @@ -1186,8 +1186,8 @@ void DesktopDragDropClientAuraX11::CreateDragWidget( params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; params.accept_events = false; - gfx::Point location = gfx::Screen::GetNativeScreen()->GetCursorScreenPoint() - - drag_widget_offset_; + gfx::Point location = + gfx::Screen::GetScreen()->GetCursorScreenPoint() - drag_widget_offset_; params.bounds = gfx::Rect(location, image.size()); widget->set_focus_on_creation(false); widget->set_frame_type(Widget::FRAME_TYPE_FORCE_NATIVE); diff --git a/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc b/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc index 618d774..f2c2706 100644 --- a/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc +++ b/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc @@ -696,8 +696,9 @@ void DesktopNativeWidgetAura::SetBounds(const gfx::Rect& bounds) { float scale = 1; aura::Window* root = host_->window(); if (root) { - scale = gfx::Screen::GetScreenFor(root)-> - GetDisplayNearestWindow(root).device_scale_factor(); + scale = gfx::Screen::GetScreen() + ->GetDisplayNearestWindow(root) + .device_scale_factor(); } gfx::Rect bounds_in_pixels = gfx::ScaleToEnclosingRect(bounds, scale, scale); diff --git a/ui/views/widget/desktop_aura/desktop_native_widget_aura_unittest.cc b/ui/views/widget/desktop_aura/desktop_native_widget_aura_unittest.cc index 9578951..0e928a1 100644 --- a/ui/views/widget/desktop_aura/desktop_native_widget_aura_unittest.cc +++ b/ui/views/widget/desktop_aura/desktop_native_widget_aura_unittest.cc @@ -434,9 +434,7 @@ TEST_F(DesktopAuraWidgetTest, TopLevelOwnedPopupRepositionTest) { gfx::Rect new_pos(10, 10, 400, 400); popup_window.owned_window()->SetBoundsInScreen( - new_pos, - gfx::Screen::GetScreenFor( - popup_window.owned_window())->GetDisplayNearestPoint(gfx::Point())); + new_pos, gfx::Screen::GetScreen()->GetDisplayNearestPoint(gfx::Point())); EXPECT_EQ(new_pos, popup_window.top_level_widget()->GetWindowBoundsInScreen()); diff --git a/ui/views/widget/desktop_aura/desktop_screen_x11.cc b/ui/views/widget/desktop_aura/desktop_screen_x11.cc index 07bcfca..915a5cd 100644 --- a/ui/views/widget/desktop_aura/desktop_screen_x11.cc +++ b/ui/views/widget/desktop_aura/desktop_screen_x11.cc @@ -255,7 +255,7 @@ uint32_t DesktopScreenX11::DispatchEvent(const ui::PlatformEvent& event) { // static void DesktopScreenX11::UpdateDeviceScaleFactorForTest() { DesktopScreenX11* screen = - static_cast<DesktopScreenX11*>(gfx::Screen::GetNativeScreen()); + static_cast<DesktopScreenX11*>(gfx::Screen::GetScreen()); screen->ConfigureTimerFired(); } diff --git a/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc b/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc index e2fb724..e2eaf14 100644 --- a/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc +++ b/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc @@ -820,7 +820,7 @@ void DesktopWindowTreeHostX11::SetFullscreen(bool fullscreen) { if (fullscreen) { restored_bounds_in_pixels_ = bounds_in_pixels_; const gfx::Display display = - gfx::Screen::GetScreenFor(NULL)->GetDisplayNearestWindow(window()); + gfx::Screen::GetScreen()->GetDisplayNearestWindow(window()); bounds_in_pixels_ = ToPixelRect(display.bounds()); } else { bounds_in_pixels_ = restored_bounds_in_pixels_; @@ -938,10 +938,10 @@ void DesktopWindowTreeHostX11::SizeConstraintsChanged() { // DesktopWindowTreeHostX11, aura::WindowTreeHost implementation: gfx::Transform DesktopWindowTreeHostX11::GetRootTransform() const { - gfx::Display display = gfx::Screen::GetNativeScreen()->GetPrimaryDisplay(); + gfx::Display display = gfx::Screen::GetScreen()->GetPrimaryDisplay(); if (window_mapped_) { aura::Window* win = const_cast<aura::Window*>(window()); - display = gfx::Screen::GetNativeScreen()->GetDisplayNearestWindow(win); + display = gfx::Screen::GetScreen()->GetDisplayNearestWindow(win); } float scale = display.device_scale_factor(); @@ -1287,7 +1287,7 @@ void DesktopWindowTreeHostX11::InitX11Window( gfx::Size DesktopWindowTreeHostX11::AdjustSize( const gfx::Size& requested_size_in_pixels) { std::vector<gfx::Display> displays = - gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_NATIVE)->GetAllDisplays(); + gfx::Screen::GetScreen()->GetAllDisplays(); // Compare against all monitor sizes. The window manager can move the window // to whichever monitor it wants. for (size_t i = 0; i < displays.size(); ++i) { @@ -1533,9 +1533,9 @@ void DesktopWindowTreeHostX11::ConvertEventToDifferentHost( DesktopWindowTreeHostX11* host) { DCHECK_NE(this, host); const gfx::Display display_src = - gfx::Screen::GetNativeScreen()->GetDisplayNearestWindow(window()); + gfx::Screen::GetScreen()->GetDisplayNearestWindow(window()); const gfx::Display display_dest = - gfx::Screen::GetNativeScreen()->GetDisplayNearestWindow(host->window()); + gfx::Screen::GetScreen()->GetDisplayNearestWindow(host->window()); DCHECK_EQ(display_src.device_scale_factor(), display_dest.device_scale_factor()); gfx::Vector2d offset = GetLocationOnNativeScreen() - diff --git a/ui/views/widget/desktop_aura/x11_window_event_filter.cc b/ui/views/widget/desktop_aura/x11_window_event_filter.cc index c8f1065..c0ead55 100644 --- a/ui/views/widget/desktop_aura/x11_window_event_filter.cc +++ b/ui/views/widget/desktop_aura/x11_window_event_filter.cc @@ -151,9 +151,8 @@ void X11WindowEventFilter::OnClickedMaximizeButton(ui::MouseEvent* event) { if (!widget) return; - gfx::Screen* screen = gfx::Screen::GetNativeScreen(); gfx::Rect display_work_area = - screen->GetDisplayNearestWindow(target).work_area(); + gfx::Screen::GetScreen()->GetDisplayNearestWindow(target).work_area(); gfx::Rect bounds = widget->GetWindowBoundsInScreen(); if (event->IsMiddleMouseButton()) { bounds.set_y(display_work_area.y()); diff --git a/ui/views/widget/native_widget_aura.cc b/ui/views/widget/native_widget_aura.cc index 5072bd5..12b6255 100644 --- a/ui/views/widget/native_widget_aura.cc +++ b/ui/views/widget/native_widget_aura.cc @@ -137,8 +137,8 @@ void NativeWidgetAura::InitNativeWidget(const Widget::InitParams& params) { // If a parent is specified but no bounds are given, // use the origin of the parent's display so that the widget // will be added to the same display as the parent. - gfx::Rect bounds = gfx::Screen::GetScreenFor(parent)-> - GetDisplayNearestWindow(parent).bounds(); + gfx::Rect bounds = + gfx::Screen::GetScreen()->GetDisplayNearestWindow(parent).bounds(); window_bounds.set_origin(bounds.origin()); } } @@ -283,8 +283,8 @@ void NativeWidgetAura::CenterWindow(const gfx::Size& size) { // When centering window, we take the intersection of the host and // the parent. We assume the root window represents the visible // rect of a single screen. - gfx::Rect work_area = gfx::Screen::GetScreenFor(window_)-> - GetDisplayNearestWindow(window_).work_area(); + gfx::Rect work_area = + gfx::Screen::GetScreen()->GetDisplayNearestWindow(window_).work_area(); aura::client::ScreenPositionClient* screen_position_client = aura::client::GetScreenPositionClient(window_->GetRootWindow()); @@ -404,7 +404,7 @@ void NativeWidgetAura::SetBounds(const gfx::Rect& bounds) { aura::client::GetScreenPositionClient(root); if (screen_position_client) { gfx::Display dst_display = - gfx::Screen::GetScreenFor(window_)->GetDisplayMatching(bounds); + gfx::Screen::GetScreen()->GetDisplayMatching(bounds); screen_position_client->SetBounds(window_, bounds, dst_display); return; } @@ -643,8 +643,7 @@ void NativeWidgetAura::ClearNativeFocus() { gfx::Rect NativeWidgetAura::GetWorkAreaBoundsInScreen() const { if (!window_) return gfx::Rect(); - return gfx::Screen::GetScreenFor(window_)-> - GetDisplayNearestWindow(window_).work_area(); + return gfx::Screen::GetScreen()->GetDisplayNearestWindow(window_).work_area(); } Widget::MoveLoopResult NativeWidgetAura::RunMoveLoop( diff --git a/ui/views/widget/tooltip_manager.h b/ui/views/widget/tooltip_manager.h index 4287fc5..e807404 100644 --- a/ui/views/widget/tooltip_manager.h +++ b/ui/views/widget/tooltip_manager.h @@ -8,7 +8,6 @@ #include <string> #include "base/strings/string16.h" -#include "ui/gfx/native_widget_types.h" #include "ui/views/views_export.h" namespace gfx { @@ -39,10 +38,8 @@ class VIEWS_EXPORT TooltipManager { virtual ~TooltipManager() {} // Returns the maximum width of the tooltip. |point| gives the location - // the tooltip is to be displayed on in screen coordinates. |context| is - // used to determine which gfx::Screen should be used. - virtual int GetMaxWidth(const gfx::Point& location, - gfx::NativeView context) const = 0; + // the tooltip is to be displayed on in screen coordinates. + virtual int GetMaxWidth(const gfx::Point& location) const = 0; // Returns the font list used for tooltips. virtual const gfx::FontList& GetFontList() const = 0; diff --git a/ui/views/widget/tooltip_manager_aura.cc b/ui/views/widget/tooltip_manager_aura.cc index 1c5bd26..c4bf40e 100644 --- a/ui/views/widget/tooltip_manager_aura.cc +++ b/ui/views/widget/tooltip_manager_aura.cc @@ -49,7 +49,7 @@ void TooltipManagerAura::UpdateTooltipManagerForCapture(Widget* source) { if (!screen_position_client) return; screen_position_client->ConvertPointToScreen(root_window, &screen_loc); - gfx::Screen* screen = gfx::Screen::GetScreenFor(root_window); + gfx::Screen* screen = gfx::Screen::GetScreen(); aura::Window* target = screen->GetWindowAtScreenPoint(screen_loc); if (!target) return; @@ -81,10 +81,10 @@ const gfx::FontList& TooltipManagerAura::GetFontList() const { return GetDefaultFontList(); } -int TooltipManagerAura::GetMaxWidth(const gfx::Point& point, - aura::Window* context) const { - return aura::client::GetTooltipClient(context->GetRootWindow())-> - GetMaxWidth(point, context); +int TooltipManagerAura::GetMaxWidth(const gfx::Point& point) const { + return aura::client::GetTooltipClient( + widget_->GetNativeView()->GetRootWindow()) + ->GetMaxWidth(point); } void TooltipManagerAura::UpdateTooltip() { diff --git a/ui/views/widget/tooltip_manager_aura.h b/ui/views/widget/tooltip_manager_aura.h index 8d6bd9a..f429385 100644 --- a/ui/views/widget/tooltip_manager_aura.h +++ b/ui/views/widget/tooltip_manager_aura.h @@ -39,8 +39,7 @@ class TooltipManagerAura : public TooltipManager { static const gfx::FontList& GetDefaultFontList(); // TooltipManager: - int GetMaxWidth(const gfx::Point& location, - aura::Window* context) const override; + int GetMaxWidth(const gfx::Point& location) const override; const gfx::FontList& GetFontList() const override; void UpdateTooltip() override; void TooltipTextChanged(View* view) override; diff --git a/ui/views/widget/widget.cc b/ui/views/widget/widget.cc index eebe124..895b5e1 100644 --- a/ui/views/widget/widget.cc +++ b/ui/views/widget/widget.cc @@ -509,9 +509,9 @@ void Widget::CenterWindow(const gfx::Size& size) { } void Widget::SetBoundsConstrained(const gfx::Rect& bounds) { - gfx::Rect work_area = - gfx::Screen::GetScreenFor(GetNativeView())->GetDisplayNearestPoint( - bounds.origin()).work_area(); + gfx::Rect work_area = gfx::Screen::GetScreen() + ->GetDisplayNearestPoint(bounds.origin()) + .work_area(); if (work_area.IsEmpty()) { SetBounds(bounds); } else { diff --git a/ui/views_content_client/views_content_client_main_parts_chromeos.cc b/ui/views_content_client/views_content_client_main_parts_chromeos.cc index d139971..79e0911 100644 --- a/ui/views_content_client/views_content_client_main_parts_chromeos.cc +++ b/ui/views_content_client/views_content_client_main_parts_chromeos.cc @@ -65,7 +65,7 @@ void ViewsContentClientMainPartsChromeOS::PreMainMessageLoopRun() { gfx::Size host_size(800, 600); test_screen_.reset(aura::TestScreen::Create(host_size)); - gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, test_screen_.get()); + gfx::Screen::SetScreenInstance(test_screen_.get()); // Set up basic pieces of views::corewm. wm_test_helper_.reset( new ::wm::WMTestHelper(host_size, content::GetContextFactory())); diff --git a/ui/views_content_client/views_content_client_main_parts_desktop_aura.cc b/ui/views_content_client/views_content_client_main_parts_desktop_aura.cc index 1ac04ec..c7a3d0c 100644 --- a/ui/views_content_client/views_content_client_main_parts_desktop_aura.cc +++ b/ui/views_content_client/views_content_client_main_parts_desktop_aura.cc @@ -39,8 +39,7 @@ void ViewsContentClientMainPartsDesktopAura::PreMainMessageLoopRun() { ViewsContentClientMainPartsAura::PreMainMessageLoopRun(); aura::Env::CreateInstance(true); - gfx::Screen::SetScreenInstance( - gfx::SCREEN_TYPE_NATIVE, views::CreateDesktopScreen()); + gfx::Screen::SetScreenInstance(views::CreateDesktopScreen()); views_content_client()->task().Run(browser_context(), NULL); } diff --git a/ui/wm/core/default_screen_position_client.cc b/ui/wm/core/default_screen_position_client.cc index d26a91e..532c265 100644 --- a/ui/wm/core/default_screen_position_client.cc +++ b/ui/wm/core/default_screen_position_client.cc @@ -21,8 +21,9 @@ gfx::Point DefaultScreenPositionClient::GetOriginInScreen( const aura::Window* root_window) { gfx::Point origin_in_pixels = root_window->GetHost()->GetBounds().origin(); aura::Window* window = const_cast<aura::Window*>(root_window); - float scale = gfx::Screen::GetScreenFor(window)-> - GetDisplayNearestWindow(window).device_scale_factor(); + float scale = gfx::Screen::GetScreen() + ->GetDisplayNearestWindow(window) + .device_scale_factor(); return gfx::ScaleToFlooredPoint(origin_in_pixels, 1.0f / scale); } diff --git a/ui/wm/public/tooltip_client.h b/ui/wm/public/tooltip_client.h index f58a63e..7709515 100644 --- a/ui/wm/public/tooltip_client.h +++ b/ui/wm/public/tooltip_client.h @@ -21,8 +21,7 @@ class ScopedTooltipDisabler; class AURA_EXPORT TooltipClient { public: // Returns the max width of the tooltip when shown at the specified location. - virtual int GetMaxWidth(const gfx::Point& point, - aura::Window* context) const = 0; + virtual int GetMaxWidth(const gfx::Point& point) const = 0; // Informs the shell tooltip manager of change in tooltip for window |target|. virtual void UpdateTooltip(Window* target) = 0; |