| 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/global_error_bubble_controller.h" | 5 #import "chrome/browser/ui/cocoa/global_error_bubble_controller.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/mac/scoped_nsobject.h" | 8 #include "base/mac/scoped_nsobject.h" |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "base/strings/sys_string_conversions.h" | 10 #include "base/strings/sys_string_conversions.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 | 45 |
| 46 } // namespace GlobalErrorBubbleControllerInternal | 46 } // namespace GlobalErrorBubbleControllerInternal |
| 47 | 47 |
| 48 @implementation GlobalErrorBubbleController | 48 @implementation GlobalErrorBubbleController |
| 49 | 49 |
| 50 + (GlobalErrorBubbleViewBase*)showForBrowser:(Browser*)browser | 50 + (GlobalErrorBubbleViewBase*)showForBrowser:(Browser*)browser |
| 51 error:(const base::WeakPtr<GlobalErrorWithStandardBubble>&)error { | 51 error:(const base::WeakPtr<GlobalErrorWithStandardBubble>&)error { |
| 52 NSWindow* parentWindow = browser->window()->GetNativeWindow(); | 52 NSWindow* parentWindow = browser->window()->GetNativeWindow(); |
| 53 BrowserWindowController* bwc = [BrowserWindowController | 53 BrowserWindowController* bwc = [BrowserWindowController |
| 54 browserWindowControllerForWindow:parentWindow]; | 54 browserWindowControllerForWindow:parentWindow]; |
| 55 NSView* wrenchButton = [[bwc toolbarController] wrenchButton]; | 55 NSView* appMenuButton = [[bwc toolbarController] appMenuButton]; |
| 56 NSPoint offset = NSMakePoint( | 56 NSPoint offset = NSMakePoint( |
| 57 NSMidX([wrenchButton bounds]), | 57 NSMidX([appMenuButton bounds]), |
| 58 app_menu_controller::kAppMenuBubblePointOffsetY); | 58 app_menu_controller::kAppMenuBubblePointOffsetY); |
| 59 | 59 |
| 60 // The bubble will be automatically deleted when the window is closed. | 60 // The bubble will be automatically deleted when the window is closed. |
| 61 GlobalErrorBubbleController* bubble = [[GlobalErrorBubbleController alloc] | 61 GlobalErrorBubbleController* bubble = [[GlobalErrorBubbleController alloc] |
| 62 initWithWindowNibPath:@"GlobalErrorBubble" | 62 initWithWindowNibPath:@"GlobalErrorBubble" |
| 63 relativeToView:wrenchButton | 63 relativeToView:appMenuButton |
| 64 offset:offset]; | 64 offset:offset]; |
| 65 bubble->error_ = error; | 65 bubble->error_ = error; |
| 66 bubble->bridge_.reset(new GlobalErrorBubbleControllerInternal::Bridge( | 66 bubble->bridge_.reset(new GlobalErrorBubbleControllerInternal::Bridge( |
| 67 bubble)); | 67 bubble)); |
| 68 bubble->browser_ = browser; | 68 bubble->browser_ = browser; |
| 69 [bubble showWindow:nil]; | 69 [bubble showWindow:nil]; |
| 70 | 70 |
| 71 return bubble->bridge_.get(); | 71 return bubble->bridge_.get(); |
| 72 } | 72 } |
| 73 | 73 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 [self close]; | 153 [self close]; |
| 154 } | 154 } |
| 155 | 155 |
| 156 @end | 156 @end |
| 157 | 157 |
| 158 GlobalErrorBubbleViewBase* GlobalErrorBubbleViewBase::ShowStandardBubbleView( | 158 GlobalErrorBubbleViewBase* GlobalErrorBubbleViewBase::ShowStandardBubbleView( |
| 159 Browser* browser, | 159 Browser* browser, |
| 160 const base::WeakPtr<GlobalErrorWithStandardBubble>& error) { | 160 const base::WeakPtr<GlobalErrorWithStandardBubble>& error) { |
| 161 return [GlobalErrorBubbleController showForBrowser:browser error:error]; | 161 return [GlobalErrorBubbleController showForBrowser:browser error:error]; |
| 162 } | 162 } |
| OLD | NEW |