OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
11 #include "chrome/browser/prefs/pref_service.h" | 11 #include "chrome/browser/prefs/pref_service.h" |
12 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 12 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
13 #include "chrome/browser/profiles/profile_manager.h" | 13 #include "chrome/browser/profiles/profile_manager.h" |
14 #include "chrome/browser/ui/views/accessibility_event_router_views.h" | 14 #include "chrome/browser/ui/views/accessibility_event_router_views.h" |
15 #include "chrome/browser/ui/views/event_utils.h" | 15 #include "chrome/browser/ui/views/event_utils.h" |
16 #include "chrome/browser/ui/window_sizer.h" | |
17 #include "chrome/common/pref_names.h" | 16 #include "chrome/common/pref_names.h" |
18 #include "ui/base/clipboard/clipboard.h" | 17 #include "ui/base/clipboard/clipboard.h" |
19 #include "ui/gfx/rect.h" | 18 #include "ui/gfx/rect.h" |
| 19 #include "ui/gfx/screen.h" |
20 #include "ui/views/widget/native_widget.h" | 20 #include "ui/views/widget/native_widget.h" |
21 #include "ui/views/widget/widget.h" | 21 #include "ui/views/widget/widget.h" |
22 | 22 |
23 #if defined(OS_WIN) | 23 #if defined(OS_WIN) |
24 #include "chrome/browser/app_icon_win.h" | 24 #include "chrome/browser/app_icon_win.h" |
25 #endif | 25 #endif |
26 | 26 |
27 namespace { | 27 namespace { |
28 | 28 |
29 // If the given window has a profile associated with it, use that profile's | 29 // If the given window has a profile associated with it, use that profile's |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 DCHECK(prefs->FindPreference(window_name.c_str())); | 62 DCHECK(prefs->FindPreference(window_name.c_str())); |
63 DictionaryPrefUpdate update(prefs, window_name.c_str()); | 63 DictionaryPrefUpdate update(prefs, window_name.c_str()); |
64 DictionaryValue* window_preferences = update.Get(); | 64 DictionaryValue* window_preferences = update.Get(); |
65 window_preferences->SetInteger("left", bounds.x()); | 65 window_preferences->SetInteger("left", bounds.x()); |
66 window_preferences->SetInteger("top", bounds.y()); | 66 window_preferences->SetInteger("top", bounds.y()); |
67 window_preferences->SetInteger("right", bounds.right()); | 67 window_preferences->SetInteger("right", bounds.right()); |
68 window_preferences->SetInteger("bottom", bounds.bottom()); | 68 window_preferences->SetInteger("bottom", bounds.bottom()); |
69 window_preferences->SetBoolean("maximized", | 69 window_preferences->SetBoolean("maximized", |
70 show_state == ui::SHOW_STATE_MAXIMIZED); | 70 show_state == ui::SHOW_STATE_MAXIMIZED); |
71 | 71 |
72 scoped_ptr<WindowSizer::MonitorInfoProvider> monitor_info_provider( | 72 gfx::Rect work_area(gfx::Screen::GetMonitorWorkAreaMatching(bounds)); |
73 WindowSizer::CreateDefaultMonitorInfoProvider()); | |
74 gfx::Rect work_area( | |
75 monitor_info_provider->GetMonitorWorkAreaMatching(bounds)); | |
76 window_preferences->SetInteger("work_area_left", work_area.x()); | 73 window_preferences->SetInteger("work_area_left", work_area.x()); |
77 window_preferences->SetInteger("work_area_top", work_area.y()); | 74 window_preferences->SetInteger("work_area_top", work_area.y()); |
78 window_preferences->SetInteger("work_area_right", work_area.right()); | 75 window_preferences->SetInteger("work_area_right", work_area.right()); |
79 window_preferences->SetInteger("work_area_bottom", work_area.bottom()); | 76 window_preferences->SetInteger("work_area_bottom", work_area.bottom()); |
80 } | 77 } |
81 | 78 |
82 bool ChromeViewsDelegate::GetSavedWindowPlacement( | 79 bool ChromeViewsDelegate::GetSavedWindowPlacement( |
83 const std::string& window_name, | 80 const std::string& window_name, |
84 gfx::Rect* bounds, | 81 gfx::Rect* bounds, |
85 ui::WindowShowState* show_state) const { | 82 ui::WindowShowState* show_state) const { |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 g_browser_process->AddRefModule(); | 128 g_browser_process->AddRefModule(); |
132 } | 129 } |
133 | 130 |
134 void ChromeViewsDelegate::ReleaseRef() { | 131 void ChromeViewsDelegate::ReleaseRef() { |
135 g_browser_process->ReleaseModule(); | 132 g_browser_process->ReleaseModule(); |
136 } | 133 } |
137 | 134 |
138 int ChromeViewsDelegate::GetDispositionForEvent(int event_flags) { | 135 int ChromeViewsDelegate::GetDispositionForEvent(int event_flags) { |
139 return event_utils::DispositionFromEventFlags(event_flags); | 136 return event_utils::DispositionFromEventFlags(event_flags); |
140 } | 137 } |
OLD | NEW |