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

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: GetSavedWindowPlacement consolidation, Test, and All case. 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 return g_browser_process->clipboard(); 58 return g_browser_process->clipboard();
59 } 59 }
60 60
61 views::View* ChromeViewsDelegate::GetDefaultParentView() { 61 views::View* ChromeViewsDelegate::GetDefaultParentView() {
62 return default_parent_view; 62 return default_parent_view;
63 } 63 }
64 64
65 void ChromeViewsDelegate::SaveWindowPlacement(const views::Widget* window, 65 void ChromeViewsDelegate::SaveWindowPlacement(const views::Widget* window,
66 const std::wstring& window_name, 66 const std::wstring& window_name,
67 const gfx::Rect& bounds, 67 const gfx::Rect& bounds,
68 bool maximized) { 68 ui::WindowShowState show_state) {
69 bool using_local_state = false; 69 bool using_local_state = false;
70 PrefService* prefs = GetPrefsForWindow(window, &using_local_state); 70 PrefService* prefs = GetPrefsForWindow(window, &using_local_state);
71 if (!prefs) 71 if (!prefs)
72 return; 72 return;
73 73
74 CHECK(prefs->FindPreference(WideToUTF8(window_name).c_str())) << " " << 74 CHECK(prefs->FindPreference(WideToUTF8(window_name).c_str())) << " " <<
75 browser_shutdown::GetShutdownType() << " " << using_local_state << " " << 75 browser_shutdown::GetShutdownType() << " " << using_local_state << " " <<
76 window->destroy_state(); 76 window->destroy_state();
77 DictionaryPrefUpdate update(prefs, WideToUTF8(window_name).c_str()); 77 DictionaryPrefUpdate update(prefs, WideToUTF8(window_name).c_str());
78 DictionaryValue* window_preferences = update.Get(); 78 DictionaryValue* window_preferences = update.Get();
79 window_preferences->SetInteger("left", bounds.x()); 79 window_preferences->SetInteger("left", bounds.x());
80 window_preferences->SetInteger("top", bounds.y()); 80 window_preferences->SetInteger("top", bounds.y());
81 window_preferences->SetInteger("right", bounds.right()); 81 window_preferences->SetInteger("right", bounds.right());
82 window_preferences->SetInteger("bottom", bounds.bottom()); 82 window_preferences->SetInteger("bottom", bounds.bottom());
83 window_preferences->SetBoolean("maximized", maximized); 83 window_preferences->SetBoolean("maximized",
84 show_state == ui::SHOW_STATE_MAXIMIZED);
84 85
85 scoped_ptr<WindowSizer::MonitorInfoProvider> monitor_info_provider( 86 scoped_ptr<WindowSizer::MonitorInfoProvider> monitor_info_provider(
86 WindowSizer::CreateDefaultMonitorInfoProvider()); 87 WindowSizer::CreateDefaultMonitorInfoProvider());
87 gfx::Rect work_area( 88 gfx::Rect work_area(
88 monitor_info_provider->GetMonitorWorkAreaMatching(bounds)); 89 monitor_info_provider->GetMonitorWorkAreaMatching(bounds));
89 window_preferences->SetInteger("work_area_left", work_area.x()); 90 window_preferences->SetInteger("work_area_left", work_area.x());
90 window_preferences->SetInteger("work_area_top", work_area.y()); 91 window_preferences->SetInteger("work_area_top", work_area.y());
91 window_preferences->SetInteger("work_area_right", work_area.right()); 92 window_preferences->SetInteger("work_area_right", work_area.right());
92 window_preferences->SetInteger("work_area_bottom", work_area.bottom()); 93 window_preferences->SetInteger("work_area_bottom", work_area.bottom());
93 } 94 }
94 95
95 bool ChromeViewsDelegate::GetSavedWindowBounds(const std::wstring& window_name, 96 bool ChromeViewsDelegate::GetSavedWindowPlacement(
96 gfx::Rect* bounds) const { 97 const std::wstring& window_name,
98 gfx::Rect* bounds,
99 ui::WindowShowState* show_state) const {
97 PrefService* prefs = g_browser_process->local_state(); 100 PrefService* prefs = g_browser_process->local_state();
98 if (!prefs) 101 if (!prefs)
99 return false; 102 return false;
100 103
101 DCHECK(prefs->FindPreference(WideToUTF8(window_name).c_str())); 104 DCHECK(prefs->FindPreference(WideToUTF8(window_name).c_str()));
102 const DictionaryValue* dictionary = 105 const DictionaryValue* dictionary =
103 prefs->GetDictionary(WideToUTF8(window_name).c_str()); 106 prefs->GetDictionary(WideToUTF8(window_name).c_str());
104 int left, top, right, bottom; 107 int left, top, right, bottom;
105 if (!dictionary || !dictionary->GetInteger("left", &left) || 108 if (!dictionary || !dictionary->GetInteger("left", &left) ||
106 !dictionary->GetInteger("top", &top) || 109 !dictionary->GetInteger("top", &top) ||
107 !dictionary->GetInteger("right", &right) || 110 !dictionary->GetInteger("right", &right) ||
108 !dictionary->GetInteger("bottom", &bottom)) 111 !dictionary->GetInteger("bottom", &bottom))
109 return false; 112 return false;
110 113
111 bounds->SetRect(left, top, right - left, bottom - top); 114 bounds->SetRect(left, top, right - left, bottom - top);
115
116 bool maximized = false;
117 return dictionary && dictionary->GetBoolean("maximized", &maximized);
118 *show_state = maximized ? ui::SHOW_STATE_MAXIMIZED : ui::SHOW_STATE_NORMAL;
119
112 return true; 120 return true;
113 } 121 }
114 122
115 bool ChromeViewsDelegate::GetSavedMaximizedState(
116 const std::wstring& window_name,
117 bool* maximized) const {
118 PrefService* prefs = g_browser_process->local_state();
119 if (!prefs)
120 return false;
121
122 DCHECK(prefs->FindPreference(WideToUTF8(window_name).c_str()));
123 const DictionaryValue* dictionary =
124 prefs->GetDictionary(WideToUTF8(window_name).c_str());
125
126 return dictionary && dictionary->GetBoolean("maximized", maximized) &&
127 maximized;
128 }
129
130 void ChromeViewsDelegate::NotifyAccessibilityEvent( 123 void ChromeViewsDelegate::NotifyAccessibilityEvent(
131 views::View* view, ui::AccessibilityTypes::Event event_type) { 124 views::View* view, ui::AccessibilityTypes::Event event_type) {
132 AccessibilityEventRouterViews::GetInstance()->HandleAccessibilityEvent( 125 AccessibilityEventRouterViews::GetInstance()->HandleAccessibilityEvent(
133 view, event_type); 126 view, event_type);
134 } 127 }
135 128
136 void ChromeViewsDelegate::NotifyMenuItemFocused( 129 void ChromeViewsDelegate::NotifyMenuItemFocused(
137 const std::wstring& menu_name, 130 const std::wstring& menu_name,
138 const std::wstring& menu_item_name, 131 const std::wstring& menu_item_name,
139 int item_index, 132 int item_index,
(...skipping 13 matching lines...) Expand all
153 g_browser_process->AddRefModule(); 146 g_browser_process->AddRefModule();
154 } 147 }
155 148
156 void ChromeViewsDelegate::ReleaseRef() { 149 void ChromeViewsDelegate::ReleaseRef() {
157 g_browser_process->ReleaseModule(); 150 g_browser_process->ReleaseModule();
158 } 151 }
159 152
160 int ChromeViewsDelegate::GetDispositionForEvent(int event_flags) { 153 int ChromeViewsDelegate::GetDispositionForEvent(int event_flags) {
161 return event_utils::DispositionFromEventFlags(event_flags); 154 return event_utils::DispositionFromEventFlags(event_flags);
162 } 155 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698