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" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 return g_browser_process->clipboard(); | 58 return g_browser_process->clipboard(); |
59 } | 59 } |
60 | 60 |
61 views::View* ChromeViewsDelegate::GetDefaultParentView() { | 61 views::View* ChromeViewsDelegate::GetDefaultParentView() { |
62 return default_parent_view; | 62 return default_parent_view; |
63 } | 63 } |
64 | 64 |
65 void ChromeViewsDelegate::SaveWindowPlacement(const views::Widget* window, | 65 void ChromeViewsDelegate::SaveWindowPlacement(const views::Widget* window, |
66 const std::wstring& window_name, | 66 const std::wstring& window_name, |
67 const gfx::Rect& bounds, | 67 const gfx::Rect& bounds, |
68 bool maximized) { | 68 ui::WindowShowState show_state) { |
69 bool using_local_state = false; | 69 bool using_local_state = false; |
70 PrefService* prefs = GetPrefsForWindow(window, &using_local_state); | 70 PrefService* prefs = GetPrefsForWindow(window, &using_local_state); |
71 if (!prefs) | 71 if (!prefs) |
72 return; | 72 return; |
73 | 73 |
74 CHECK(prefs->FindPreference(WideToUTF8(window_name).c_str())) << " " << | 74 CHECK(prefs->FindPreference(WideToUTF8(window_name).c_str())) << " " << |
75 browser_shutdown::GetShutdownType() << " " << using_local_state << " " << | 75 browser_shutdown::GetShutdownType() << " " << using_local_state << " " << |
76 window->destroy_state(); | 76 window->destroy_state(); |
77 DictionaryPrefUpdate update(prefs, WideToUTF8(window_name).c_str()); | 77 DictionaryPrefUpdate update(prefs, WideToUTF8(window_name).c_str()); |
78 DictionaryValue* window_preferences = update.Get(); | 78 DictionaryValue* window_preferences = update.Get(); |
79 window_preferences->SetInteger("left", bounds.x()); | 79 window_preferences->SetInteger("left", bounds.x()); |
80 window_preferences->SetInteger("top", bounds.y()); | 80 window_preferences->SetInteger("top", bounds.y()); |
81 window_preferences->SetInteger("right", bounds.right()); | 81 window_preferences->SetInteger("right", bounds.right()); |
82 window_preferences->SetInteger("bottom", bounds.bottom()); | 82 window_preferences->SetInteger("bottom", bounds.bottom()); |
83 window_preferences->SetBoolean("maximized", maximized); | 83 window_preferences->SetBoolean("maximized", |
| 84 show_state == ui::SHOW_STATE_MAXIMIZED); |
84 | 85 |
85 scoped_ptr<WindowSizer::MonitorInfoProvider> monitor_info_provider( | 86 scoped_ptr<WindowSizer::MonitorInfoProvider> monitor_info_provider( |
86 WindowSizer::CreateDefaultMonitorInfoProvider()); | 87 WindowSizer::CreateDefaultMonitorInfoProvider()); |
87 gfx::Rect work_area( | 88 gfx::Rect work_area( |
88 monitor_info_provider->GetMonitorWorkAreaMatching(bounds)); | 89 monitor_info_provider->GetMonitorWorkAreaMatching(bounds)); |
89 window_preferences->SetInteger("work_area_left", work_area.x()); | 90 window_preferences->SetInteger("work_area_left", work_area.x()); |
90 window_preferences->SetInteger("work_area_top", work_area.y()); | 91 window_preferences->SetInteger("work_area_top", work_area.y()); |
91 window_preferences->SetInteger("work_area_right", work_area.right()); | 92 window_preferences->SetInteger("work_area_right", work_area.right()); |
92 window_preferences->SetInteger("work_area_bottom", work_area.bottom()); | 93 window_preferences->SetInteger("work_area_bottom", work_area.bottom()); |
93 } | 94 } |
(...skipping 11 matching lines...) Expand all Loading... |
105 if (!dictionary || !dictionary->GetInteger("left", &left) || | 106 if (!dictionary || !dictionary->GetInteger("left", &left) || |
106 !dictionary->GetInteger("top", &top) || | 107 !dictionary->GetInteger("top", &top) || |
107 !dictionary->GetInteger("right", &right) || | 108 !dictionary->GetInteger("right", &right) || |
108 !dictionary->GetInteger("bottom", &bottom)) | 109 !dictionary->GetInteger("bottom", &bottom)) |
109 return false; | 110 return false; |
110 | 111 |
111 bounds->SetRect(left, top, right - left, bottom - top); | 112 bounds->SetRect(left, top, right - left, bottom - top); |
112 return true; | 113 return true; |
113 } | 114 } |
114 | 115 |
115 bool ChromeViewsDelegate::GetSavedMaximizedState( | 116 bool ChromeViewsDelegate::GetSavedWindowShowState( |
116 const std::wstring& window_name, | 117 const std::wstring& window_name, |
117 bool* maximized) const { | 118 ui::WindowShowState* show_state) const { |
118 PrefService* prefs = g_browser_process->local_state(); | 119 PrefService* prefs = g_browser_process->local_state(); |
119 if (!prefs) | 120 if (!prefs) |
120 return false; | 121 return false; |
121 | 122 |
122 DCHECK(prefs->FindPreference(WideToUTF8(window_name).c_str())); | 123 DCHECK(prefs->FindPreference(WideToUTF8(window_name).c_str())); |
123 const DictionaryValue* dictionary = | 124 const DictionaryValue* dictionary = |
124 prefs->GetDictionary(WideToUTF8(window_name).c_str()); | 125 prefs->GetDictionary(WideToUTF8(window_name).c_str()); |
125 | 126 |
126 return dictionary && dictionary->GetBoolean("maximized", maximized) && | 127 bool maximized = false; |
127 maximized; | 128 return dictionary && dictionary->GetBoolean("maximized", &maximized); |
| 129 *show_state = maximized ? ui::SHOW_STATE_MAXIMIZED : ui::SHOW_STATE_NORMAL; |
| 130 return maximized; |
128 } | 131 } |
129 | 132 |
130 void ChromeViewsDelegate::NotifyAccessibilityEvent( | 133 void ChromeViewsDelegate::NotifyAccessibilityEvent( |
131 views::View* view, ui::AccessibilityTypes::Event event_type) { | 134 views::View* view, ui::AccessibilityTypes::Event event_type) { |
132 AccessibilityEventRouterViews::GetInstance()->HandleAccessibilityEvent( | 135 AccessibilityEventRouterViews::GetInstance()->HandleAccessibilityEvent( |
133 view, event_type); | 136 view, event_type); |
134 } | 137 } |
135 | 138 |
136 void ChromeViewsDelegate::NotifyMenuItemFocused( | 139 void ChromeViewsDelegate::NotifyMenuItemFocused( |
137 const std::wstring& menu_name, | 140 const std::wstring& menu_name, |
(...skipping 15 matching lines...) Expand all Loading... |
153 g_browser_process->AddRefModule(); | 156 g_browser_process->AddRefModule(); |
154 } | 157 } |
155 | 158 |
156 void ChromeViewsDelegate::ReleaseRef() { | 159 void ChromeViewsDelegate::ReleaseRef() { |
157 g_browser_process->ReleaseModule(); | 160 g_browser_process->ReleaseModule(); |
158 } | 161 } |
159 | 162 |
160 int ChromeViewsDelegate::GetDispositionForEvent(int event_flags) { | 163 int ChromeViewsDelegate::GetDispositionForEvent(int event_flags) { |
161 return event_utils::DispositionFromEventFlags(event_flags); | 164 return event_utils::DispositionFromEventFlags(event_flags); |
162 } | 165 } |
OLD | NEW |