| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
| 6 | 6 |
| 7 #import "base/scoped_nsobject.h" | 7 #import "base/scoped_nsobject.h" |
| 8 #import "base/string_util.h" | 8 #import "base/string_util.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #import "chrome/app/chrome_command_ids.h" // For translate menu command ids. | 10 #import "chrome/app/chrome_command_ids.h" // For translate menu command ids. |
| 11 #import "chrome/browser/renderer_host/site_instance.h" | 11 #import "chrome/browser/renderer_host/site_instance.h" |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 CreateInfoBar(TranslateInfoBarDelegate::BEFORE_TRANSLATE); | 90 CreateInfoBar(TranslateInfoBarDelegate::BEFORE_TRANSLATE); |
| 91 } | 91 } |
| 92 | 92 |
| 93 void CreateInfoBar(TranslateInfoBarDelegate::Type type) { | 93 void CreateInfoBar(TranslateInfoBarDelegate::Type type) { |
| 94 TranslateErrors::Type error = TranslateErrors::NONE; | 94 TranslateErrors::Type error = TranslateErrors::NONE; |
| 95 if (type == TranslateInfoBarDelegate::TRANSLATION_ERROR) | 95 if (type == TranslateInfoBarDelegate::TRANSLATION_ERROR) |
| 96 error = TranslateErrors::NETWORK; | 96 error = TranslateErrors::NETWORK; |
| 97 infobar_delegate.reset( | 97 infobar_delegate.reset( |
| 98 new MockTranslateInfoBarDelegate(type, error, tab_contents.get())); | 98 new MockTranslateInfoBarDelegate(type, error, tab_contents.get())); |
| 99 [[infobar_controller view] removeFromSuperview]; | 99 [[infobar_controller view] removeFromSuperview]; |
| 100 scoped_ptr<InfoBar> infobar(infobar_delegate->CreateInfoBar()); | 100 scoped_ptr<InfoBar> infobar( |
| 101 static_cast<InfoBarDelegate*>(infobar_delegate.get())->CreateInfoBar()); |
| 101 infobar_controller.reset( | 102 infobar_controller.reset( |
| 102 reinterpret_cast<TranslateInfoBarControllerBase*>( | 103 reinterpret_cast<TranslateInfoBarControllerBase*>( |
| 103 infobar->controller())); | 104 infobar->controller())); |
| 104 // We need to set the window to be wide so that the options button | 105 // We need to set the window to be wide so that the options button |
| 105 // doesn't overlap the other buttons. | 106 // doesn't overlap the other buttons. |
| 106 [test_window() setContentSize:NSMakeSize(2000, 500)]; | 107 [test_window() setContentSize:NSMakeSize(2000, 500)]; |
| 107 [[infobar_controller view] setFrame:NSMakeRect(0, 0, 2000, 500)]; | 108 [[infobar_controller view] setFrame:NSMakeRect(0, 0, 2000, 500)]; |
| 108 [[test_window() contentView] addSubview:[infobar_controller view]]; | 109 [[test_window() contentView] addSubview:[infobar_controller view]]; |
| 109 } | 110 } |
| 110 }; | 111 }; |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 translate_prefs.IncrementTranslationDeniedCount("en"); | 246 translate_prefs.IncrementTranslationDeniedCount("en"); |
| 246 } | 247 } |
| 247 CreateInfoBar(TranslateInfoBarDelegate::BEFORE_TRANSLATE); | 248 CreateInfoBar(TranslateInfoBarDelegate::BEFORE_TRANSLATE); |
| 248 BeforeTranslateInfobarController* controller = | 249 BeforeTranslateInfobarController* controller = |
| 249 (BeforeTranslateInfobarController*)infobar_controller.get(); | 250 (BeforeTranslateInfobarController*)infobar_controller.get(); |
| 250 EXPECT_TRUE([[controller alwaysTranslateButton] superview] == nil); | 251 EXPECT_TRUE([[controller alwaysTranslateButton] superview] == nil); |
| 251 EXPECT_TRUE([[controller neverTranslateButton] superview] != nil); | 252 EXPECT_TRUE([[controller neverTranslateButton] superview] != nil); |
| 252 } | 253 } |
| 253 | 254 |
| 254 } // namespace | 255 } // namespace |
| OLD | NEW |