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

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

Issue 7745049: Reverts debugging code added for 91396. I've tracked down the bug and (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 4 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
« no previous file with comments | « no previous file | views/widget/widget.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
11 #include "chrome/browser/browser_shutdown.h"
12 #include "chrome/browser/prefs/pref_service.h" 11 #include "chrome/browser/prefs/pref_service.h"
13 #include "chrome/browser/prefs/scoped_user_pref_update.h" 12 #include "chrome/browser/prefs/scoped_user_pref_update.h"
14 #include "chrome/browser/profiles/profile_manager.h" 13 #include "chrome/browser/profiles/profile_manager.h"
15 #include "chrome/browser/ui/views/accessibility_event_router_views.h" 14 #include "chrome/browser/ui/views/accessibility_event_router_views.h"
16 #include "chrome/browser/ui/views/event_utils.h" 15 #include "chrome/browser/ui/views/event_utils.h"
17 #include "chrome/browser/ui/window_sizer.h" 16 #include "chrome/browser/ui/window_sizer.h"
18 #include "chrome/common/pref_names.h" 17 #include "chrome/common/pref_names.h"
19 #include "ui/base/clipboard/clipboard.h" 18 #include "ui/base/clipboard/clipboard.h"
20 #include "ui/gfx/rect.h" 19 #include "ui/gfx/rect.h"
21 #include "views/widget/native_widget.h" 20 #include "views/widget/native_widget.h"
22 #include "views/widget/widget.h" 21 #include "views/widget/widget.h"
23 22
24 #if defined(OS_WIN) 23 #if defined(OS_WIN)
25 #include "chrome/browser/app_icon_win.h" 24 #include "chrome/browser/app_icon_win.h"
26 #endif 25 #endif
27 26
28 namespace { 27 namespace {
29 28
30 // If the given window has a profile associated with it, use that profile's 29 // If the given window has a profile associated with it, use that profile's
31 // preference service. Otherwise, store and retrieve the data from Local State. 30 // preference service. Otherwise, store and retrieve the data from Local State.
32 // This function may return NULL if the necessary pref service has not yet 31 // This function may return NULL if the necessary pref service has not yet
33 // been initialized. 32 // been initialized.
34 // TODO(mirandac): This function will also separate windows by profile in a 33 // TODO(mirandac): This function will also separate windows by profile in a
35 // multi-profile environment. 34 // multi-profile environment.
36 PrefService* GetPrefsForWindow(const views::Widget* window, 35 PrefService* GetPrefsForWindow(const views::Widget* window) {
37 bool* using_local_state) {
38 Profile* profile = reinterpret_cast<Profile*>( 36 Profile* profile = reinterpret_cast<Profile*>(
39 window->GetNativeWindowProperty(Profile::kProfileKey)); 37 window->GetNativeWindowProperty(Profile::kProfileKey));
40 if (!profile) { 38 if (!profile) {
41 // Use local state for windows that have no explicit profile. 39 // Use local state for windows that have no explicit profile.
42 *using_local_state = true;
43 return g_browser_process->local_state(); 40 return g_browser_process->local_state();
44 } 41 }
45 *using_local_state = false;
46 return profile->GetPrefs(); 42 return profile->GetPrefs();
47 } 43 }
48 44
49 } // namespace 45 } // namespace
50 46
51 // static 47 // static
52 views::View* ChromeViewsDelegate::default_parent_view = NULL; 48 views::View* ChromeViewsDelegate::default_parent_view = NULL;
53 49
54 /////////////////////////////////////////////////////////////////////////////// 50 ///////////////////////////////////////////////////////////////////////////////
55 // ChromeViewsDelegate, views::ViewsDelegate implementation: 51 // ChromeViewsDelegate, views::ViewsDelegate implementation:
56 52
57 ui::Clipboard* ChromeViewsDelegate::GetClipboard() const { 53 ui::Clipboard* ChromeViewsDelegate::GetClipboard() const {
58 return g_browser_process->clipboard(); 54 return g_browser_process->clipboard();
59 } 55 }
60 56
61 views::View* ChromeViewsDelegate::GetDefaultParentView() { 57 views::View* ChromeViewsDelegate::GetDefaultParentView() {
62 return default_parent_view; 58 return default_parent_view;
63 } 59 }
64 60
65 void ChromeViewsDelegate::SaveWindowPlacement(const views::Widget* window, 61 void ChromeViewsDelegate::SaveWindowPlacement(const views::Widget* window,
66 const std::wstring& window_name, 62 const std::wstring& window_name,
67 const gfx::Rect& bounds, 63 const gfx::Rect& bounds,
68 bool maximized) { 64 bool maximized) {
69 bool using_local_state = false; 65 PrefService* prefs = GetPrefsForWindow(window);
70 PrefService* prefs = GetPrefsForWindow(window, &using_local_state);
71 if (!prefs) 66 if (!prefs)
72 return; 67 return;
73 68
74 CHECK(prefs->FindPreference(WideToUTF8(window_name).c_str())) << " " << 69 DCHECK(prefs->FindPreference(WideToUTF8(window_name).c_str()));
75 browser_shutdown::GetShutdownType() << " " << using_local_state << " " <<
76 window->destroy_state();
77 DictionaryPrefUpdate update(prefs, WideToUTF8(window_name).c_str()); 70 DictionaryPrefUpdate update(prefs, WideToUTF8(window_name).c_str());
78 DictionaryValue* window_preferences = update.Get(); 71 DictionaryValue* window_preferences = update.Get();
79 window_preferences->SetInteger("left", bounds.x()); 72 window_preferences->SetInteger("left", bounds.x());
80 window_preferences->SetInteger("top", bounds.y()); 73 window_preferences->SetInteger("top", bounds.y());
81 window_preferences->SetInteger("right", bounds.right()); 74 window_preferences->SetInteger("right", bounds.right());
82 window_preferences->SetInteger("bottom", bounds.bottom()); 75 window_preferences->SetInteger("bottom", bounds.bottom());
83 window_preferences->SetBoolean("maximized", maximized); 76 window_preferences->SetBoolean("maximized", maximized);
84 77
85 scoped_ptr<WindowSizer::MonitorInfoProvider> monitor_info_provider( 78 scoped_ptr<WindowSizer::MonitorInfoProvider> monitor_info_provider(
86 WindowSizer::CreateDefaultMonitorInfoProvider()); 79 WindowSizer::CreateDefaultMonitorInfoProvider());
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
« no previous file with comments | « no previous file | views/widget/widget.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698