| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/automation/automation_provider.h" | 5 #include "chrome/browser/automation/automation_provider.h" |
| 6 | 6 |
| 7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
| 8 | 8 |
| 9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
| 10 #include "app/l10n_util_mac.h" | 10 #include "app/l10n_util_mac.h" |
| 11 #include "base/gfx/point.h" | 11 #include "base/gfx/point.h" |
| 12 #include "base/gfx/rect.h" | 12 #include "base/gfx/rect.h" |
| 13 #include "base/sys_string_conversions.h" | 13 #include "base/sys_string_conversions.h" |
| 14 #include "chrome/browser/cocoa/tab_window_controller.h" | 14 #include "chrome/browser/cocoa/tab_window_controller.h" |
| 15 #include "chrome/test/automation/automation_messages.h" | 15 #include "chrome/test/automation/automation_messages.h" |
| 16 #include "grit/generated_resources.h" | 16 #include "grit/generated_resources.h" |
| 17 | 17 |
| 18 void AutomationProvider::SetWindowBounds(int handle, const gfx::Rect& bounds, | 18 void AutomationProvider::SetWindowBounds(int handle, const gfx::Rect& bounds, |
| 19 bool* success) { | 19 bool* success) { |
| 20 *success = false; | 20 *success = false; |
| 21 NSWindow* window = window_tracker_->GetResource(handle); | 21 NSWindow* window = window_tracker_->GetResource(handle); |
| 22 if (window) { | 22 if (window) { |
| 23 NSRect new_bounds = NSRectFromCGRect(bounds.ToCGRect()); | 23 NSRect new_bounds = NSRectFromCGRect(bounds.ToCGRect()); |
| 24 | 24 |
| 25 // This is likely incorrect for a multiple-monitor setup; OK because this | 25 if ([[NSScreen screens] count] > 0) { |
| 26 // is used only for testing purposes. | 26 new_bounds.origin.y = |
| 27 new_bounds.origin.y = [[window screen] frame].size.height - | 27 [[[NSScreen screens] objectAtIndex:0] frame].size.height - |
| 28 new_bounds.origin.y - new_bounds.size.height; | 28 new_bounds.origin.y - new_bounds.size.height; |
| 29 } |
| 29 | 30 |
| 30 [window setFrame:new_bounds display:NO]; | 31 [window setFrame:new_bounds display:NO]; |
| 31 *success = true; | 32 *success = true; |
| 32 } | 33 } |
| 33 } | 34 } |
| 34 | 35 |
| 35 void AutomationProvider::SetWindowVisible(int handle, bool visible, | 36 void AutomationProvider::SetWindowVisible(int handle, bool visible, |
| 36 bool* result) { | 37 bool* result) { |
| 37 *result = false; | 38 *result = false; |
| 38 NSWindow* window = window_tracker_->GetResource(handle); | 39 NSWindow* window = window_tracker_->GetResource(handle); |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 // If we don't yet have a title, use "Untitled". | 152 // If we don't yet have a title, use "Untitled". |
| 152 if (![title length]) { | 153 if (![title length]) { |
| 153 text->assign(WideToUTF16(l10n_util::GetString( | 154 text->assign(WideToUTF16(l10n_util::GetString( |
| 154 IDS_BROWSER_WINDOW_MAC_TAB_UNTITLED))); | 155 IDS_BROWSER_WINDOW_MAC_TAB_UNTITLED))); |
| 155 return; | 156 return; |
| 156 } | 157 } |
| 157 | 158 |
| 158 text->assign(base::SysNSStringToUTF16(title)); | 159 text->assign(base::SysNSStringToUTF16(title)); |
| 159 } | 160 } |
| 160 | 161 |
| OLD | NEW |