| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this |
| 2 // source code is governed by a BSD-style license that can be found in the | 2 // source code is governed by a BSD-style license that can be found in the |
| 3 // LICENSE file. | 3 // LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/views/chrome_views_delegate.h" | 5 #include "chrome/browser/views/chrome_views_delegate.h" |
| 6 | 6 |
| 7 #include "base/clipboard.h" | 7 #include "base/clipboard.h" |
| 8 #include "base/gfx/rect.h" | 8 #include "base/gfx/rect.h" |
| 9 #include "base/scoped_ptr.h" |
| 9 #include "chrome/app/chrome_dll_resource.h" | 10 #include "chrome/app/chrome_dll_resource.h" |
| 10 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
| 12 #include "chrome/browser/window_sizer.h" |
| 11 #include "chrome/common/pref_service.h" | 13 #include "chrome/common/pref_service.h" |
| 12 | 14 |
| 13 /////////////////////////////////////////////////////////////////////////////// | 15 /////////////////////////////////////////////////////////////////////////////// |
| 14 // ChromeViewsDelegate, views::ViewsDelegate implementation: | 16 // ChromeViewsDelegate, views::ViewsDelegate implementation: |
| 15 | 17 |
| 16 Clipboard* ChromeViewsDelegate::GetClipboard() const { | 18 Clipboard* ChromeViewsDelegate::GetClipboard() const { |
| 17 return g_browser_process->clipboard(); | 19 return g_browser_process->clipboard(); |
| 18 } | 20 } |
| 19 | 21 |
| 20 void ChromeViewsDelegate::SaveWindowPlacement(const std::wstring& window_name, | 22 void ChromeViewsDelegate::SaveWindowPlacement(const std::wstring& window_name, |
| 21 const gfx::Rect& bounds, | 23 const gfx::Rect& bounds, |
| 22 bool maximized) { | 24 bool maximized) { |
| 23 if (!g_browser_process->local_state()) | 25 if (!g_browser_process->local_state()) |
| 24 return; | 26 return; |
| 25 | 27 |
| 26 DictionaryValue* window_preferences = | 28 DictionaryValue* window_preferences = |
| 27 g_browser_process->local_state()->GetMutableDictionary( | 29 g_browser_process->local_state()->GetMutableDictionary( |
| 28 window_name.c_str()); | 30 window_name.c_str()); |
| 29 window_preferences->SetInteger(L"left", bounds.x()); | 31 window_preferences->SetInteger(L"left", bounds.x()); |
| 30 window_preferences->SetInteger(L"top", bounds.y()); | 32 window_preferences->SetInteger(L"top", bounds.y()); |
| 31 window_preferences->SetInteger(L"right", bounds.right()); | 33 window_preferences->SetInteger(L"right", bounds.right()); |
| 32 window_preferences->SetInteger(L"bottom", bounds.bottom()); | 34 window_preferences->SetInteger(L"bottom", bounds.bottom()); |
| 33 window_preferences->SetBoolean(L"maximized", maximized); | 35 window_preferences->SetBoolean(L"maximized", maximized); |
| 36 |
| 37 scoped_ptr<WindowSizer::MonitorInfoProvider> monitor_info_provider( |
| 38 WindowSizer::CreateDefaultMonitorInfoProvider()); |
| 39 gfx::Rect work_area( |
| 40 monitor_info_provider->GetMonitorWorkAreaMatching(bounds)); |
| 41 window_preferences->SetInteger(L"work_area_left", work_area.x()); |
| 42 window_preferences->SetInteger(L"work_area_top", work_area.y()); |
| 43 window_preferences->SetInteger(L"work_area_right", work_area.right()); |
| 44 window_preferences->SetInteger(L"work_area_bottom", work_area.bottom()); |
| 34 } | 45 } |
| 35 | 46 |
| 36 bool ChromeViewsDelegate::GetSavedWindowBounds(const std::wstring& window_name, | 47 bool ChromeViewsDelegate::GetSavedWindowBounds(const std::wstring& window_name, |
| 37 gfx::Rect* bounds) const { | 48 gfx::Rect* bounds) const { |
| 38 if (!g_browser_process->local_state()) | 49 if (!g_browser_process->local_state()) |
| 39 return false; | 50 return false; |
| 40 | 51 |
| 41 const DictionaryValue* dictionary = | 52 const DictionaryValue* dictionary = |
| 42 g_browser_process->local_state()->GetDictionary(window_name.c_str()); | 53 g_browser_process->local_state()->GetDictionary(window_name.c_str()); |
| 43 int left, top, right, bottom; | 54 int left, top, right, bottom; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 62 return dictionary && dictionary->GetBoolean(L"maximized", maximized) && | 73 return dictionary && dictionary->GetBoolean(L"maximized", maximized) && |
| 63 maximized; | 74 maximized; |
| 64 } | 75 } |
| 65 | 76 |
| 66 #if defined(OS_WIN) | 77 #if defined(OS_WIN) |
| 67 HICON ChromeViewsDelegate::GetDefaultWindowIcon() const { | 78 HICON ChromeViewsDelegate::GetDefaultWindowIcon() const { |
| 68 return LoadIcon(GetModuleHandle(L"chrome.dll"), | 79 return LoadIcon(GetModuleHandle(L"chrome.dll"), |
| 69 MAKEINTRESOURCE(IDR_MAINFRAME)); | 80 MAKEINTRESOURCE(IDR_MAINFRAME)); |
| 70 } | 81 } |
| 71 #endif | 82 #endif |
| OLD | NEW |