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 #import "chrome/browser/ui/cocoa/intents/web_intent_picker_view_controller.h" | 5 #import "chrome/browser/ui/cocoa/intents/web_intent_picker_view_controller.h" |
6 | 6 |
7 #include "base/sys_string_conversions.h" | 7 #include "base/sys_string_conversions.h" |
8 #import "chrome/browser/ui/cocoa/event_utils.h" | 8 #import "chrome/browser/ui/cocoa/event_utils.h" |
9 #import "chrome/browser/ui/cocoa/flipped_view.h" | 9 #import "chrome/browser/ui/cocoa/flipped_view.h" |
10 #import "chrome/browser/ui/cocoa/hover_close_button.h" | 10 #import "chrome/browser/ui/cocoa/hover_close_button.h" |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 NSSize minSize = | 139 NSSize minSize = |
140 [viewController minimumSizeForInnerWidth:NSWidth(innerFrame)]; | 140 [viewController minimumSizeForInnerWidth:NSWidth(innerFrame)]; |
141 innerFrame.size.width = std::max(minSize.width, NSWidth(innerFrame)); | 141 innerFrame.size.width = std::max(minSize.width, NSWidth(innerFrame)); |
142 innerFrame.size.width = std::min( | 142 innerFrame.size.width = std::min( |
143 static_cast<CGFloat>(WebIntentPicker::kWindowMaxWidth), | 143 static_cast<CGFloat>(WebIntentPicker::kWindowMaxWidth), |
144 NSWidth(innerFrame)); | 144 NSWidth(innerFrame)); |
145 innerFrame.size.height = std::max(minSize.height, NSHeight(innerFrame)); | 145 innerFrame.size.height = std::max(minSize.height, NSHeight(innerFrame)); |
146 | 146 |
147 NSRect bounds = NSInsetRect(innerFrame, | 147 NSRect bounds = NSInsetRect(innerFrame, |
148 -ConstrainedWindow::kHorizontalPadding, | 148 -ConstrainedWindow::kHorizontalPadding, |
149 -ConstrainedWindow::kVerticalPadding); | 149 0); |
| 150 bounds.origin.y -= ConstrainedWindow::kClientTopPadding; |
| 151 bounds.size.height = NSHeight(innerFrame) + |
| 152 ConstrainedWindow::kClientTopPadding + |
| 153 ConstrainedWindow::kClientBottomPadding; |
150 | 154 |
151 [[viewController view] setFrame:bounds]; | 155 [[viewController view] setFrame:bounds]; |
152 [viewController layoutSubviewsWithinFrame:innerFrame]; | 156 [viewController layoutSubviewsWithinFrame:innerFrame]; |
153 | 157 |
154 NSRect closeFrame; | 158 NSRect closeFrame; |
155 closeFrame.size.width = ConstrainedWindow::GetCloseButtonSize(); | 159 closeFrame.size.width = ConstrainedWindow::GetCloseButtonSize(); |
156 closeFrame.size.height = ConstrainedWindow::GetCloseButtonSize(); | 160 closeFrame.size.height = ConstrainedWindow::GetCloseButtonSize(); |
157 closeFrame.origin.x = NSMaxX(innerFrame) - NSWidth(closeFrame); | 161 closeFrame.origin.x = NSMaxX(innerFrame) - NSWidth(closeFrame); |
158 closeFrame.origin.y = NSMinY(innerFrame); | 162 closeFrame.origin.y = NSMinY(innerFrame); |
159 [closeButton_ setFrame:closeFrame]; | 163 [closeButton_ setFrame:closeFrame]; |
160 | 164 |
161 [[self view] setFrame:bounds]; | 165 [[self view] setFrame:bounds]; |
162 } | 166 } |
163 | 167 |
164 - (NSRect)minimumInnerFrame { | 168 - (NSRect)minimumInnerFrame { |
165 NSRect bounds = NSMakeRect(0, 0, WebIntentPicker::kWindowMinWidth, | 169 NSRect bounds = NSMakeRect(0, 0, WebIntentPicker::kWindowMinWidth, |
166 WebIntentPicker::kWindowMinHeight); | 170 WebIntentPicker::kWindowMinHeight); |
167 return NSInsetRect(bounds, | 171 bounds = NSInsetRect(bounds, |
168 ConstrainedWindow::kHorizontalPadding, | 172 ConstrainedWindow::kHorizontalPadding, |
169 ConstrainedWindow::kVerticalPadding); | 173 0); |
| 174 bounds.origin.y += ConstrainedWindow::kClientTopPadding; |
| 175 bounds.size.height = bounds.size.height - |
| 176 ConstrainedWindow::kClientTopPadding - |
| 177 ConstrainedWindow::kClientBottomPadding; |
| 178 return bounds; |
170 } | 179 } |
171 | 180 |
172 - (NSViewController<WebIntentViewController>*)currentViewController { | 181 - (NSViewController<WebIntentViewController>*)currentViewController { |
173 switch (state_) { | 182 switch (state_) { |
174 case PICKER_STATE_WAITING: | 183 case PICKER_STATE_WAITING: |
175 return progressViewController_; | 184 return progressViewController_; |
176 case PICKER_STATE_NO_SERVICE: | 185 case PICKER_STATE_NO_SERVICE: |
177 return messageViewController_; | 186 return messageViewController_; |
178 case PICKER_STATE_CHOOSE_SERVICE: | 187 case PICKER_STATE_CHOOSE_SERVICE: |
179 return chooseServiceViewController_; | 188 return chooseServiceViewController_; |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 picker_->delegate()->OnExtensionLinkClicked(service.id, disposition); | 324 picker_->delegate()->OnExtensionLinkClicked(service.id, disposition); |
316 } | 325 } |
317 | 326 |
318 - (void)onShowMoreServices:(id)sender { | 327 - (void)onShowMoreServices:(id)sender { |
319 WindowOpenDisposition disposition = | 328 WindowOpenDisposition disposition = |
320 event_utils::WindowOpenDispositionFromNSEvent([NSApp currentEvent]); | 329 event_utils::WindowOpenDispositionFromNSEvent([NSApp currentEvent]); |
321 picker_->delegate()->OnSuggestionsLinkClicked(disposition); | 330 picker_->delegate()->OnSuggestionsLinkClicked(disposition); |
322 } | 331 } |
323 | 332 |
324 @end | 333 @end |
OLD | NEW |