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 @@ ...@@ -5,7 +5,9 @@
#include "chrome/browser/ui/views/infobars/after_translate_infobar.h" #include "chrome/browser/ui/views/infobars/after_translate_infobar.h"
#include "base/strings/utf_string_conversions.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/translate/translate_infobar_delegate.h"
#include "chrome/browser/ui/views/infobars/translate_language_menu_model.h"
#include "grit/generated_resources.h" #include "grit/generated_resources.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
#include "ui/views/controls/button/label_button.h" #include "ui/views/controls/button/label_button.h"
...@@ -24,7 +26,6 @@ AfterTranslateInfoBar::AfterTranslateInfoBar( ...@@ -24,7 +26,6 @@ AfterTranslateInfoBar::AfterTranslateInfoBar(
target_language_menu_button_(NULL), target_language_menu_button_(NULL),
revert_button_(NULL), revert_button_(NULL),
options_menu_button_(NULL), options_menu_button_(NULL),
options_menu_model_(delegate),
swapped_language_buttons_(false) { swapped_language_buttons_(false) {
autodetermined_source_language_ = autodetermined_source_language_ =
delegate->original_language_index() == TranslateInfoBarDelegate::kNoIndex; delegate->original_language_index() == TranslateInfoBarDelegate::kNoIndex;
...@@ -126,6 +127,7 @@ void AfterTranslateInfoBar::ViewHierarchyChanged( ...@@ -126,6 +127,7 @@ void AfterTranslateInfoBar::ViewHierarchyChanged(
options_menu_button_ = CreateMenuButton( options_menu_button_ = CreateMenuButton(
l10n_util::GetStringUTF16(IDS_TRANSLATE_INFOBAR_OPTIONS), this); l10n_util::GetStringUTF16(IDS_TRANSLATE_INFOBAR_OPTIONS), this);
options_menu_model_.reset(new OptionsMenuModel(delegate));
AddChildView(options_menu_button_); AddChildView(options_menu_button_);
// This must happen after adding all other children so InfoBarView can ensure // This must happen after adding all other children so InfoBarView can ensure
...@@ -177,7 +179,7 @@ void AfterTranslateInfoBar::OnMenuButtonClicked(views::View* source, ...@@ -177,7 +179,7 @@ void AfterTranslateInfoBar::OnMenuButtonClicked(views::View* source,
views::MenuItemView::TOPLEFT); views::MenuItemView::TOPLEFT);
} else { } else {
DCHECK_EQ(options_menu_button_, source); DCHECK_EQ(options_menu_button_, source);
RunMenuAt(&options_menu_model_, options_menu_button_, RunMenuAt(options_menu_model_.get(), options_menu_button_,
views::MenuItemView::TOPRIGHT); views::MenuItemView::TOPRIGHT);
} }
} }
...@@ -5,12 +5,13 @@ ...@@ -5,12 +5,13 @@
#ifndef CHROME_BROWSER_UI_VIEWS_INFOBARS_AFTER_TRANSLATE_INFOBAR_H_ #ifndef CHROME_BROWSER_UI_VIEWS_INFOBARS_AFTER_TRANSLATE_INFOBAR_H_
#define 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_infobar_base.h"
#include "chrome/browser/ui/views/infobars/translate_language_menu_model.h"
#include "ui/views/controls/button/menu_button_listener.h" #include "ui/views/controls/button/menu_button_listener.h"
class OptionsMenuModel;
class TranslateInfoBarDelegate; class TranslateInfoBarDelegate;
class TranslateLanguageMenuModel;
namespace views { namespace views {
class MenuButton; class MenuButton;
} }
...@@ -51,7 +52,7 @@ class AfterTranslateInfoBar : public TranslateInfoBarBase, ...@@ -51,7 +52,7 @@ class AfterTranslateInfoBar : public TranslateInfoBarBase,
scoped_ptr<TranslateLanguageMenuModel> original_language_menu_model_; scoped_ptr<TranslateLanguageMenuModel> original_language_menu_model_;
scoped_ptr<TranslateLanguageMenuModel> target_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. // True if the target language comes before the original one.
bool swapped_language_buttons_; bool swapped_language_buttons_;
......
...@@ -5,7 +5,9 @@ ...@@ -5,7 +5,9 @@
#include "chrome/browser/ui/views/infobars/before_translate_infobar.h" #include "chrome/browser/ui/views/infobars/before_translate_infobar.h"
#include "base/strings/utf_string_conversions.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/translate/translate_infobar_delegate.h"
#include "chrome/browser/ui/views/infobars/translate_language_menu_model.h"
#include "grit/generated_resources.h" #include "grit/generated_resources.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
#include "ui/views/controls/button/label_button.h" #include "ui/views/controls/button/label_button.h"
...@@ -24,8 +26,7 @@ BeforeTranslateInfoBar::BeforeTranslateInfoBar( ...@@ -24,8 +26,7 @@ BeforeTranslateInfoBar::BeforeTranslateInfoBar(
deny_button_(NULL), deny_button_(NULL),
never_translate_button_(NULL), never_translate_button_(NULL),
always_translate_button_(NULL), always_translate_button_(NULL),
options_menu_button_(NULL), options_menu_button_(NULL) {
options_menu_model_(delegate) {
} }
BeforeTranslateInfoBar::~BeforeTranslateInfoBar() { BeforeTranslateInfoBar::~BeforeTranslateInfoBar() {
...@@ -133,6 +134,7 @@ void BeforeTranslateInfoBar::ViewHierarchyChanged( ...@@ -133,6 +134,7 @@ void BeforeTranslateInfoBar::ViewHierarchyChanged(
options_menu_button_ = CreateMenuButton( options_menu_button_ = CreateMenuButton(
l10n_util::GetStringUTF16(IDS_TRANSLATE_INFOBAR_OPTIONS), this); l10n_util::GetStringUTF16(IDS_TRANSLATE_INFOBAR_OPTIONS), this);
options_menu_model_.reset(new OptionsMenuModel(delegate));
AddChildView(options_menu_button_); AddChildView(options_menu_button_);
// This must happen after adding all other children so InfoBarView can ensure // This must happen after adding all other children so InfoBarView can ensure
...@@ -190,7 +192,7 @@ void BeforeTranslateInfoBar::OnMenuButtonClicked(views::View* source, ...@@ -190,7 +192,7 @@ void BeforeTranslateInfoBar::OnMenuButtonClicked(views::View* source,
views::MenuItemView::TOPLEFT); views::MenuItemView::TOPLEFT);
} else { } else {
DCHECK_EQ(options_menu_button_, source); DCHECK_EQ(options_menu_button_, source);
RunMenuAt(&options_menu_model_, options_menu_button_, RunMenuAt(options_menu_model_.get(), options_menu_button_,
views::MenuItemView::TOPRIGHT); views::MenuItemView::TOPRIGHT);
} }
} }
...@@ -5,12 +5,13 @@ ...@@ -5,12 +5,13 @@
#ifndef CHROME_BROWSER_UI_VIEWS_INFOBARS_BEFORE_TRANSLATE_INFOBAR_H_ #ifndef CHROME_BROWSER_UI_VIEWS_INFOBARS_BEFORE_TRANSLATE_INFOBAR_H_
#define 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_infobar_base.h"
#include "chrome/browser/ui/views/infobars/translate_language_menu_model.h"
#include "ui/views/controls/button/menu_button_listener.h" #include "ui/views/controls/button/menu_button_listener.h"
class OptionsMenuModel;
class TranslateInfoBarDelegate; class TranslateInfoBarDelegate;
class TranslateLanguageMenuModel;
namespace views { namespace views {
class MenuButton; class MenuButton;
} }
...@@ -51,7 +52,7 @@ class BeforeTranslateInfoBar : public TranslateInfoBarBase, ...@@ -51,7 +52,7 @@ class BeforeTranslateInfoBar : public TranslateInfoBarBase,
views::MenuButton* options_menu_button_; views::MenuButton* options_menu_button_;
scoped_ptr<TranslateLanguageMenuModel> language_menu_model_; scoped_ptr<TranslateLanguageMenuModel> language_menu_model_;
OptionsMenuModel options_menu_model_; scoped_ptr<OptionsMenuModel> options_menu_model_;
DISALLOW_COPY_AND_ASSIGN(BeforeTranslateInfoBar); DISALLOW_COPY_AND_ASSIGN(BeforeTranslateInfoBar);
}; };
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "ui/views/controls/button/menu_button_listener.h" #include "ui/views/controls/button/menu_button_listener.h"
class Browser; class Browser;
namespace views { namespace views {
class ImageView; class ImageView;
class MenuButton; class MenuButton;
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
namespace ui { namespace ui {
class MenuModel; class MenuModel;
} }
namespace views { namespace views {
class ImageButton; class ImageButton;
class ImageView; class ImageView;
...@@ -27,7 +28,7 @@ class LinkListener; ...@@ -27,7 +28,7 @@ class LinkListener;
class MenuButton; class MenuButton;
class MenuButtonListener; class MenuButtonListener;
class MenuRunner; class MenuRunner;
} } // namespace views
class InfoBarView : public InfoBar, class InfoBarView : public InfoBar,
public views::View, public views::View,
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
class TranslateInfoBarBase; class TranslateInfoBarBase;
class TranslateInfoBarDelegate; class TranslateInfoBarDelegate;
namespace views { namespace views {
class MenuButton; 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