Commit bc884c96 authored by pkasting@chromium.org's avatar pkasting@chromium.org

Minor c/b/ui/views/infobars changes:

* Make the various translate OptionsMenuModels scoped_ptr<>s like the other menu
  models.  This is mostly for convenience for the refactor change, where
  accessing the delegate (to initialize this) in the constructor is kind of
  annoying.  Added bonus, we can pull a few #includes out of some .h files.
* Add a blank line between blocks of forward declarations... this seems to be
  how most other code does it and feels a little less cramped

BUG=none
TEST=none
TBR=sky

Review URL: https://codereview.chromium.org/84363002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@236932 0039d316-1c4b-4281-b951-d872f2087c98
parent cd904795
......@@ -5,7 +5,9 @@
#include "chrome/browser/ui/views/infobars/after_translate_infobar.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/translate/options_menu_model.h"
#include "chrome/browser/translate/translate_infobar_delegate.h"
#include "chrome/browser/ui/views/infobars/translate_language_menu_model.h"
#include "grit/generated_resources.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/views/controls/button/label_button.h"
......@@ -24,7 +26,6 @@ AfterTranslateInfoBar::AfterTranslateInfoBar(
target_language_menu_button_(NULL),
revert_button_(NULL),
options_menu_button_(NULL),
options_menu_model_(delegate),
swapped_language_buttons_(false) {
autodetermined_source_language_ =
delegate->original_language_index() == TranslateInfoBarDelegate::kNoIndex;
......@@ -126,6 +127,7 @@ void AfterTranslateInfoBar::ViewHierarchyChanged(
options_menu_button_ = CreateMenuButton(
l10n_util::GetStringUTF16(IDS_TRANSLATE_INFOBAR_OPTIONS), this);
options_menu_model_.reset(new OptionsMenuModel(delegate));
AddChildView(options_menu_button_);
// This must happen after adding all other children so InfoBarView can ensure
......@@ -177,7 +179,7 @@ void AfterTranslateInfoBar::OnMenuButtonClicked(views::View* source,
views::MenuItemView::TOPLEFT);
} else {
DCHECK_EQ(options_menu_button_, source);
RunMenuAt(&options_menu_model_, options_menu_button_,
RunMenuAt(options_menu_model_.get(), options_menu_button_,
views::MenuItemView::TOPRIGHT);
}
}
......@@ -5,12 +5,13 @@
#ifndef CHROME_BROWSER_UI_VIEWS_INFOBARS_AFTER_TRANSLATE_INFOBAR_H_
#define CHROME_BROWSER_UI_VIEWS_INFOBARS_AFTER_TRANSLATE_INFOBAR_H_
#include "chrome/browser/translate/options_menu_model.h"
#include "chrome/browser/ui/views/infobars/translate_infobar_base.h"
#include "chrome/browser/ui/views/infobars/translate_language_menu_model.h"
#include "ui/views/controls/button/menu_button_listener.h"
class OptionsMenuModel;
class TranslateInfoBarDelegate;
class TranslateLanguageMenuModel;
namespace views {
class MenuButton;
}
......@@ -51,7 +52,7 @@ class AfterTranslateInfoBar : public TranslateInfoBarBase,
scoped_ptr<TranslateLanguageMenuModel> original_language_menu_model_;
scoped_ptr<TranslateLanguageMenuModel> target_language_menu_model_;
OptionsMenuModel options_menu_model_;
scoped_ptr<OptionsMenuModel> options_menu_model_;
// True if the target language comes before the original one.
bool swapped_language_buttons_;
......
......@@ -5,7 +5,9 @@
#include "chrome/browser/ui/views/infobars/before_translate_infobar.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/translate/options_menu_model.h"
#include "chrome/browser/translate/translate_infobar_delegate.h"
#include "chrome/browser/ui/views/infobars/translate_language_menu_model.h"
#include "grit/generated_resources.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/views/controls/button/label_button.h"
......@@ -24,8 +26,7 @@ BeforeTranslateInfoBar::BeforeTranslateInfoBar(
deny_button_(NULL),
never_translate_button_(NULL),
always_translate_button_(NULL),
options_menu_button_(NULL),
options_menu_model_(delegate) {
options_menu_button_(NULL) {
}
BeforeTranslateInfoBar::~BeforeTranslateInfoBar() {
......@@ -133,6 +134,7 @@ void BeforeTranslateInfoBar::ViewHierarchyChanged(
options_menu_button_ = CreateMenuButton(
l10n_util::GetStringUTF16(IDS_TRANSLATE_INFOBAR_OPTIONS), this);
options_menu_model_.reset(new OptionsMenuModel(delegate));
AddChildView(options_menu_button_);
// This must happen after adding all other children so InfoBarView can ensure
......@@ -190,7 +192,7 @@ void BeforeTranslateInfoBar::OnMenuButtonClicked(views::View* source,
views::MenuItemView::TOPLEFT);
} else {
DCHECK_EQ(options_menu_button_, source);
RunMenuAt(&options_menu_model_, options_menu_button_,
RunMenuAt(options_menu_model_.get(), options_menu_button_,
views::MenuItemView::TOPRIGHT);
}
}
......@@ -5,12 +5,13 @@
#ifndef CHROME_BROWSER_UI_VIEWS_INFOBARS_BEFORE_TRANSLATE_INFOBAR_H_
#define CHROME_BROWSER_UI_VIEWS_INFOBARS_BEFORE_TRANSLATE_INFOBAR_H_
#include "chrome/browser/translate/options_menu_model.h"
#include "chrome/browser/ui/views/infobars/translate_infobar_base.h"
#include "chrome/browser/ui/views/infobars/translate_language_menu_model.h"
#include "ui/views/controls/button/menu_button_listener.h"
class OptionsMenuModel;
class TranslateInfoBarDelegate;
class TranslateLanguageMenuModel;
namespace views {
class MenuButton;
}
......@@ -51,7 +52,7 @@ class BeforeTranslateInfoBar : public TranslateInfoBarBase,
views::MenuButton* options_menu_button_;
scoped_ptr<TranslateLanguageMenuModel> language_menu_model_;
OptionsMenuModel options_menu_model_;
scoped_ptr<OptionsMenuModel> options_menu_model_;
DISALLOW_COPY_AND_ASSIGN(BeforeTranslateInfoBar);
};
......
......@@ -11,6 +11,7 @@
#include "ui/views/controls/button/menu_button_listener.h"
class Browser;
namespace views {
class ImageView;
class MenuButton;
......
......@@ -17,6 +17,7 @@
namespace ui {
class MenuModel;
}
namespace views {
class ImageButton;
class ImageView;
......@@ -27,7 +28,7 @@ class LinkListener;
class MenuButton;
class MenuButtonListener;
class MenuRunner;
}
} // namespace views
class InfoBarView : public InfoBar,
public views::View,
......
......@@ -9,6 +9,7 @@
class TranslateInfoBarBase;
class TranslateInfoBarDelegate;
namespace views {
class MenuButton;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment