Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #import "chrome/browser/ui/cocoa/translate/translate_bubble_controller.h" | |
| 6 | |
| 7 #include "base/mac/scoped_nsobject.h" | |
| 8 #include "chrome/browser/translate/translate_ui_delegate.h" | |
| 9 #import "chrome/browser/ui/cocoa/browser_window_controller.h" | |
| 10 #import "chrome/browser/ui/cocoa/info_bubble_view.h" | |
| 11 #import "chrome/browser/ui/cocoa/info_bubble_window.h" | |
| 12 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" | |
| 13 #include "chrome/browser/ui/translate/translate_bubble_model_impl.h" | |
| 14 #import "ui/base/cocoa/flipped_view.h" | |
| 15 #import "ui/base/cocoa/window_size_constants.h" | |
| 16 | |
| 17 @implementation TranslateBubbleController | |
| 18 | |
| 19 - (const content::WebContents*)webContents { | |
|
groby-ooo-7-16
2014/02/27 19:19:02
Since this property only needs a getter that retur
Robert Sesek
2014/02/27 20:45:01
Getters come after -init
hajimehoshi
2014/02/28 04:25:22
Done.
hajimehoshi
2014/02/28 04:25:22
Done.
| |
| 20 return webContents_; | |
| 21 } | |
| 22 | |
| 23 - (const TranslateBubbleModel*)model { | |
| 24 return model_.get(); | |
| 25 } | |
| 26 | |
| 27 - (id)initWithParentWindow:(BrowserWindowController*)controller | |
| 28 model:(scoped_ptr<TranslateBubbleModel>)model | |
| 29 webContents:(content::WebContents*)webContents { | |
| 30 NSWindow* parentWindow = [controller window]; | |
| 31 | |
| 32 // Use an arbitrary size; it will be changed in performLayout. | |
| 33 NSRect contentRect = ui::kWindowSizeDeterminedLater; | |
| 34 base::scoped_nsobject<InfoBubbleWindow> window( | |
| 35 [[InfoBubbleWindow alloc] initWithContentRect:contentRect | |
| 36 styleMask:NSBorderlessWindowMask | |
| 37 backing:NSBackingStoreBuffered | |
| 38 defer:NO]); | |
| 39 | |
| 40 if ((self = [super initWithWindow:window | |
| 41 parentWindow:parentWindow | |
| 42 anchoredAt:NSZeroPoint])) { | |
| 43 webContents_ = webContents; | |
| 44 model_ = model.Pass(); | |
| 45 if (model_->GetViewState() != | |
| 46 TranslateBubbleModel::VIEW_STATE_BEFORE_TRANSLATE) { | |
| 47 translateExecuted_ = YES; | |
| 48 } | |
| 49 | |
| 50 [self performLayout]; | |
| 51 } | |
| 52 return self; | |
| 53 } | |
| 54 | |
| 55 - (void)showWindow:(id)sender { | |
| 56 BrowserWindowController* controller = [[self parentWindow] windowController]; | |
| 57 NSPoint anchorPoint = [[controller toolbarController] translateBubblePoint]; | |
| 58 anchorPoint = [[self parentWindow] convertBaseToScreen:anchorPoint]; | |
| 59 [self setAnchorPoint:anchorPoint]; | |
| 60 [super showWindow:sender]; | |
| 61 } | |
| 62 | |
| 63 - (void)switchView:(TranslateBubbleModel::ViewState)viewState { | |
| 64 if (model_->GetViewState() == viewState) | |
| 65 return; | |
| 66 | |
| 67 model_->SetViewState(viewState); | |
| 68 [self performLayout]; | |
| 69 } | |
| 70 | |
| 71 - (void)switchToErrorView:(TranslateErrors::Type)errorType { | |
| 72 // fixme(hajimehoshi): Implement this. | |
|
Robert Sesek
2014/02/27 20:45:01
TODO
hajimehoshi
2014/02/28 04:25:22
Done.
| |
| 73 } | |
| 74 | |
| 75 - (void)performLayout { | |
| 76 // fixme(hajimehoshi): Now this shows just an empty bubble. Implement this. | |
|
Robert Sesek
2014/02/27 20:45:01
TODO
hajimehoshi
2014/02/28 04:25:22
Done.
| |
| 77 [[self window] display]; | |
| 78 } | |
| 79 | |
| 80 @end | |
| OLD | NEW |