| 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/extensions/extension_popup_controller.h" | 5 #import "chrome/browser/ui/cocoa/extensions/extension_popup_controller.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 if ((self = [super initWithWindow:window | 167 if ((self = [super initWithWindow:window |
| 168 parentWindow:parentWindow | 168 parentWindow:parentWindow |
| 169 anchoredAt:anchoredAt])) { | 169 anchoredAt:anchoredAt])) { |
| 170 host_.reset(host); | 170 host_.reset(host); |
| 171 beingInspected_ = devMode; | 171 beingInspected_ = devMode; |
| 172 ignoreWindowDidResignKey_ = NO; | 172 ignoreWindowDidResignKey_ = NO; |
| 173 | 173 |
| 174 InfoBubbleView* view = self.bubble; | 174 InfoBubbleView* view = self.bubble; |
| 175 [view setArrowLocation:arrowLocation]; | 175 [view setArrowLocation:arrowLocation]; |
| 176 | 176 |
| 177 // alternative1: call [view setAnchorPoint:anchoredAt] here, drop the |
| 178 // onWindowChanged diff chunk. (or some kind of positionWindow call). |
| 179 |
| 180 // alternative2: hook into that setArrowLocation above in the bubble |
| 181 // controller (also: alignment), and keep the window position consistent. |
| 182 |
| 177 extensionView_ = host->view()->GetNativeView(); | 183 extensionView_ = host->view()->GetNativeView(); |
| 178 container_.reset(new ExtensionPopupContainer(self)); | 184 container_.reset(new ExtensionPopupContainer(self)); |
| 179 static_cast<ExtensionViewMac*>(host->view()) | 185 static_cast<ExtensionViewMac*>(host->view()) |
| 180 ->set_container(container_.get()); | 186 ->set_container(container_.get()); |
| 181 | 187 |
| 182 NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; | 188 NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; |
| 183 [center addObserver:self | 189 [center addObserver:self |
| 184 selector:@selector(extensionViewFrameChanged) | 190 selector:@selector(extensionViewFrameChanged) |
| 185 name:NSViewFrameDidChangeNotification | 191 name:NSViewFrameDidChangeNotification |
| 186 object:extensionView_]; | 192 object:extensionView_]; |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 | 402 |
| 397 [extensionView_ setFrame:frame]; | 403 [extensionView_ setFrame:frame]; |
| 398 [extensionView_ setNeedsDisplay:YES]; | 404 [extensionView_ setNeedsDisplay:YES]; |
| 399 } | 405 } |
| 400 | 406 |
| 401 - (void)onViewDidShow { | 407 - (void)onViewDidShow { |
| 402 [self onSizeChanged:pendingSize_]; | 408 [self onSizeChanged:pendingSize_]; |
| 403 } | 409 } |
| 404 | 410 |
| 405 - (void)onWindowChanged { | 411 - (void)onWindowChanged { |
| 412 // The window is positioned before creating the host, to ensure the host is |
| 413 // created with the correct screen information. |
| 414 if (!host_) |
| 415 return; |
| 416 |
| 406 ExtensionViewMac* extensionView = | 417 ExtensionViewMac* extensionView = |
| 407 static_cast<ExtensionViewMac*>(host_->view()); | 418 static_cast<ExtensionViewMac*>(host_->view()); |
| 408 // Let the extension view know, so that it can tell plugins. | 419 // Let the extension view know, so that it can tell plugins. |
| 409 if (extensionView) | 420 if (extensionView) |
| 410 extensionView->WindowFrameChanged(); | 421 extensionView->WindowFrameChanged(); |
| 411 } | 422 } |
| 412 | 423 |
| 413 - (void)windowDidResize:(NSNotification*)notification { | 424 - (void)windowDidResize:(NSNotification*)notification { |
| 414 [self onWindowChanged]; | 425 [self onWindowChanged]; |
| 415 } | 426 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 429 return minSize; | 440 return minSize; |
| 430 } | 441 } |
| 431 | 442 |
| 432 // Private (TestingAPI) | 443 // Private (TestingAPI) |
| 433 + (NSSize)maxPopupSize { | 444 + (NSSize)maxPopupSize { |
| 434 NSSize maxSize = {ExtensionViewMac::kMaxWidth, ExtensionViewMac::kMaxHeight}; | 445 NSSize maxSize = {ExtensionViewMac::kMaxWidth, ExtensionViewMac::kMaxHeight}; |
| 435 return maxSize; | 446 return maxSize; |
| 436 } | 447 } |
| 437 | 448 |
| 438 @end | 449 @end |
| OLD | NEW |