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

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

Issue 6247017: Revert 72153 - Remove user-related data from local_state and add to user_pre... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 11 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
Property Changes:
Added: svn:mergeinfo
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/scoped_ptr.h" 7 #include "base/scoped_ptr.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/browser_process.h" 9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/prefs/pref_service.h" 10 #include "chrome/browser/prefs/pref_service.h"
11 #include "chrome/browser/profiles/profile_manager.h"
12 #include "chrome/browser/ui/views/accessibility_event_router_views.h" 11 #include "chrome/browser/ui/views/accessibility_event_router_views.h"
13 #include "chrome/browser/ui/window_sizer.h" 12 #include "chrome/browser/ui/window_sizer.h"
14 #include "gfx/rect.h" 13 #include "gfx/rect.h"
15 #include "ui/base/clipboard/clipboard.h" 14 #include "ui/base/clipboard/clipboard.h"
16 15
17 #if defined(OS_WIN) 16 #if defined(OS_WIN)
18 #include "chrome/browser/app_icon_win.h" 17 #include "chrome/browser/app_icon_win.h"
19 #endif 18 #endif
20 19
21 /////////////////////////////////////////////////////////////////////////////// 20 ///////////////////////////////////////////////////////////////////////////////
22 // ChromeViewsDelegate, views::ViewsDelegate implementation: 21 // ChromeViewsDelegate, views::ViewsDelegate implementation:
23 22
24 ui::Clipboard* ChromeViewsDelegate::GetClipboard() const { 23 ui::Clipboard* ChromeViewsDelegate::GetClipboard() const {
25 return g_browser_process->clipboard(); 24 return g_browser_process->clipboard();
26 } 25 }
27 26
28 void ChromeViewsDelegate::SaveWindowPlacement(const std::wstring& window_name, 27 void ChromeViewsDelegate::SaveWindowPlacement(const std::wstring& window_name,
29 const gfx::Rect& bounds, 28 const gfx::Rect& bounds,
30 bool maximized) { 29 bool maximized) {
31 if (!g_browser_process->profile_manager()) 30 if (!g_browser_process->local_state())
32 return; 31 return;
33 32
34 DictionaryValue* window_preferences = 33 DictionaryValue* window_preferences =
35 g_browser_process->profile_manager()->GetDefaultProfile()->GetPrefs()-> 34 g_browser_process->local_state()->GetMutableDictionary(
36 GetMutableDictionary(WideToUTF8(window_name).c_str()); 35 WideToUTF8(window_name).c_str());
37 window_preferences->SetInteger("left", bounds.x()); 36 window_preferences->SetInteger("left", bounds.x());
38 window_preferences->SetInteger("top", bounds.y()); 37 window_preferences->SetInteger("top", bounds.y());
39 window_preferences->SetInteger("right", bounds.right()); 38 window_preferences->SetInteger("right", bounds.right());
40 window_preferences->SetInteger("bottom", bounds.bottom()); 39 window_preferences->SetInteger("bottom", bounds.bottom());
41 window_preferences->SetBoolean("maximized", maximized); 40 window_preferences->SetBoolean("maximized", maximized);
42 41
43 scoped_ptr<WindowSizer::MonitorInfoProvider> monitor_info_provider( 42 scoped_ptr<WindowSizer::MonitorInfoProvider> monitor_info_provider(
44 WindowSizer::CreateDefaultMonitorInfoProvider()); 43 WindowSizer::CreateDefaultMonitorInfoProvider());
45 gfx::Rect work_area( 44 gfx::Rect work_area(
46 monitor_info_provider->GetMonitorWorkAreaMatching(bounds)); 45 monitor_info_provider->GetMonitorWorkAreaMatching(bounds));
47 window_preferences->SetInteger("work_area_left", work_area.x()); 46 window_preferences->SetInteger("work_area_left", work_area.x());
48 window_preferences->SetInteger("work_area_top", work_area.y()); 47 window_preferences->SetInteger("work_area_top", work_area.y());
49 window_preferences->SetInteger("work_area_right", work_area.right()); 48 window_preferences->SetInteger("work_area_right", work_area.right());
50 window_preferences->SetInteger("work_area_bottom", work_area.bottom()); 49 window_preferences->SetInteger("work_area_bottom", work_area.bottom());
51 } 50 }
52 51
53 bool ChromeViewsDelegate::GetSavedWindowBounds(const std::wstring& window_name, 52 bool ChromeViewsDelegate::GetSavedWindowBounds(const std::wstring& window_name,
54 gfx::Rect* bounds) const { 53 gfx::Rect* bounds) const {
55 if (!g_browser_process->profile_manager()) 54 if (!g_browser_process->local_state())
56 return false; 55 return false;
57 56
58 const DictionaryValue* dictionary = 57 const DictionaryValue* dictionary =
59 g_browser_process->profile_manager()->GetDefaultProfile()->GetPrefs()-> 58 g_browser_process->local_state()->GetDictionary(
60 GetDictionary(WideToUTF8(window_name).c_str()); 59 WideToUTF8(window_name).c_str());
61 int left, top, right, bottom; 60 int left, top, right, bottom;
62 if (!dictionary || !dictionary->GetInteger("left", &left) || 61 if (!dictionary || !dictionary->GetInteger("left", &left) ||
63 !dictionary->GetInteger("top", &top) || 62 !dictionary->GetInteger("top", &top) ||
64 !dictionary->GetInteger("right", &right) || 63 !dictionary->GetInteger("right", &right) ||
65 !dictionary->GetInteger("bottom", &bottom)) 64 !dictionary->GetInteger("bottom", &bottom))
66 return false; 65 return false;
67 66
68 bounds->SetRect(left, top, right - left, bottom - top); 67 bounds->SetRect(left, top, right - left, bottom - top);
69 return true; 68 return true;
70 } 69 }
71 70
72 bool ChromeViewsDelegate::GetSavedMaximizedState( 71 bool ChromeViewsDelegate::GetSavedMaximizedState(
73 const std::wstring& window_name, 72 const std::wstring& window_name,
74 bool* maximized) const { 73 bool* maximized) const {
75 if (!g_browser_process->profile_manager()) 74 if (!g_browser_process->local_state())
76 return false; 75 return false;
77 76
78 const DictionaryValue* dictionary = 77 const DictionaryValue* dictionary =
79 g_browser_process->profile_manager()->GetDefaultProfile()->GetPrefs()-> 78 g_browser_process->local_state()->GetDictionary(
80 GetDictionary(WideToUTF8(window_name).c_str()); 79 WideToUTF8(window_name).c_str());
81
82 return dictionary && dictionary->GetBoolean("maximized", maximized) && 80 return dictionary && dictionary->GetBoolean("maximized", maximized) &&
83 maximized; 81 maximized;
84 } 82 }
85 83
86 void ChromeViewsDelegate::NotifyAccessibilityEvent( 84 void ChromeViewsDelegate::NotifyAccessibilityEvent(
87 views::View* view, AccessibilityTypes::Event event_type) { 85 views::View* view, AccessibilityTypes::Event event_type) {
88 AccessibilityEventRouterViews::GetInstance()->HandleAccessibilityEvent( 86 AccessibilityEventRouterViews::GetInstance()->HandleAccessibilityEvent(
89 view, event_type); 87 view, event_type);
90 } 88 }
91 89
92 #if defined(OS_WIN) 90 #if defined(OS_WIN)
93 HICON ChromeViewsDelegate::GetDefaultWindowIcon() const { 91 HICON ChromeViewsDelegate::GetDefaultWindowIcon() const {
94 return GetAppIcon(); 92 return GetAppIcon();
95 } 93 }
96 #endif 94 #endif
97 95
98 void ChromeViewsDelegate::AddRef() { 96 void ChromeViewsDelegate::AddRef() {
99 g_browser_process->AddRefModule(); 97 g_browser_process->AddRefModule();
100 } 98 }
101 99
102 void ChromeViewsDelegate::ReleaseRef() { 100 void ChromeViewsDelegate::ReleaseRef() {
103 g_browser_process->ReleaseModule(); 101 g_browser_process->ReleaseModule();
104 } 102 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/browser_window_gtk.cc ('k') | chrome/browser/ui/views/frame/browser_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698