| 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/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
| 9 #include "base/prefs/scoped_user_pref_update.h" | 9 #include "base/prefs/scoped_user_pref_update.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 #endif | 32 #endif |
| 33 | 33 |
| 34 #if defined(USE_AURA) && !defined(OS_CHROMEOS) | 34 #if defined(USE_AURA) && !defined(OS_CHROMEOS) |
| 35 #include "chrome/browser/ui/host_desktop.h" | 35 #include "chrome/browser/ui/host_desktop.h" |
| 36 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" | 36 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" |
| 37 #include "ui/views/widget/native_widget_aura.h" | 37 #include "ui/views/widget/native_widget_aura.h" |
| 38 #endif | 38 #endif |
| 39 | 39 |
| 40 #if defined(USE_ASH) | 40 #if defined(USE_ASH) |
| 41 #include "ash/shell.h" | 41 #include "ash/shell.h" |
| 42 #include "ash/wm/window_state.h" |
| 42 #include "chrome/browser/ui/ash/ash_init.h" | 43 #include "chrome/browser/ui/ash/ash_init.h" |
| 43 #include "chrome/browser/ui/ash/ash_util.h" | 44 #include "chrome/browser/ui/ash/ash_util.h" |
| 44 #endif | 45 #endif |
| 45 | 46 |
| 46 namespace { | 47 namespace { |
| 47 | 48 |
| 48 // If the given window has a profile associated with it, use that profile's | 49 // If the given window has a profile associated with it, use that profile's |
| 49 // preference service. Otherwise, store and retrieve the data from Local State. | 50 // preference service. Otherwise, store and retrieve the data from Local State. |
| 50 // This function may return NULL if the necessary pref service has not yet | 51 // This function may return NULL if the necessary pref service has not yet |
| 51 // been initialized. | 52 // been initialized. |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 show_state == ui::SHOW_STATE_MAXIMIZED); | 86 show_state == ui::SHOW_STATE_MAXIMIZED); |
| 86 gfx::Rect work_area(gfx::Screen::GetScreenFor(window->GetNativeView())-> | 87 gfx::Rect work_area(gfx::Screen::GetScreenFor(window->GetNativeView())-> |
| 87 GetDisplayNearestWindow(window->GetNativeView()).work_area()); | 88 GetDisplayNearestWindow(window->GetNativeView()).work_area()); |
| 88 window_preferences->SetInteger("work_area_left", work_area.x()); | 89 window_preferences->SetInteger("work_area_left", work_area.x()); |
| 89 window_preferences->SetInteger("work_area_top", work_area.y()); | 90 window_preferences->SetInteger("work_area_top", work_area.y()); |
| 90 window_preferences->SetInteger("work_area_right", work_area.right()); | 91 window_preferences->SetInteger("work_area_right", work_area.right()); |
| 91 window_preferences->SetInteger("work_area_bottom", work_area.bottom()); | 92 window_preferences->SetInteger("work_area_bottom", work_area.bottom()); |
| 92 } | 93 } |
| 93 | 94 |
| 94 bool ChromeViewsDelegate::GetSavedWindowPlacement( | 95 bool ChromeViewsDelegate::GetSavedWindowPlacement( |
| 96 const views::Widget* widget, |
| 95 const std::string& window_name, | 97 const std::string& window_name, |
| 96 gfx::Rect* bounds, | 98 gfx::Rect* bounds, |
| 97 ui::WindowShowState* show_state) const { | 99 ui::WindowShowState* show_state) const { |
| 98 PrefService* prefs = g_browser_process->local_state(); | 100 PrefService* prefs = g_browser_process->local_state(); |
| 99 if (!prefs) | 101 if (!prefs) |
| 100 return false; | 102 return false; |
| 101 | 103 |
| 102 DCHECK(prefs->FindPreference(window_name.c_str())); | 104 DCHECK(prefs->FindPreference(window_name.c_str())); |
| 103 const DictionaryValue* dictionary = prefs->GetDictionary(window_name.c_str()); | 105 const DictionaryValue* dictionary = prefs->GetDictionary(window_name.c_str()); |
| 104 int left, top, right, bottom; | 106 int left, top, right, bottom; |
| 105 if (!dictionary || !dictionary->GetInteger("left", &left) || | 107 if (!dictionary || !dictionary->GetInteger("left", &left) || |
| 106 !dictionary->GetInteger("top", &top) || | 108 !dictionary->GetInteger("top", &top) || |
| 107 !dictionary->GetInteger("right", &right) || | 109 !dictionary->GetInteger("right", &right) || |
| 108 !dictionary->GetInteger("bottom", &bottom)) | 110 !dictionary->GetInteger("bottom", &bottom)) |
| 109 return false; | 111 return false; |
| 110 | 112 |
| 111 bounds->SetRect(left, top, right - left, bottom - top); | 113 bounds->SetRect(left, top, right - left, bottom - top); |
| 112 | 114 |
| 113 bool maximized = false; | 115 bool maximized = false; |
| 114 if (dictionary) | 116 if (dictionary) |
| 115 dictionary->GetBoolean("maximized", &maximized); | 117 dictionary->GetBoolean("maximized", &maximized); |
| 116 *show_state = maximized ? ui::SHOW_STATE_MAXIMIZED : ui::SHOW_STATE_NORMAL; | 118 *show_state = maximized ? ui::SHOW_STATE_MAXIMIZED : ui::SHOW_STATE_NORMAL; |
| 117 | 119 |
| 120 #if defined(USE_ASH) |
| 121 // On Ash environment, a window won't span across displays. Adjust |
| 122 // the bounds to fit the work area. |
| 123 gfx::NativeView window = widget->GetNativeView(); |
| 124 if (chrome::GetHostDesktopTypeForNativeView(window) == |
| 125 chrome::HOST_DESKTOP_TYPE_ASH) { |
| 126 gfx::Display display = gfx::Screen::GetScreenFor(window)-> |
| 127 GetDisplayMatching(*bounds); |
| 128 bounds->AdjustToFit(display.work_area()); |
| 129 ash::wm::GetWindowState(window)->set_minimum_visibility(true); |
| 130 } |
| 131 #endif |
| 118 return true; | 132 return true; |
| 119 } | 133 } |
| 120 | 134 |
| 121 void ChromeViewsDelegate::NotifyAccessibilityEvent( | 135 void ChromeViewsDelegate::NotifyAccessibilityEvent( |
| 122 views::View* view, ui::AccessibilityTypes::Event event_type) { | 136 views::View* view, ui::AccessibilityTypes::Event event_type) { |
| 123 AccessibilityEventRouterViews::GetInstance()->HandleAccessibilityEvent( | 137 AccessibilityEventRouterViews::GetInstance()->HandleAccessibilityEvent( |
| 124 view, event_type); | 138 view, event_type); |
| 125 } | 139 } |
| 126 | 140 |
| 127 void ChromeViewsDelegate::NotifyMenuItemFocused(const string16& menu_name, | 141 void ChromeViewsDelegate::NotifyMenuItemFocused(const string16& menu_name, |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 } | 282 } |
| 269 #endif | 283 #endif |
| 270 } | 284 } |
| 271 | 285 |
| 272 #if !defined(OS_CHROMEOS) | 286 #if !defined(OS_CHROMEOS) |
| 273 base::TimeDelta | 287 base::TimeDelta |
| 274 ChromeViewsDelegate::GetDefaultTextfieldObscuredRevealDuration() { | 288 ChromeViewsDelegate::GetDefaultTextfieldObscuredRevealDuration() { |
| 275 return base::TimeDelta(); | 289 return base::TimeDelta(); |
| 276 } | 290 } |
| 277 #endif | 291 #endif |
| OLD | NEW |