Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(87)

Side by Side Diff: chrome/browser/ui/views/chrome_views_delegate.cc

Issue 7748036: Restoring a session should restore window minimization state on Windows (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 return g_browser_process->clipboard(); 54 return g_browser_process->clipboard();
55 } 55 }
56 56
57 views::View* ChromeViewsDelegate::GetDefaultParentView() { 57 views::View* ChromeViewsDelegate::GetDefaultParentView() {
58 return default_parent_view; 58 return default_parent_view;
59 } 59 }
60 60
61 void ChromeViewsDelegate::SaveWindowPlacement(const views::Widget* window, 61 void ChromeViewsDelegate::SaveWindowPlacement(const views::Widget* window,
62 const std::wstring& window_name, 62 const std::wstring& window_name,
63 const gfx::Rect& bounds, 63 const gfx::Rect& bounds,
64 bool maximized) { 64 ui::WindowShowState show_state) {
65 PrefService* prefs = GetPrefsForWindow(window); 65 PrefService* prefs = GetPrefsForWindow(window);
66 if (!prefs) 66 if (!prefs)
67 return; 67 return;
68 68
69 DCHECK(prefs->FindPreference(WideToUTF8(window_name).c_str())); 69 DCHECK(prefs->FindPreference(WideToUTF8(window_name).c_str()));
70 DictionaryPrefUpdate update(prefs, WideToUTF8(window_name).c_str()); 70 DictionaryPrefUpdate update(prefs, WideToUTF8(window_name).c_str());
71 DictionaryValue* window_preferences = update.Get(); 71 DictionaryValue* window_preferences = update.Get();
72 window_preferences->SetInteger("left", bounds.x()); 72 window_preferences->SetInteger("left", bounds.x());
73 window_preferences->SetInteger("top", bounds.y()); 73 window_preferences->SetInteger("top", bounds.y());
74 window_preferences->SetInteger("right", bounds.right()); 74 window_preferences->SetInteger("right", bounds.right());
75 window_preferences->SetInteger("bottom", bounds.bottom()); 75 window_preferences->SetInteger("bottom", bounds.bottom());
76 window_preferences->SetBoolean("maximized", maximized); 76 window_preferences->SetBoolean("maximized",
77 show_state == ui::SHOW_STATE_MAXIMIZED);
77 78
78 scoped_ptr<WindowSizer::MonitorInfoProvider> monitor_info_provider( 79 scoped_ptr<WindowSizer::MonitorInfoProvider> monitor_info_provider(
79 WindowSizer::CreateDefaultMonitorInfoProvider()); 80 WindowSizer::CreateDefaultMonitorInfoProvider());
80 gfx::Rect work_area( 81 gfx::Rect work_area(
81 monitor_info_provider->GetMonitorWorkAreaMatching(bounds)); 82 monitor_info_provider->GetMonitorWorkAreaMatching(bounds));
82 window_preferences->SetInteger("work_area_left", work_area.x()); 83 window_preferences->SetInteger("work_area_left", work_area.x());
83 window_preferences->SetInteger("work_area_top", work_area.y()); 84 window_preferences->SetInteger("work_area_top", work_area.y());
84 window_preferences->SetInteger("work_area_right", work_area.right()); 85 window_preferences->SetInteger("work_area_right", work_area.right());
85 window_preferences->SetInteger("work_area_bottom", work_area.bottom()); 86 window_preferences->SetInteger("work_area_bottom", work_area.bottom());
86 } 87 }
87 88
88 bool ChromeViewsDelegate::GetSavedWindowBounds(const std::wstring& window_name, 89 bool ChromeViewsDelegate::GetSavedWindowPlacement(
89 gfx::Rect* bounds) const { 90 const std::wstring& window_name,
91 gfx::Rect* bounds,
92 ui::WindowShowState* show_state) const {
90 PrefService* prefs = g_browser_process->local_state(); 93 PrefService* prefs = g_browser_process->local_state();
91 if (!prefs) 94 if (!prefs)
92 return false; 95 return false;
93 96
94 DCHECK(prefs->FindPreference(WideToUTF8(window_name).c_str())); 97 DCHECK(prefs->FindPreference(WideToUTF8(window_name).c_str()));
95 const DictionaryValue* dictionary = 98 const DictionaryValue* dictionary =
96 prefs->GetDictionary(WideToUTF8(window_name).c_str()); 99 prefs->GetDictionary(WideToUTF8(window_name).c_str());
97 int left, top, right, bottom; 100 int left, top, right, bottom;
98 if (!dictionary || !dictionary->GetInteger("left", &left) || 101 if (!dictionary || !dictionary->GetInteger("left", &left) ||
99 !dictionary->GetInteger("top", &top) || 102 !dictionary->GetInteger("top", &top) ||
100 !dictionary->GetInteger("right", &right) || 103 !dictionary->GetInteger("right", &right) ||
101 !dictionary->GetInteger("bottom", &bottom)) 104 !dictionary->GetInteger("bottom", &bottom))
102 return false; 105 return false;
103 106
104 bounds->SetRect(left, top, right - left, bottom - top); 107 bounds->SetRect(left, top, right - left, bottom - top);
108
109 bool maximized = false;
110 if (dictionary)
111 dictionary->GetBoolean("maximized", &maximized);
112 *show_state = maximized ? ui::SHOW_STATE_MAXIMIZED : ui::SHOW_STATE_NORMAL;
113
105 return true; 114 return true;
106 } 115 }
107 116
108 bool ChromeViewsDelegate::GetSavedMaximizedState(
109 const std::wstring& window_name,
110 bool* maximized) const {
111 PrefService* prefs = g_browser_process->local_state();
112 if (!prefs)
113 return false;
114
115 DCHECK(prefs->FindPreference(WideToUTF8(window_name).c_str()));
116 const DictionaryValue* dictionary =
117 prefs->GetDictionary(WideToUTF8(window_name).c_str());
118
119 return dictionary && dictionary->GetBoolean("maximized", maximized) &&
120 maximized;
121 }
122
123 void ChromeViewsDelegate::NotifyAccessibilityEvent( 117 void ChromeViewsDelegate::NotifyAccessibilityEvent(
124 views::View* view, ui::AccessibilityTypes::Event event_type) { 118 views::View* view, ui::AccessibilityTypes::Event event_type) {
125 AccessibilityEventRouterViews::GetInstance()->HandleAccessibilityEvent( 119 AccessibilityEventRouterViews::GetInstance()->HandleAccessibilityEvent(
126 view, event_type); 120 view, event_type);
127 } 121 }
128 122
129 void ChromeViewsDelegate::NotifyMenuItemFocused( 123 void ChromeViewsDelegate::NotifyMenuItemFocused(
130 const std::wstring& menu_name, 124 const std::wstring& menu_name,
131 const std::wstring& menu_item_name, 125 const std::wstring& menu_item_name,
132 int item_index, 126 int item_index,
(...skipping 13 matching lines...) Expand all
146 g_browser_process->AddRefModule(); 140 g_browser_process->AddRefModule();
147 } 141 }
148 142
149 void ChromeViewsDelegate::ReleaseRef() { 143 void ChromeViewsDelegate::ReleaseRef() {
150 g_browser_process->ReleaseModule(); 144 g_browser_process->ReleaseModule();
151 } 145 }
152 146
153 int ChromeViewsDelegate::GetDispositionForEvent(int event_flags) { 147 int ChromeViewsDelegate::GetDispositionForEvent(int event_flags) {
154 return event_utils::DispositionFromEventFlags(event_flags); 148 return event_utils::DispositionFromEventFlags(event_flags);
155 } 149 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/chrome_views_delegate.h ('k') | chrome/browser/ui/views/frame/browser_frame.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698