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/profiles/profile_manager.h" | 13 #include "chrome/browser/profiles/profile_manager.h" |
13 #include "chrome/browser/ui/views/accessibility_event_router_views.h" | 14 #include "chrome/browser/ui/views/accessibility_event_router_views.h" |
14 #include "chrome/browser/ui/window_sizer.h" | 15 #include "chrome/browser/ui/window_sizer.h" |
15 #include "chrome/common/pref_names.h" | 16 #include "chrome/common/pref_names.h" |
16 #include "ui/base/clipboard/clipboard.h" | 17 #include "ui/base/clipboard/clipboard.h" |
17 #include "ui/gfx/rect.h" | 18 #include "ui/gfx/rect.h" |
18 #include "views/widget/native_widget.h" | 19 #include "views/widget/native_widget.h" |
19 #include "views/widget/widget.h" | 20 #include "views/widget/widget.h" |
20 #include "views/window/window.h" | 21 #include "views/window/window.h" |
21 | 22 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 | 54 |
54 void ChromeViewsDelegate::SaveWindowPlacement(views::Window* window, | 55 void ChromeViewsDelegate::SaveWindowPlacement(views::Window* window, |
55 const std::wstring& window_name, | 56 const std::wstring& window_name, |
56 const gfx::Rect& bounds, | 57 const gfx::Rect& bounds, |
57 bool maximized) { | 58 bool maximized) { |
58 PrefService* prefs = GetPrefsForWindow(window); | 59 PrefService* prefs = GetPrefsForWindow(window); |
59 if (!prefs) | 60 if (!prefs) |
60 return; | 61 return; |
61 | 62 |
62 DCHECK(prefs->FindPreference(WideToUTF8(window_name).c_str())); | 63 DCHECK(prefs->FindPreference(WideToUTF8(window_name).c_str())); |
63 DictionaryValue* window_preferences = | 64 DictionaryPrefUpdate update(prefs, WideToUTF8(window_name).c_str()); |
64 prefs->GetMutableDictionary(WideToUTF8(window_name).c_str()); | 65 DictionaryValue* window_preferences = update.Get(); |
65 window_preferences->SetInteger("left", bounds.x()); | 66 window_preferences->SetInteger("left", bounds.x()); |
66 window_preferences->SetInteger("top", bounds.y()); | 67 window_preferences->SetInteger("top", bounds.y()); |
67 window_preferences->SetInteger("right", bounds.right()); | 68 window_preferences->SetInteger("right", bounds.right()); |
68 window_preferences->SetInteger("bottom", bounds.bottom()); | 69 window_preferences->SetInteger("bottom", bounds.bottom()); |
69 window_preferences->SetBoolean("maximized", maximized); | 70 window_preferences->SetBoolean("maximized", maximized); |
70 | 71 |
71 scoped_ptr<WindowSizer::MonitorInfoProvider> monitor_info_provider( | 72 scoped_ptr<WindowSizer::MonitorInfoProvider> monitor_info_provider( |
72 WindowSizer::CreateDefaultMonitorInfoProvider()); | 73 WindowSizer::CreateDefaultMonitorInfoProvider()); |
73 gfx::Rect work_area( | 74 gfx::Rect work_area( |
74 monitor_info_provider->GetMonitorWorkAreaMatching(bounds)); | 75 monitor_info_provider->GetMonitorWorkAreaMatching(bounds)); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 } | 138 } |
138 #endif | 139 #endif |
139 | 140 |
140 void ChromeViewsDelegate::AddRef() { | 141 void ChromeViewsDelegate::AddRef() { |
141 g_browser_process->AddRefModule(); | 142 g_browser_process->AddRefModule(); |
142 } | 143 } |
143 | 144 |
144 void ChromeViewsDelegate::ReleaseRef() { | 145 void ChromeViewsDelegate::ReleaseRef() { |
145 g_browser_process->ReleaseModule(); | 146 g_browser_process->ReleaseModule(); |
146 } | 147 } |
OLD | NEW |