| 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/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| 11 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
| 12 #include "chrome/browser/event_disposition.h" | 12 #include "chrome/browser/event_disposition.h" |
| 13 #include "chrome/browser/prefs/pref_service.h" | 13 #include "chrome/browser/prefs/pref_service.h" |
| 14 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 14 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
| 15 #include "chrome/browser/profiles/profile_manager.h" | 15 #include "chrome/browser/profiles/profile_manager.h" |
| 16 #include "chrome/browser/ui/host_desktop.h" |
| 16 #include "chrome/browser/ui/views/accessibility/accessibility_event_router_views
.h" | 17 #include "chrome/browser/ui/views/accessibility/accessibility_event_router_views
.h" |
| 17 #include "chrome/common/pref_names.h" | 18 #include "chrome/common/pref_names.h" |
| 18 #include "ui/gfx/rect.h" | 19 #include "ui/gfx/rect.h" |
| 19 #include "ui/gfx/screen.h" | 20 #include "ui/gfx/screen.h" |
| 20 #include "ui/views/views_switches.h" | 21 #include "ui/views/views_switches.h" |
| 21 #include "ui/views/widget/native_widget.h" | 22 #include "ui/views/widget/native_widget.h" |
| 22 #include "ui/views/widget/widget.h" | 23 #include "ui/views/widget/widget.h" |
| 23 | 24 |
| 24 #if defined(OS_WIN) | 25 #if defined(OS_WIN) |
| 25 #include "chrome/browser/app_icon_win.h" | 26 #include "chrome/browser/app_icon_win.h" |
| 26 #endif | 27 #endif |
| 27 | 28 |
| 28 #if defined(USE_AURA) && !defined(OS_CHROMEOS) | 29 #if defined(USE_AURA) && !defined(OS_CHROMEOS) |
| 29 #include "ui/views/widget/desktop_native_widget_aura.h" | 30 #include "ui/views/widget/desktop_native_widget_aura.h" |
| 30 #endif | 31 #endif |
| 31 | 32 |
| 32 #if defined(USE_AURA) | 33 #if defined(USE_AURA) |
| 34 #include "ui/aura/window.h" |
| 33 #include "ui/views/widget/desktop_native_widget_helper_aura.h" | 35 #include "ui/views/widget/desktop_native_widget_helper_aura.h" |
| 36 #include "ui/views/widget/native_widget_aura.h" |
| 34 #endif | 37 #endif |
| 35 | 38 |
| 36 #if defined(USE_ASH) | 39 #if defined(USE_ASH) |
| 37 #include "ash/shell.h" | 40 #include "ash/shell.h" |
| 38 #include "chrome/browser/ui/ash/ash_init.h" | 41 #include "chrome/browser/ui/ash/ash_init.h" |
| 39 #endif | 42 #endif |
| 40 | 43 |
| 41 namespace { | 44 namespace { |
| 42 | 45 |
| 43 // If the given window has a profile associated with it, use that profile's | 46 // If the given window has a profile associated with it, use that profile's |
| (...skipping 28 matching lines...) Expand all Loading... |
| 72 DCHECK(prefs->FindPreference(window_name.c_str())); | 75 DCHECK(prefs->FindPreference(window_name.c_str())); |
| 73 DictionaryPrefUpdate update(prefs, window_name.c_str()); | 76 DictionaryPrefUpdate update(prefs, window_name.c_str()); |
| 74 DictionaryValue* window_preferences = update.Get(); | 77 DictionaryValue* window_preferences = update.Get(); |
| 75 window_preferences->SetInteger("left", bounds.x()); | 78 window_preferences->SetInteger("left", bounds.x()); |
| 76 window_preferences->SetInteger("top", bounds.y()); | 79 window_preferences->SetInteger("top", bounds.y()); |
| 77 window_preferences->SetInteger("right", bounds.right()); | 80 window_preferences->SetInteger("right", bounds.right()); |
| 78 window_preferences->SetInteger("bottom", bounds.bottom()); | 81 window_preferences->SetInteger("bottom", bounds.bottom()); |
| 79 window_preferences->SetBoolean("maximized", | 82 window_preferences->SetBoolean("maximized", |
| 80 show_state == ui::SHOW_STATE_MAXIMIZED); | 83 show_state == ui::SHOW_STATE_MAXIMIZED); |
| 81 gfx::Rect work_area( | 84 gfx::Rect work_area( |
| 82 gfx::Screen::GetDisplayMatching(bounds).work_area()); | 85 gfx::Screen::GetDisplayMatching( |
| 86 gfx::Screen::BadTwoWorldsContext(), bounds).work_area()); |
| 83 window_preferences->SetInteger("work_area_left", work_area.x()); | 87 window_preferences->SetInteger("work_area_left", work_area.x()); |
| 84 window_preferences->SetInteger("work_area_top", work_area.y()); | 88 window_preferences->SetInteger("work_area_top", work_area.y()); |
| 85 window_preferences->SetInteger("work_area_right", work_area.right()); | 89 window_preferences->SetInteger("work_area_right", work_area.right()); |
| 86 window_preferences->SetInteger("work_area_bottom", work_area.bottom()); | 90 window_preferences->SetInteger("work_area_bottom", work_area.bottom()); |
| 87 } | 91 } |
| 88 | 92 |
| 89 bool ChromeViewsDelegate::GetSavedWindowPlacement( | 93 bool ChromeViewsDelegate::GetSavedWindowPlacement( |
| 90 const std::string& window_name, | 94 const std::string& window_name, |
| 91 gfx::Rect* bounds, | 95 gfx::Rect* bounds, |
| 92 ui::WindowShowState* show_state) const { | 96 ui::WindowShowState* show_state) const { |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 views::NonClientFrameView* ChromeViewsDelegate::CreateDefaultNonClientFrameView( | 141 views::NonClientFrameView* ChromeViewsDelegate::CreateDefaultNonClientFrameView( |
| 138 views::Widget* widget) { | 142 views::Widget* widget) { |
| 139 #if defined(USE_ASH) | 143 #if defined(USE_ASH) |
| 140 return ash::Shell::GetInstance()->CreateDefaultNonClientFrameView(widget); | 144 return ash::Shell::GetInstance()->CreateDefaultNonClientFrameView(widget); |
| 141 #else | 145 #else |
| 142 return NULL; | 146 return NULL; |
| 143 #endif | 147 #endif |
| 144 } | 148 } |
| 145 | 149 |
| 146 bool ChromeViewsDelegate::UseTransparentWindows() const { | 150 bool ChromeViewsDelegate::UseTransparentWindows() const { |
| 147 #if defined(USE_ASH) | 151 // TODO(scottmg): http://crbug.com/133312 |
| 148 // Ash uses transparent window frames above. | 152 NOTIMPLEMENTED(); |
| 149 return !CommandLine::ForCurrentProcess()->HasSwitch( | |
| 150 views::switches::kDesktopAura); | |
| 151 #else | |
| 152 return false; | 153 return false; |
| 153 #endif | |
| 154 } | 154 } |
| 155 | 155 |
| 156 void ChromeViewsDelegate::AddRef() { | 156 void ChromeViewsDelegate::AddRef() { |
| 157 g_browser_process->AddRefModule(); | 157 g_browser_process->AddRefModule(); |
| 158 } | 158 } |
| 159 | 159 |
| 160 void ChromeViewsDelegate::ReleaseRef() { | 160 void ChromeViewsDelegate::ReleaseRef() { |
| 161 g_browser_process->ReleaseModule(); | 161 g_browser_process->ReleaseModule(); |
| 162 } | 162 } |
| 163 | 163 |
| 164 int ChromeViewsDelegate::GetDispositionForEvent(int event_flags) { | 164 int ChromeViewsDelegate::GetDispositionForEvent(int event_flags) { |
| 165 return chrome::DispositionFromEventFlags(event_flags); | 165 return chrome::DispositionFromEventFlags(event_flags); |
| 166 } | 166 } |
| 167 | 167 |
| 168 #if defined(USE_AURA) | 168 #if defined(USE_AURA) |
| 169 views::NativeWidgetHelperAura* ChromeViewsDelegate::CreateNativeWidgetHelper( | 169 views::NativeWidgetHelperAura* ChromeViewsDelegate::CreateNativeWidgetHelper( |
| 170 views::NativeWidgetAura* native_widget) { | 170 views::NativeWidgetAura* native_widget, gfx::NativeView parent) { |
| 171 // TODO(beng): insufficient but currently necessary. http://crbug.com/133312 | 171 if (chrome::GetHostDesktopTypeForNativeView(parent) == |
| 172 #if !defined(OS_CHROMEOS) // We don't build this class for ChromeOS. | 172 chrome::HOST_DESKTOP_TYPE_NATIVE) |
| 173 #if defined(USE_ASH) | |
| 174 if (!chrome::ShouldOpenAshOnStartup()) | |
| 175 #endif | |
| 176 return new views::DesktopNativeWidgetHelperAura(native_widget); | 173 return new views::DesktopNativeWidgetHelperAura(native_widget); |
| 177 #endif | |
| 178 #if defined(USE_ASH) | |
| 179 return NULL; | 174 return NULL; |
| 180 #endif | |
| 181 } | 175 } |
| 182 #endif | 176 #endif |
| 183 | 177 |
| 184 content::WebContents* ChromeViewsDelegate::CreateWebContents( | 178 content::WebContents* ChromeViewsDelegate::CreateWebContents( |
| 185 content::BrowserContext* browser_context, | 179 content::BrowserContext* browser_context, |
| 186 content::SiteInstance* site_instance) { | 180 content::SiteInstance* site_instance) { |
| 187 return NULL; | 181 return NULL; |
| 188 } | 182 } |
| 189 | 183 |
| 190 views::NativeWidget* ChromeViewsDelegate::CreateNativeWidget( | 184 views::NativeWidget* ChromeViewsDelegate::CreateNativeWidget( |
| 191 views::internal::NativeWidgetDelegate* delegate, | 185 views::internal::NativeWidgetDelegate* delegate, |
| 192 gfx::NativeView parent) { | 186 gfx::NativeView parent) { |
| 193 #if defined(USE_AURA) && !defined(OS_CHROMEOS) | 187 #if defined(USE_AURA) |
| 194 if (CommandLine::ForCurrentProcess()->HasSwitch( | 188 if (chrome::GetHostDesktopTypeForNativeView(parent) == |
| 195 views::switches::kDesktopAura)) | 189 chrome::HOST_DESKTOP_TYPE_NATIVE) |
| 196 return new views::DesktopNativeWidgetAura(delegate); | 190 return new views::DesktopNativeWidgetAura(delegate); |
| 197 #endif | 191 #endif |
| 198 return NULL; | 192 return NULL; |
| 199 } | 193 } |
| OLD | NEW |