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

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

Issue 7790010: Revert 98679 - Restoring a session should restore window minimization state on Windows (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: 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 ui::WindowShowState show_state) { 64 bool maximized) {
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", 76 window_preferences->SetBoolean("maximized", maximized);
77 show_state == ui::SHOW_STATE_MAXIMIZED);
78 77
79 scoped_ptr<WindowSizer::MonitorInfoProvider> monitor_info_provider( 78 scoped_ptr<WindowSizer::MonitorInfoProvider> monitor_info_provider(
80 WindowSizer::CreateDefaultMonitorInfoProvider()); 79 WindowSizer::CreateDefaultMonitorInfoProvider());
81 gfx::Rect work_area( 80 gfx::Rect work_area(
82 monitor_info_provider->GetMonitorWorkAreaMatching(bounds)); 81 monitor_info_provider->GetMonitorWorkAreaMatching(bounds));
83 window_preferences->SetInteger("work_area_left", work_area.x()); 82 window_preferences->SetInteger("work_area_left", work_area.x());
84 window_preferences->SetInteger("work_area_top", work_area.y()); 83 window_preferences->SetInteger("work_area_top", work_area.y());
85 window_preferences->SetInteger("work_area_right", work_area.right()); 84 window_preferences->SetInteger("work_area_right", work_area.right());
86 window_preferences->SetInteger("work_area_bottom", work_area.bottom()); 85 window_preferences->SetInteger("work_area_bottom", work_area.bottom());
87 } 86 }
88 87
89 bool ChromeViewsDelegate::GetSavedWindowPlacement( 88 bool ChromeViewsDelegate::GetSavedWindowBounds(const std::wstring& window_name,
90 const std::wstring& window_name, 89 gfx::Rect* bounds) const {
91 gfx::Rect* bounds,
92 ui::WindowShowState* show_state) const {
93 PrefService* prefs = g_browser_process->local_state(); 90 PrefService* prefs = g_browser_process->local_state();
94 if (!prefs) 91 if (!prefs)
95 return false; 92 return false;
96 93
97 DCHECK(prefs->FindPreference(WideToUTF8(window_name).c_str())); 94 DCHECK(prefs->FindPreference(WideToUTF8(window_name).c_str()));
98 const DictionaryValue* dictionary = 95 const DictionaryValue* dictionary =
99 prefs->GetDictionary(WideToUTF8(window_name).c_str()); 96 prefs->GetDictionary(WideToUTF8(window_name).c_str());
100 int left, top, right, bottom; 97 int left, top, right, bottom;
101 if (!dictionary || !dictionary->GetInteger("left", &left) || 98 if (!dictionary || !dictionary->GetInteger("left", &left) ||
102 !dictionary->GetInteger("top", &top) || 99 !dictionary->GetInteger("top", &top) ||
103 !dictionary->GetInteger("right", &right) || 100 !dictionary->GetInteger("right", &right) ||
104 !dictionary->GetInteger("bottom", &bottom)) 101 !dictionary->GetInteger("bottom", &bottom))
105 return false; 102 return false;
106 103
107 bounds->SetRect(left, top, right - left, bottom - top); 104 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
114 return true; 105 return true;
115 } 106 }
116 107
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
117 void ChromeViewsDelegate::NotifyAccessibilityEvent( 123 void ChromeViewsDelegate::NotifyAccessibilityEvent(
118 views::View* view, ui::AccessibilityTypes::Event event_type) { 124 views::View* view, ui::AccessibilityTypes::Event event_type) {
119 AccessibilityEventRouterViews::GetInstance()->HandleAccessibilityEvent( 125 AccessibilityEventRouterViews::GetInstance()->HandleAccessibilityEvent(
120 view, event_type); 126 view, event_type);
121 } 127 }
122 128
123 void ChromeViewsDelegate::NotifyMenuItemFocused( 129 void ChromeViewsDelegate::NotifyMenuItemFocused(
124 const std::wstring& menu_name, 130 const std::wstring& menu_name,
125 const std::wstring& menu_item_name, 131 const std::wstring& menu_item_name,
126 int item_index, 132 int item_index,
(...skipping 13 matching lines...) Expand all
140 g_browser_process->AddRefModule(); 146 g_browser_process->AddRefModule();
141 } 147 }
142 148
143 void ChromeViewsDelegate::ReleaseRef() { 149 void ChromeViewsDelegate::ReleaseRef() {
144 g_browser_process->ReleaseModule(); 150 g_browser_process->ReleaseModule();
145 } 151 }
146 152
147 int ChromeViewsDelegate::GetDispositionForEvent(int event_flags) { 153 int ChromeViewsDelegate::GetDispositionForEvent(int event_flags) {
148 return event_utils::DispositionFromEventFlags(event_flags); 154 return event_utils::DispositionFromEventFlags(event_flags);
149 } 155 }
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