| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/translate/translate_bubble_controller.h" | 5 #import "chrome/browser/ui/cocoa/translate/translate_bubble_controller.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/mac/foundation_util.h" | 9 #include "base/mac/foundation_util.h" |
| 10 #include "base/mac/scoped_nsobject.h" | 10 #include "base/mac/scoped_nsobject.h" |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 NSWindow* parentWindow = [controller window]; | 143 NSWindow* parentWindow = [controller window]; |
| 144 | 144 |
| 145 // Use an arbitrary size; it will be changed in performLayout. | 145 // Use an arbitrary size; it will be changed in performLayout. |
| 146 NSRect contentRect = ui::kWindowSizeDeterminedLater; | 146 NSRect contentRect = ui::kWindowSizeDeterminedLater; |
| 147 base::scoped_nsobject<InfoBubbleWindow> window( | 147 base::scoped_nsobject<InfoBubbleWindow> window( |
| 148 [[InfoBubbleWindow alloc] initWithContentRect:contentRect | 148 [[InfoBubbleWindow alloc] initWithContentRect:contentRect |
| 149 styleMask:NSBorderlessWindowMask | 149 styleMask:NSBorderlessWindowMask |
| 150 backing:NSBackingStoreBuffered | 150 backing:NSBackingStoreBuffered |
| 151 defer:NO]); | 151 defer:NO]); |
| 152 | 152 |
| 153 // Disable animations - otherwise, the window/controller will outlive the web | |
| 154 // contents it's associated with. | |
| 155 [window setAllowedAnimations:info_bubble::kAnimateNone]; | |
| 156 | |
| 157 if ((self = [super initWithWindow:window | 153 if ((self = [super initWithWindow:window |
| 158 parentWindow:parentWindow | 154 parentWindow:parentWindow |
| 159 anchoredAt:NSZeroPoint])) { | 155 anchoredAt:NSZeroPoint])) { |
| 160 webContents_ = webContents; | 156 webContents_ = webContents; |
| 161 model_ = std::move(model); | 157 model_ = std::move(model); |
| 162 | 158 |
| 163 shouldAlwaysTranslate_ = model_->ShouldAlwaysTranslate(); | 159 shouldAlwaysTranslate_ = model_->ShouldAlwaysTranslate(); |
| 164 if (!webContents_->GetBrowserContext()->IsOffTheRecord()) { | 160 if (!webContents_->GetBrowserContext()->IsOffTheRecord()) { |
| 165 shouldAlwaysTranslate_ = | 161 shouldAlwaysTranslate_ = |
| 166 model_->ShouldAlwaysTranslateBeCheckedByDefault(); | 162 model_->ShouldAlwaysTranslateBeCheckedByDefault(); |
| (...skipping 712 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 879 // source or target language on the before translate view. | 875 // source or target language on the before translate view. |
| 880 - (BOOL)textView:(NSTextView*)aTextView | 876 - (BOOL)textView:(NSTextView*)aTextView |
| 881 clickedOnLink:(id)link | 877 clickedOnLink:(id)link |
| 882 atIndex:(NSUInteger)charIndex { | 878 atIndex:(NSUInteger)charIndex { |
| 883 translate::ReportUiAction(translate::ADVANCED_LINK_CLICKED); | 879 translate::ReportUiAction(translate::ADVANCED_LINK_CLICKED); |
| 884 [self switchView:TranslateBubbleModel::VIEW_STATE_ADVANCED]; | 880 [self switchView:TranslateBubbleModel::VIEW_STATE_ADVANCED]; |
| 885 return YES; | 881 return YES; |
| 886 } | 882 } |
| 887 | 883 |
| 888 @end | 884 @end |
| OLD | NEW |