Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(141)

Side by Side Diff: chrome/browser/ui/views/infobars/after_translate_infobar.cc

Issue 7006010: Change InfoBar-related notifications to be sourced from a TabContentsWrapper, not a TabContents. ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 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 #include "chrome/browser/ui/views/infobars/after_translate_infobar.h" 5 #include "chrome/browser/ui/views/infobars/after_translate_infobar.h"
6 6
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "chrome/browser/translate/translate_infobar_delegate.h" 8 #include "chrome/browser/translate/translate_infobar_delegate.h"
9 #include "grit/generated_resources.h" 9 #include "grit/generated_resources.h"
10 #include "ui/base/l10n/l10n_util.h" 10 #include "ui/base/l10n/l10n_util.h"
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 original_language_menu_button_->GetPreferredSize().width() + 141 original_language_menu_button_->GetPreferredSize().width() +
142 kButtonInLabelSpacing) + 142 kButtonInLabelSpacing) +
143 (kButtonInLabelSpacing + 143 (kButtonInLabelSpacing +
144 target_language_menu_button_->GetPreferredSize().width() + 144 target_language_menu_button_->GetPreferredSize().width() +
145 kButtonInLabelSpacing) + 145 kButtonInLabelSpacing) +
146 (kButtonInLabelSpacing + revert_button_->GetPreferredSize().width()) + 146 (kButtonInLabelSpacing + revert_button_->GetPreferredSize().width()) +
147 (kEndOfLabelSpacing + options_menu_button_->GetPreferredSize().width()); 147 (kEndOfLabelSpacing + options_menu_button_->GetPreferredSize().width());
148 } 148 }
149 149
150 void AfterTranslateInfoBar::OriginalLanguageChanged() { 150 void AfterTranslateInfoBar::OriginalLanguageChanged() {
151 UpdateLanguageButtonText(original_language_menu_button_, 151 // Tests can call this function when the infobar has never been added to a
152 LanguagesMenuModel::ORIGINAL); 152 // view hierarchy and thus there is no button.
153 if (original_language_menu_button_) {
154 UpdateLanguageButtonText(original_language_menu_button_,
155 LanguagesMenuModel::ORIGINAL);
156 }
153 } 157 }
154 158
155 void AfterTranslateInfoBar::TargetLanguageChanged() { 159 void AfterTranslateInfoBar::TargetLanguageChanged() {
156 UpdateLanguageButtonText(target_language_menu_button_, 160 // Tests can call this function when the infobar has never been added to a
157 LanguagesMenuModel::TARGET); 161 // view hierarchy and thus there is no button.
162 if (target_language_menu_button_) {
163 UpdateLanguageButtonText(target_language_menu_button_,
164 LanguagesMenuModel::TARGET);
165 }
158 } 166 }
159 167
160 void AfterTranslateInfoBar::RunMenu(View* source, const gfx::Point& pt) { 168 void AfterTranslateInfoBar::RunMenu(View* source, const gfx::Point& pt) {
161 if (source == original_language_menu_button_) { 169 if (source == original_language_menu_button_) {
162 original_language_menu_->RunMenuAt(pt, views::Menu2::ALIGN_TOPRIGHT); 170 original_language_menu_->RunMenuAt(pt, views::Menu2::ALIGN_TOPRIGHT);
163 } else if (source == target_language_menu_button_) { 171 } else if (source == target_language_menu_button_) {
164 target_language_menu_->RunMenuAt(pt, views::Menu2::ALIGN_TOPRIGHT); 172 target_language_menu_->RunMenuAt(pt, views::Menu2::ALIGN_TOPRIGHT);
165 } else { 173 } else {
166 DCHECK_EQ(options_menu_button_, source); 174 DCHECK_EQ(options_menu_button_, source);
167 options_menu_->RunMenuAt(pt, views::Menu2::ALIGN_TOPRIGHT); 175 options_menu_->RunMenuAt(pt, views::Menu2::ALIGN_TOPRIGHT);
168 } 176 }
169 } 177 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/tab_contents/tab_contents_wrapper.cc ('k') | chrome/browser/ui/views/infobars/before_translate_infobar.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698