Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/views/window_delegate.h" | 5 #include "chrome/views/window_delegate.h" |
| 6 | 6 |
| 7 // TODO(beng): hrmp. | |
| 8 #include "chrome/browser/browser_process.h" | |
| 9 #include "chrome/common/pref_service.h" | |
| 7 #include "chrome/views/client_view.h" | 10 #include "chrome/views/client_view.h" |
| 8 #include "chrome/views/window.h" | 11 #include "chrome/views/window.h" |
| 9 #include "skia/include/SkBitmap.h" | 12 #include "skia/include/SkBitmap.h" |
| 10 | 13 |
| 11 namespace views { | 14 namespace views { |
| 12 | 15 |
| 13 WindowDelegate::WindowDelegate() { | 16 WindowDelegate::WindowDelegate() { |
| 14 } | 17 } |
| 15 | 18 |
| 16 WindowDelegate::~WindowDelegate() { | 19 WindowDelegate::~WindowDelegate() { |
| 17 ReleaseWindow(); | 20 ReleaseWindow(); |
| 18 } | 21 } |
| 19 | 22 |
| 20 // Returns the icon to be displayed in the window. | 23 // Returns the icon to be displayed in the window. |
| 21 SkBitmap WindowDelegate::GetWindowIcon() { | 24 SkBitmap WindowDelegate::GetWindowIcon() { |
| 22 return SkBitmap(); | 25 return SkBitmap(); |
| 23 } | 26 } |
| 24 | 27 |
| 28 void WindowDelegate::SaveWindowPlacement(const gfx::Rect& bounds, | |
| 29 bool maximized, | |
| 30 bool always_on_top) { | |
| 31 std::wstring window_name = GetWindowName(); | |
| 32 if (window_name.empty()) | |
| 33 return; | |
| 34 | |
| 35 DictionaryValue* window_preferences = | |
| 36 g_browser_process->local_state()->GetMutableDictionary( | |
| 37 window_name.c_str()); | |
| 38 window_preferences->SetInteger(L"left", bounds.x()); | |
| 39 window_preferences->SetInteger(L"top", bounds.y()); | |
| 40 window_preferences->SetInteger(L"right", bounds.right()); | |
| 41 window_preferences->SetInteger(L"bottom", bounds.bottom()); | |
| 42 window_preferences->SetBoolean(L"maximized", maximized); | |
| 43 window_preferences->SetBoolean(L"always_on_top", always_on_top); | |
| 44 } | |
| 45 | |
| 46 bool WindowDelegate::GetSavedWindowBounds(gfx::Rect* bounds) const { | |
| 47 std::wstring window_name = GetWindowName(); | |
| 48 if (window_name.empty()) | |
| 49 return false; | |
| 50 | |
| 51 const DictionaryValue* dictionary = | |
| 52 g_browser_process->local_state()->GetDictionary(window_name.c_str()); | |
| 53 int left, top, right, bottom; | |
| 54 if (!dictionary || !dictionary->GetInteger(L"left", &left) || | |
| 55 !dictionary->GetInteger(L"top", &top) || | |
| 56 !dictionary->GetInteger(L"right", &right) || | |
| 57 !dictionary->GetInteger(L"bottom", &bottom)) | |
| 58 return false; | |
| 59 | |
| 60 bounds->SetRect(left, top, right, bottom); | |
| 61 return true; | |
| 62 } | |
| 63 | |
| 64 bool WindowDelegate::GetSavedMaximizedState(bool* maximized) const { | |
| 65 std::wstring window_name = GetWindowName(); | |
| 66 if (window_name.empty()) | |
| 67 return false; | |
| 68 | |
| 69 const DictionaryValue* dictionary = | |
| 70 g_browser_process->local_state()->GetDictionary(window_name.c_str()); | |
| 71 return dictionary && dictionary->GetBoolean(L"maximized", maximized); | |
| 72 } | |
| 73 | |
| 74 bool WindowDelegate::GetSavedAlwaysOnTopState(bool* always_on_top) const { | |
| 75 std::wstring window_name = GetWindowName(); | |
| 76 if (window_name.empty()) | |
| 77 return false; | |
| 78 | |
| 79 const DictionaryValue* dictionary = | |
| 80 g_browser_process->local_state()->GetDictionary(window_name.c_str()); | |
|
sky
2008/11/14 00:28:09
nit: 4 spaces.
| |
| 81 return dictionary && dictionary->GetBoolean(L"always_on_top", always_on_top); | |
| 82 } | |
| 83 | |
| 84 | |
| 25 ClientView* WindowDelegate::CreateClientView(Window* window) { | 85 ClientView* WindowDelegate::CreateClientView(Window* window) { |
| 26 return new ClientView(window, GetContentsView()); | 86 return new ClientView(window, GetContentsView()); |
| 27 } | 87 } |
| 28 | 88 |
| 29 void WindowDelegate::ReleaseWindow() { | 89 void WindowDelegate::ReleaseWindow() { |
| 30 window_.release(); | 90 window_.release(); |
| 31 } | 91 } |
| 32 | 92 |
| 33 } // namespace views | 93 } // namespace views |
| 34 | 94 |
| OLD | NEW |