Index: chrome/views/window_delegate.cc |
=================================================================== |
--- chrome/views/window_delegate.cc (revision 5374) |
+++ chrome/views/window_delegate.cc (working copy) |
@@ -4,6 +4,9 @@ |
#include "chrome/views/window_delegate.h" |
+// TODO(beng): hrmp. |
+#include "chrome/browser/browser_process.h" |
+#include "chrome/common/pref_service.h" |
#include "chrome/views/client_view.h" |
#include "chrome/views/window.h" |
#include "skia/include/SkBitmap.h" |
@@ -22,6 +25,63 @@ |
return SkBitmap(); |
} |
+void WindowDelegate::SaveWindowPlacement(const gfx::Rect& bounds, |
+ bool maximized, |
+ bool always_on_top) { |
+ std::wstring window_name = GetWindowName(); |
+ if (window_name.empty()) |
+ return; |
+ |
+ DictionaryValue* window_preferences = |
+ g_browser_process->local_state()->GetMutableDictionary( |
+ window_name.c_str()); |
+ window_preferences->SetInteger(L"left", bounds.x()); |
+ window_preferences->SetInteger(L"top", bounds.y()); |
+ window_preferences->SetInteger(L"right", bounds.right()); |
+ window_preferences->SetInteger(L"bottom", bounds.bottom()); |
+ window_preferences->SetBoolean(L"maximized", maximized); |
+ window_preferences->SetBoolean(L"always_on_top", always_on_top); |
+} |
+ |
+bool WindowDelegate::GetSavedWindowBounds(gfx::Rect* bounds) const { |
+ std::wstring window_name = GetWindowName(); |
+ if (window_name.empty()) |
+ return false; |
+ |
+ const DictionaryValue* dictionary = |
+ g_browser_process->local_state()->GetDictionary(window_name.c_str()); |
+ int left, top, right, bottom; |
+ if (!dictionary || !dictionary->GetInteger(L"left", &left) || |
+ !dictionary->GetInteger(L"top", &top) || |
+ !dictionary->GetInteger(L"right", &right) || |
+ !dictionary->GetInteger(L"bottom", &bottom)) |
+ return false; |
+ |
+ bounds->SetRect(left, top, right, bottom); |
+ return true; |
+} |
+ |
+bool WindowDelegate::GetSavedMaximizedState(bool* maximized) const { |
+ std::wstring window_name = GetWindowName(); |
+ if (window_name.empty()) |
+ return false; |
+ |
+ const DictionaryValue* dictionary = |
+ g_browser_process->local_state()->GetDictionary(window_name.c_str()); |
+ return dictionary && dictionary->GetBoolean(L"maximized", maximized); |
+} |
+ |
+bool WindowDelegate::GetSavedAlwaysOnTopState(bool* always_on_top) const { |
+ std::wstring window_name = GetWindowName(); |
+ if (window_name.empty()) |
+ return false; |
+ |
+ const DictionaryValue* dictionary = |
+ g_browser_process->local_state()->GetDictionary(window_name.c_str()); |
sky
2008/11/14 00:28:09
nit: 4 spaces.
|
+ return dictionary && dictionary->GetBoolean(L"always_on_top", always_on_top); |
+} |
+ |
+ |
ClientView* WindowDelegate::CreateClientView(Window* window) { |
return new ClientView(window, GetContentsView()); |
} |