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