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 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 NSSize minSize = | 163 NSSize minSize = |
164 [viewController minimumSizeForInnerWidth:NSWidth(innerFrame)]; | 164 [viewController minimumSizeForInnerWidth:NSWidth(innerFrame)]; |
165 innerFrame.size.width = std::max(minSize.width, NSWidth(innerFrame)); | 165 innerFrame.size.width = std::max(minSize.width, NSWidth(innerFrame)); |
166 innerFrame.size.width = std::min( | 166 innerFrame.size.width = std::min( |
167 static_cast<CGFloat>(WebIntentPicker::kWindowMaxWidth), | 167 static_cast<CGFloat>(WebIntentPicker::kWindowMaxWidth), |
168 NSWidth(innerFrame)); | 168 NSWidth(innerFrame)); |
169 innerFrame.size.height = std::max(minSize.height, NSHeight(innerFrame)); | 169 innerFrame.size.height = std::max(minSize.height, NSHeight(innerFrame)); |
170 | 170 |
171 NSRect bounds = NSInsetRect(innerFrame, | 171 NSRect bounds = NSInsetRect(innerFrame, |
172 -ConstrainedWindow::kHorizontalPadding, | 172 -ConstrainedWindow::kHorizontalPadding, |
173 -ConstrainedWindow::kVerticalPadding); | 173 0); |
| 174 bounds.origin.y -= ConstrainedWindow::kClientTopPadding; |
| 175 bounds.size.height = NSHeight(innerFrame) + |
| 176 ConstrainedWindow::kClientTopPadding + |
| 177 ConstrainedWindow::kClientBottomPadding; |
174 | 178 |
175 [[viewController view] setFrame:bounds]; | 179 [[viewController view] setFrame:bounds]; |
176 [viewController layoutSubviewsWithinFrame:innerFrame]; | 180 [viewController layoutSubviewsWithinFrame:innerFrame]; |
177 | 181 |
178 NSRect closeFrame; | 182 NSRect closeFrame; |
179 closeFrame.size.width = ConstrainedWindow::GetCloseButtonSize(); | 183 closeFrame.size.width = ConstrainedWindow::GetCloseButtonSize(); |
180 closeFrame.size.height = ConstrainedWindow::GetCloseButtonSize(); | 184 closeFrame.size.height = ConstrainedWindow::GetCloseButtonSize(); |
181 closeFrame.origin.x = NSMaxX(innerFrame) - NSWidth(closeFrame); | 185 closeFrame.origin.x = NSMaxX(innerFrame) - NSWidth(closeFrame); |
182 closeFrame.origin.y = NSMinY(innerFrame); | 186 closeFrame.origin.y = NSMinY(innerFrame); |
183 [closeButton_ setFrame:closeFrame]; | 187 [closeButton_ setFrame:closeFrame]; |
184 | 188 |
185 [[self view] setFrame:bounds]; | 189 [[self view] setFrame:bounds]; |
186 } | 190 } |
187 | 191 |
188 - (NSRect)minimumInnerFrame { | 192 - (NSRect)minimumInnerFrame { |
189 NSRect bounds = NSMakeRect(0, 0, WebIntentPicker::kWindowMinWidth, | 193 NSRect bounds = NSMakeRect(0, 0, WebIntentPicker::kWindowMinWidth, |
190 WebIntentPicker::kWindowMinHeight); | 194 WebIntentPicker::kWindowMinHeight); |
191 return NSInsetRect(bounds, | 195 bounds = NSInsetRect(bounds, |
192 ConstrainedWindow::kHorizontalPadding, | 196 ConstrainedWindow::kHorizontalPadding, |
193 ConstrainedWindow::kVerticalPadding); | 197 0); |
| 198 bounds.origin.y += ConstrainedWindow::kClientTopPadding; |
| 199 bounds.size.height = bounds.size.height - |
| 200 ConstrainedWindow::kClientTopPadding - |
| 201 ConstrainedWindow::kClientBottomPadding; |
| 202 return bounds; |
194 } | 203 } |
195 | 204 |
196 - (NSViewController<WebIntentViewController>*)currentViewController { | 205 - (NSViewController<WebIntentViewController>*)currentViewController { |
197 switch (state_) { | 206 switch (state_) { |
198 case PICKER_STATE_WAITING: | 207 case PICKER_STATE_WAITING: |
199 return progressViewController_; | 208 return progressViewController_; |
200 case PICKER_STATE_NO_SERVICE: | 209 case PICKER_STATE_NO_SERVICE: |
201 return messageViewController_; | 210 return messageViewController_; |
202 case PICKER_STATE_CHOOSE_SERVICE: | 211 case PICKER_STATE_CHOOSE_SERVICE: |
203 return chooseServiceViewController_; | 212 return chooseServiceViewController_; |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 WindowOpenDisposition disposition = | 372 WindowOpenDisposition disposition = |
364 event_utils::WindowOpenDispositionFromNSEvent([NSApp currentEvent]); | 373 event_utils::WindowOpenDispositionFromNSEvent([NSApp currentEvent]); |
365 picker_->delegate()->OnSuggestionsLinkClicked(disposition); | 374 picker_->delegate()->OnSuggestionsLinkClicked(disposition); |
366 } | 375 } |
367 | 376 |
368 - (void)onChooseAnotherService:(id)sender { | 377 - (void)onChooseAnotherService:(id)sender { |
369 picker_->delegate()->OnChooseAnotherService(); | 378 picker_->delegate()->OnChooseAnotherService(); |
370 } | 379 } |
371 | 380 |
372 @end | 381 @end |
OLD | NEW |