| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/views/chrome_views_delegate.h" | 5 #include "chrome/browser/ui/views/chrome_views_delegate.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| 11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
| 12 #include "build/build_config.h" | 12 #include "build/build_config.h" |
| 13 #include "chrome/browser/browser_process.h" | 13 #include "chrome/browser/browser_process.h" |
| 14 #include "chrome/browser/lifetime/keep_alive_types.h" | 14 #include "chrome/browser/lifetime/keep_alive_types.h" |
| 15 #include "chrome/browser/lifetime/scoped_keep_alive.h" | 15 #include "chrome/browser/lifetime/scoped_keep_alive.h" |
| 16 #include "chrome/browser/profiles/profile_manager.h" | 16 #include "chrome/browser/profiles/profile_manager.h" |
| 17 #include "chrome/browser/ui/browser_window_state.h" | 17 #include "chrome/browser/ui/browser_window_state.h" |
| 18 #include "components/prefs/pref_service.h" | 18 #include "components/prefs/pref_service.h" |
| 19 #include "components/prefs/scoped_user_pref_update.h" | 19 #include "components/prefs/scoped_user_pref_update.h" |
| 20 #include "components/version_info/version_info.h" | 20 #include "components/version_info/version_info.h" |
| 21 #include "content/public/browser/browser_thread.h" | 21 #include "content/public/browser/browser_thread.h" |
| 22 #include "content/public/browser/context_factory.h" | 22 #include "content/public/browser/context_factory.h" |
| 23 #include "grit/chrome_unscaled_resources.h" | 23 #include "grit/chrome_unscaled_resources.h" |
| 24 #include "ui/base/resource/resource_bundle.h" | 24 #include "ui/base/resource/resource_bundle.h" |
| 25 #include "ui/base/ui_base_switches.h" | 25 #include "ui/base/ui_base_switches.h" |
| 26 #include "ui/display/screen.h" |
| 26 #include "ui/gfx/geometry/rect.h" | 27 #include "ui/gfx/geometry/rect.h" |
| 27 #include "ui/gfx/screen.h" | |
| 28 #include "ui/views/controls/menu/menu_controller.h" | 28 #include "ui/views/controls/menu/menu_controller.h" |
| 29 #include "ui/views/widget/native_widget.h" | 29 #include "ui/views/widget/native_widget.h" |
| 30 #include "ui/views/widget/widget.h" | 30 #include "ui/views/widget/widget.h" |
| 31 | 31 |
| 32 #if defined(OS_WIN) | 32 #if defined(OS_WIN) |
| 33 #include <dwmapi.h> | 33 #include <dwmapi.h> |
| 34 #include <shellapi.h> | 34 #include <shellapi.h> |
| 35 #include "base/profiler/scoped_tracker.h" | 35 #include "base/profiler/scoped_tracker.h" |
| 36 #include "base/task_runner_util.h" | 36 #include "base/task_runner_util.h" |
| 37 #include "base/win/windows_version.h" | 37 #include "base/win/windows_version.h" |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 std::unique_ptr<DictionaryPrefUpdate> pref_update = | 200 std::unique_ptr<DictionaryPrefUpdate> pref_update = |
| 201 chrome::GetWindowPlacementDictionaryReadWrite(window_name, prefs); | 201 chrome::GetWindowPlacementDictionaryReadWrite(window_name, prefs); |
| 202 base::DictionaryValue* window_preferences = pref_update->Get(); | 202 base::DictionaryValue* window_preferences = pref_update->Get(); |
| 203 window_preferences->SetInteger("left", bounds.x()); | 203 window_preferences->SetInteger("left", bounds.x()); |
| 204 window_preferences->SetInteger("top", bounds.y()); | 204 window_preferences->SetInteger("top", bounds.y()); |
| 205 window_preferences->SetInteger("right", bounds.right()); | 205 window_preferences->SetInteger("right", bounds.right()); |
| 206 window_preferences->SetInteger("bottom", bounds.bottom()); | 206 window_preferences->SetInteger("bottom", bounds.bottom()); |
| 207 window_preferences->SetBoolean("maximized", | 207 window_preferences->SetBoolean("maximized", |
| 208 show_state == ui::SHOW_STATE_MAXIMIZED); | 208 show_state == ui::SHOW_STATE_MAXIMIZED); |
| 209 window_preferences->SetBoolean("docked", show_state == ui::SHOW_STATE_DOCKED); | 209 window_preferences->SetBoolean("docked", show_state == ui::SHOW_STATE_DOCKED); |
| 210 gfx::Rect work_area(gfx::Screen::GetScreen() | 210 gfx::Rect work_area(display::Screen::GetScreen() |
| 211 ->GetDisplayNearestWindow(window->GetNativeView()) | 211 ->GetDisplayNearestWindow(window->GetNativeView()) |
| 212 .work_area()); | 212 .work_area()); |
| 213 window_preferences->SetInteger("work_area_left", work_area.x()); | 213 window_preferences->SetInteger("work_area_left", work_area.x()); |
| 214 window_preferences->SetInteger("work_area_top", work_area.y()); | 214 window_preferences->SetInteger("work_area_top", work_area.y()); |
| 215 window_preferences->SetInteger("work_area_right", work_area.right()); | 215 window_preferences->SetInteger("work_area_right", work_area.right()); |
| 216 window_preferences->SetInteger("work_area_bottom", work_area.bottom()); | 216 window_preferences->SetInteger("work_area_bottom", work_area.bottom()); |
| 217 } | 217 } |
| 218 | 218 |
| 219 bool ChromeViewsDelegate::GetSavedWindowPlacement( | 219 bool ChromeViewsDelegate::GetSavedWindowPlacement( |
| 220 const views::Widget* widget, | 220 const views::Widget* widget, |
| (...skipping 20 matching lines...) Expand all Loading... |
| 241 | 241 |
| 242 bool maximized = false; | 242 bool maximized = false; |
| 243 if (dictionary) | 243 if (dictionary) |
| 244 dictionary->GetBoolean("maximized", &maximized); | 244 dictionary->GetBoolean("maximized", &maximized); |
| 245 *show_state = maximized ? ui::SHOW_STATE_MAXIMIZED : ui::SHOW_STATE_NORMAL; | 245 *show_state = maximized ? ui::SHOW_STATE_MAXIMIZED : ui::SHOW_STATE_NORMAL; |
| 246 | 246 |
| 247 #if defined(USE_ASH) | 247 #if defined(USE_ASH) |
| 248 // On Ash environment, a window won't span across displays. Adjust | 248 // On Ash environment, a window won't span across displays. Adjust |
| 249 // the bounds to fit the work area. | 249 // the bounds to fit the work area. |
| 250 gfx::NativeView window = widget->GetNativeView(); | 250 gfx::NativeView window = widget->GetNativeView(); |
| 251 gfx::Display display = gfx::Screen::GetScreen()->GetDisplayMatching(*bounds); | 251 display::Display display = |
| 252 display::Screen::GetScreen()->GetDisplayMatching(*bounds); |
| 252 bounds->AdjustToFit(display.work_area()); | 253 bounds->AdjustToFit(display.work_area()); |
| 253 ash::wm::GetWindowState(window)->set_minimum_visibility(true); | 254 ash::wm::GetWindowState(window)->set_minimum_visibility(true); |
| 254 #endif | 255 #endif |
| 255 return true; | 256 return true; |
| 256 } | 257 } |
| 257 | 258 |
| 258 void ChromeViewsDelegate::NotifyAccessibilityEvent( | 259 void ChromeViewsDelegate::NotifyAccessibilityEvent( |
| 259 views::View* view, ui::AXEvent event_type) { | 260 views::View* view, ui::AXEvent event_type) { |
| 260 #if defined(USE_AURA) | 261 #if defined(USE_AURA) |
| 261 AutomationManagerAura::GetInstance()->HandleEvent( | 262 AutomationManagerAura::GetInstance()->HandleEvent( |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 return content::BrowserThread::GetBlockingPool(); | 499 return content::BrowserThread::GetBlockingPool(); |
| 499 } | 500 } |
| 500 | 501 |
| 501 #if !defined(USE_ASH) | 502 #if !defined(USE_ASH) |
| 502 views::Widget::InitParams::WindowOpacity | 503 views::Widget::InitParams::WindowOpacity |
| 503 ChromeViewsDelegate::GetOpacityForInitParams( | 504 ChromeViewsDelegate::GetOpacityForInitParams( |
| 504 const views::Widget::InitParams& params) { | 505 const views::Widget::InitParams& params) { |
| 505 return views::Widget::InitParams::OPAQUE_WINDOW; | 506 return views::Widget::InitParams::OPAQUE_WINDOW; |
| 506 } | 507 } |
| 507 #endif | 508 #endif |
| OLD | NEW |