OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 window->GetNativeWindowProperty(Profile::kProfileKey)); | 55 window->GetNativeWindowProperty(Profile::kProfileKey)); |
56 if (!profile) { | 56 if (!profile) { |
57 // Use local state for windows that have no explicit profile. | 57 // Use local state for windows that have no explicit profile. |
58 return g_browser_process->local_state(); | 58 return g_browser_process->local_state(); |
59 } | 59 } |
60 return profile->GetPrefs(); | 60 return profile->GetPrefs(); |
61 } | 61 } |
62 | 62 |
63 } // namespace | 63 } // namespace |
64 | 64 |
| 65 |
| 66 ChromeViewsDelegate::ChromeViewsDelegate() : is_ref_counting_(false) { |
| 67 } |
| 68 |
65 /////////////////////////////////////////////////////////////////////////////// | 69 /////////////////////////////////////////////////////////////////////////////// |
66 // ChromeViewsDelegate, views::ViewsDelegate implementation: | 70 // ChromeViewsDelegate, views::ViewsDelegate implementation: |
67 | 71 |
68 void ChromeViewsDelegate::SaveWindowPlacement(const views::Widget* window, | 72 void ChromeViewsDelegate::SaveWindowPlacement(const views::Widget* window, |
69 const std::string& window_name, | 73 const std::string& window_name, |
70 const gfx::Rect& bounds, | 74 const gfx::Rect& bounds, |
71 ui::WindowShowState show_state) { | 75 ui::WindowShowState show_state) { |
72 PrefService* prefs = GetPrefsForWindow(window); | 76 PrefService* prefs = GetPrefsForWindow(window); |
73 if (!prefs) | 77 if (!prefs) |
74 return; | 78 return; |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 return true; | 159 return true; |
156 #else | 160 #else |
157 NOTIMPLEMENTED(); | 161 NOTIMPLEMENTED(); |
158 return false; | 162 return false; |
159 #endif | 163 #endif |
160 #else | 164 #else |
161 return false; | 165 return false; |
162 #endif | 166 #endif |
163 } | 167 } |
164 | 168 |
| 169 void ChromeViewsDelegate::SetRefCounting(bool is_ref_counting) { |
| 170 is_ref_counting_ = is_ref_counting; |
| 171 } |
| 172 |
165 void ChromeViewsDelegate::AddRef() { | 173 void ChromeViewsDelegate::AddRef() { |
166 g_browser_process->AddRefModule(); | 174 if (is_ref_counting_) |
| 175 g_browser_process->AddRefModule(); |
167 } | 176 } |
168 | 177 |
169 void ChromeViewsDelegate::ReleaseRef() { | 178 void ChromeViewsDelegate::ReleaseRef() { |
170 g_browser_process->ReleaseModule(); | 179 if (is_ref_counting_) |
| 180 g_browser_process->ReleaseModule(); |
171 } | 181 } |
172 | 182 |
173 content::WebContents* ChromeViewsDelegate::CreateWebContents( | 183 content::WebContents* ChromeViewsDelegate::CreateWebContents( |
174 content::BrowserContext* browser_context, | 184 content::BrowserContext* browser_context, |
175 content::SiteInstance* site_instance) { | 185 content::SiteInstance* site_instance) { |
176 return NULL; | 186 return NULL; |
177 } | 187 } |
178 | 188 |
179 void ChromeViewsDelegate::OnBeforeWidgetInit( | 189 void ChromeViewsDelegate::OnBeforeWidgetInit( |
180 views::Widget::InitParams* params, | 190 views::Widget::InitParams* params, |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 // should remove this check here. | 262 // should remove this check here. |
253 gfx::NativeView to_check = | 263 gfx::NativeView to_check = |
254 params->context ? params->context : params->parent; | 264 params->context ? params->context : params->parent; |
255 if (chrome::GetHostDesktopTypeForNativeView(to_check) == | 265 if (chrome::GetHostDesktopTypeForNativeView(to_check) == |
256 chrome::HOST_DESKTOP_TYPE_NATIVE) { | 266 chrome::HOST_DESKTOP_TYPE_NATIVE) { |
257 params->native_widget = new views::DesktopNativeWidgetAura(delegate); | 267 params->native_widget = new views::DesktopNativeWidgetAura(delegate); |
258 } | 268 } |
259 } | 269 } |
260 #endif | 270 #endif |
261 } | 271 } |
OLD | NEW |