Commit 32d9e1f2 authored by msw@chromium.org's avatar msw@chromium.org

Avoid overriding Bubble's GetAnchorRect() where possible.

Use the new BubbleDelegateView::set_anchor_insets() instead.
Remove redundant DCHECK, fix indent, revise comments.

BUG=none
TEST=No noticable changes (placement or otherwise).

Review URL: https://chromiumcodereview.appspot.com/10830366

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@152375 0039d316-1c4b-4281-b951-d872f2087c98
parent 2a074bab
...@@ -121,13 +121,6 @@ views::View* BookmarkBubbleView::GetInitiallyFocusedView() { ...@@ -121,13 +121,6 @@ views::View* BookmarkBubbleView::GetInitiallyFocusedView() {
return title_tf_; return title_tf_;
} }
gfx::Rect BookmarkBubbleView::GetAnchorRect() {
// Compensate for some built-in padding in the star image.
gfx::Rect rect(BubbleDelegateView::GetAnchorRect());
rect.Inset(0, anchor_view() ? 5 : 0);
return rect;
}
void BookmarkBubbleView::WindowClosing() { void BookmarkBubbleView::WindowClosing() {
// We have to reset |bubble_| here, not in our destructor, because we'll be // We have to reset |bubble_| here, not in our destructor, because we'll be
// destroyed asynchronously and the shown state will be checked before then. // destroyed asynchronously and the shown state will be checked before then.
...@@ -262,6 +255,8 @@ BookmarkBubbleView::BookmarkBubbleView(views::View* anchor_view, ...@@ -262,6 +255,8 @@ BookmarkBubbleView::BookmarkBubbleView(views::View* anchor_view,
parent_combobox_(NULL), parent_combobox_(NULL),
remove_bookmark_(false), remove_bookmark_(false),
apply_edits_(true) { apply_edits_(true) {
// Compensate for built-in vertical padding in the anchor view's image.
set_anchor_insets(gfx::Insets(5, 0, 5, 0));
} }
string16 BookmarkBubbleView::GetTitle() { string16 BookmarkBubbleView::GetTitle() {
......
...@@ -42,9 +42,8 @@ class BookmarkBubbleView : public views::BubbleDelegateView, ...@@ -42,9 +42,8 @@ class BookmarkBubbleView : public views::BubbleDelegateView,
virtual ~BookmarkBubbleView(); virtual ~BookmarkBubbleView();
// views::BubbleDelegateView methods. // views::BubbleDelegateView method.
virtual views::View* GetInitiallyFocusedView() OVERRIDE; virtual views::View* GetInitiallyFocusedView() OVERRIDE;
virtual gfx::Rect GetAnchorRect() OVERRIDE;
// views::WidgetDelegate method. // views::WidgetDelegate method.
virtual void WindowClosing() OVERRIDE; virtual void WindowClosing() OVERRIDE;
......
...@@ -128,13 +128,6 @@ views::View* ChromeToMobileBubbleView::GetInitiallyFocusedView() { ...@@ -128,13 +128,6 @@ views::View* ChromeToMobileBubbleView::GetInitiallyFocusedView() {
return send_; return send_;
} }
gfx::Rect ChromeToMobileBubbleView::GetAnchorRect() {
// Compensate for some built-in padding in the page action icon image.
gfx::Rect rect(BubbleDelegateView::GetAnchorRect());
rect.Inset(0, anchor_view() ? 5 : 0);
return rect;
}
void ChromeToMobileBubbleView::WindowClosing() { void ChromeToMobileBubbleView::WindowClosing() {
// We have to reset |bubble_| here, not in our destructor, because we'll be // We have to reset |bubble_| here, not in our destructor, because we'll be
// destroyed asynchronously and the shown state will be checked before then. // destroyed asynchronously and the shown state will be checked before then.
...@@ -331,6 +324,9 @@ ChromeToMobileBubbleView::ChromeToMobileBubbleView(views::View* anchor_view, ...@@ -331,6 +324,9 @@ ChromeToMobileBubbleView::ChromeToMobileBubbleView(views::View* anchor_view,
send_copy_(NULL), send_copy_(NULL),
send_(NULL), send_(NULL),
cancel_(NULL) { cancel_(NULL) {
// Compensate for built-in vertical padding in the anchor view's image.
set_anchor_insets(gfx::Insets(5, 0, 5, 0));
// Generate the MHTML snapshot now to report its size in the bubble. // Generate the MHTML snapshot now to report its size in the bubble.
service_->GenerateSnapshot(browser_, weak_ptr_factory_.GetWeakPtr()); service_->GenerateSnapshot(browser_, weak_ptr_factory_.GetWeakPtr());
......
...@@ -46,7 +46,6 @@ class ChromeToMobileBubbleView : public views::BubbleDelegateView, ...@@ -46,7 +46,6 @@ class ChromeToMobileBubbleView : public views::BubbleDelegateView,
// views::BubbleDelegateView methods. // views::BubbleDelegateView methods.
virtual views::View* GetInitiallyFocusedView() OVERRIDE; virtual views::View* GetInitiallyFocusedView() OVERRIDE;
virtual gfx::Rect GetAnchorRect() OVERRIDE;
virtual void WindowClosing() OVERRIDE; virtual void WindowClosing() OVERRIDE;
virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE; virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE;
virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE; virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE;
......
...@@ -108,6 +108,9 @@ ContentSettingBubbleContents::ContentSettingBubbleContents( ...@@ -108,6 +108,9 @@ ContentSettingBubbleContents::ContentSettingBubbleContents(
custom_link_(NULL), custom_link_(NULL),
manage_link_(NULL), manage_link_(NULL),
close_button_(NULL) { close_button_(NULL) {
// Compensate for built-in vertical padding in the anchor view's image.
set_anchor_insets(gfx::Insets(5, 0, 5, 0));
registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED,
content::Source<WebContents>(web_contents)); content::Source<WebContents>(web_contents));
} }
...@@ -125,12 +128,6 @@ gfx::Size ContentSettingBubbleContents::GetPreferredSize() { ...@@ -125,12 +128,6 @@ gfx::Size ContentSettingBubbleContents::GetPreferredSize() {
return preferred_size; return preferred_size;
} }
gfx::Rect ContentSettingBubbleContents::GetAnchorRect() {
gfx::Rect rect(BubbleDelegateView::GetAnchorRect());
rect.Inset(0, anchor_view() ? 5 : 0);
return rect;
}
void ContentSettingBubbleContents::Init() { void ContentSettingBubbleContents::Init() {
using views::GridLayout; using views::GridLayout;
......
...@@ -53,9 +53,6 @@ class ContentSettingBubbleContents : public views::BubbleDelegateView, ...@@ -53,9 +53,6 @@ class ContentSettingBubbleContents : public views::BubbleDelegateView,
virtual gfx::Size GetPreferredSize() OVERRIDE; virtual gfx::Size GetPreferredSize() OVERRIDE;
// views::BubbleDelegateView:
virtual gfx::Rect GetAnchorRect() OVERRIDE;
protected: protected:
// views::BubbleDelegateView: // views::BubbleDelegateView:
virtual void Init() OVERRIDE; virtual void Init() OVERRIDE;
......
...@@ -78,16 +78,12 @@ void FirstRunBubble::Init() { ...@@ -78,16 +78,12 @@ void FirstRunBubble::Init() {
layout->AddView(subtext, columns->num_columns(), 1); layout->AddView(subtext, columns->num_columns(), 1);
} }
gfx::Rect FirstRunBubble::GetAnchorRect() {
// Compensate for padding in anchor.
gfx::Rect rect(BubbleDelegateView::GetAnchorRect());
rect.Inset(0, anchor_view() ? kAnchorVerticalInset : 0);
return rect;
}
FirstRunBubble::FirstRunBubble(Browser* browser, views::View* anchor_view) FirstRunBubble::FirstRunBubble(Browser* browser, views::View* anchor_view)
: views::BubbleDelegateView(anchor_view, views::BubbleBorder::TOP_LEFT), : views::BubbleDelegateView(anchor_view, views::BubbleBorder::TOP_LEFT),
browser_(browser) { browser_(browser) {
// Compensate for built-in vertical padding in the anchor view's image.
set_anchor_insets(
gfx::Insets(kAnchorVerticalInset, 0, kAnchorVerticalInset, 0));
} }
FirstRunBubble::~FirstRunBubble() { FirstRunBubble::~FirstRunBubble() {
......
...@@ -16,9 +16,6 @@ class FirstRunBubble : public views::BubbleDelegateView, ...@@ -16,9 +16,6 @@ class FirstRunBubble : public views::BubbleDelegateView,
// |browser| is the opening browser and is NULL in unittests. // |browser| is the opening browser and is NULL in unittests.
static FirstRunBubble* ShowBubble(Browser* browser, views::View* anchor_view); static FirstRunBubble* ShowBubble(Browser* browser, views::View* anchor_view);
// views::BubbleDelegateView overrides:
virtual gfx::Rect GetAnchorRect() OVERRIDE;
protected: protected:
// views::BubbleDelegateView overrides: // views::BubbleDelegateView overrides:
virtual void Init() OVERRIDE; virtual void Init() OVERRIDE;
......
...@@ -65,7 +65,10 @@ GlobalErrorBubbleView::GlobalErrorBubbleView( ...@@ -65,7 +65,10 @@ GlobalErrorBubbleView::GlobalErrorBubbleView(
: BubbleDelegateView(anchor_view, location), : BubbleDelegateView(anchor_view, location),
browser_(browser), browser_(browser),
error_(error) { error_(error) {
DCHECK(error_); // Compensate for built-in vertical padding in the anchor view's image.
set_anchor_insets(
gfx::Insets(kAnchorVerticalInset, 0, kAnchorVerticalInset, 0));
ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
int resource_id = error_->GetBubbleViewIconResourceID(); int resource_id = error_->GetBubbleViewIconResourceID();
scoped_ptr<views::ImageView> image_view(new views::ImageView()); scoped_ptr<views::ImageView> image_view(new views::ImageView());
...@@ -145,12 +148,6 @@ GlobalErrorBubbleView::GlobalErrorBubbleView( ...@@ -145,12 +148,6 @@ GlobalErrorBubbleView::GlobalErrorBubbleView(
GlobalErrorBubbleView::~GlobalErrorBubbleView() { GlobalErrorBubbleView::~GlobalErrorBubbleView() {
} }
gfx::Rect GlobalErrorBubbleView::GetAnchorRect() {
gfx::Rect rect(views::BubbleDelegateView::GetAnchorRect());
rect.Inset(0, anchor_view() ? kAnchorVerticalInset : 0);
return rect;
}
void GlobalErrorBubbleView::ButtonPressed(views::Button* sender, void GlobalErrorBubbleView::ButtonPressed(views::Button* sender,
const ui::Event& event) { const ui::Event& event) {
if (error_) { if (error_) {
......
...@@ -23,9 +23,6 @@ class GlobalErrorBubbleView : public views::ButtonListener, ...@@ -23,9 +23,6 @@ class GlobalErrorBubbleView : public views::ButtonListener,
const base::WeakPtr<GlobalError>& error); const base::WeakPtr<GlobalError>& error);
virtual ~GlobalErrorBubbleView(); virtual ~GlobalErrorBubbleView();
// views::BubbleDelegateView implementation.
virtual gfx::Rect GetAnchorRect() OVERRIDE;
// views::ButtonListener implementation. // views::ButtonListener implementation.
virtual void ButtonPressed(views::Button* sender, virtual void ButtonPressed(views::Button* sender,
const ui::Event& event) OVERRIDE; const ui::Event& event) OVERRIDE;
......
...@@ -74,6 +74,8 @@ ZoomBubbleView::ZoomBubbleView(views::View* anchor_view, ...@@ -74,6 +74,8 @@ ZoomBubbleView::ZoomBubbleView(views::View* anchor_view,
label_(NULL), label_(NULL),
tab_contents_(tab_contents), tab_contents_(tab_contents),
auto_close_(auto_close) { auto_close_(auto_close) {
// Compensate for built-in vertical padding in the anchor view's image.
set_anchor_insets(gfx::Insets(5, 0, 5, 0));
set_use_focusless(auto_close); set_use_focusless(auto_close);
set_notify_enter_exit_on_child(true); set_notify_enter_exit_on_child(true);
} }
...@@ -147,13 +149,6 @@ void ZoomBubbleView::Init() { ...@@ -147,13 +149,6 @@ void ZoomBubbleView::Init() {
StartTimerIfNecessary(); StartTimerIfNecessary();
} }
gfx::Rect ZoomBubbleView::GetAnchorRect() {
// Compensate for some built-in padding in the zoom image.
gfx::Rect rect(BubbleDelegateView::GetAnchorRect());
rect.Inset(0, anchor_view() ? 5 : 0);
return rect;
}
void ZoomBubbleView::WindowClosing() { void ZoomBubbleView::WindowClosing() {
DCHECK(zoom_bubble_ == this); DCHECK(zoom_bubble_ == this);
zoom_bubble_ = NULL; zoom_bubble_ = NULL;
......
...@@ -54,7 +54,6 @@ class ZoomBubbleView : public views::BubbleDelegateView, ...@@ -54,7 +54,6 @@ class ZoomBubbleView : public views::BubbleDelegateView,
// views::BubbleDelegateView method. // views::BubbleDelegateView method.
virtual void Init() OVERRIDE; virtual void Init() OVERRIDE;
virtual gfx::Rect GetAnchorRect() OVERRIDE;
virtual void WindowClosing() OVERRIDE; virtual void WindowClosing() OVERRIDE;
// Singleton instance of the zoom bubble. The zoom bubble can only be shown on // Singleton instance of the zoom bubble. The zoom bubble can only be shown on
......
...@@ -60,6 +60,9 @@ NetworkProfileBubbleView::NetworkProfileBubbleView( ...@@ -60,6 +60,9 @@ NetworkProfileBubbleView::NetworkProfileBubbleView(
: BubbleDelegateView(anchor, views::BubbleBorder::TOP_RIGHT), : BubbleDelegateView(anchor, views::BubbleBorder::TOP_RIGHT),
navigator_(navigator), navigator_(navigator),
profile_(profile) { profile_(profile) {
// Compensate for built-in vertical padding in the anchor view's image.
set_anchor_insets(
gfx::Insets(kAnchorVerticalInset, 0, kAnchorVerticalInset, 0));
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
...@@ -107,13 +110,6 @@ void NetworkProfileBubbleView::Init() { ...@@ -107,13 +110,6 @@ void NetworkProfileBubbleView::Init() {
layout->AddView(ok_button); layout->AddView(ok_button);
} }
gfx::Rect NetworkProfileBubbleView::GetAnchorRect() {
// Compensate for padding in anchor.
gfx::Rect rect(BubbleDelegateView::GetAnchorRect());
rect.Inset(0, anchor_view() ? kAnchorVerticalInset : 0);
return rect;
}
void NetworkProfileBubbleView::ButtonPressed(views::Button* sender, void NetworkProfileBubbleView::ButtonPressed(views::Button* sender,
const ui::Event& event) { const ui::Event& event) {
NetworkProfileBubble::RecordUmaEvent( NetworkProfileBubble::RecordUmaEvent(
......
...@@ -29,7 +29,6 @@ class NetworkProfileBubbleView : public views::BubbleDelegateView, ...@@ -29,7 +29,6 @@ class NetworkProfileBubbleView : public views::BubbleDelegateView,
// views::BubbleDelegateView: // views::BubbleDelegateView:
virtual void Init() OVERRIDE; virtual void Init() OVERRIDE;
virtual gfx::Rect GetAnchorRect() OVERRIDE;
// views::ButtonListener: // views::ButtonListener:
virtual void ButtonPressed(views::Button* sender, virtual void ButtonPressed(views::Button* sender,
......
...@@ -121,6 +121,9 @@ PageInfoBubbleView::PageInfoBubbleView(views::View* anchor_view, ...@@ -121,6 +121,9 @@ PageInfoBubbleView::PageInfoBubbleView(views::View* anchor_view,
animation_start_height_(0), animation_start_height_(0),
navigator_(navigator), navigator_(navigator),
web_contents_(web_contents) { web_contents_(web_contents) {
// Compensate for built-in vertical padding in the anchor view's image.
set_anchor_insets(gfx::Insets(5, 0, 5, 0));
if (cert_id_ > 0) { if (cert_id_ > 0) {
scoped_refptr<net::X509Certificate> cert; scoped_refptr<net::X509Certificate> cert;
content::CertStore::GetInstance()->RetrieveCert(cert_id_, &cert); content::CertStore::GetInstance()->RetrieveCert(cert_id_, &cert);
...@@ -283,13 +286,6 @@ void PageInfoBubbleView::OnPageInfoModelChanged() { ...@@ -283,13 +286,6 @@ void PageInfoBubbleView::OnPageInfoModelChanged() {
resize_animation_.Show(); resize_animation_.Show();
} }
gfx::Rect PageInfoBubbleView::GetAnchorRect() {
// Compensate for some built-in padding in the icon.
gfx::Rect anchor(BubbleDelegateView::GetAnchorRect());
anchor.Inset(0, anchor_view() ? 5 : 0);
return anchor;
}
void PageInfoBubbleView::LinkClicked(views::Link* source, int event_flags) { void PageInfoBubbleView::LinkClicked(views::Link* source, int event_flags) {
navigator_->OpenURL(OpenURLParams(GURL(chrome::kPageInfoHelpCenterURL), navigator_->OpenURL(OpenURLParams(GURL(chrome::kPageInfoHelpCenterURL),
Referrer(), Referrer(),
......
...@@ -39,9 +39,6 @@ class PageInfoBubbleView : public views::BubbleDelegateView, ...@@ -39,9 +39,6 @@ class PageInfoBubbleView : public views::BubbleDelegateView,
// PageInfoModelObserver methods: // PageInfoModelObserver methods:
virtual void OnPageInfoModelChanged() OVERRIDE; virtual void OnPageInfoModelChanged() OVERRIDE;
// views::BubbleDelegate methods:
virtual gfx::Rect GetAnchorRect() OVERRIDE;
// views::LinkListener methods: // views::LinkListener methods:
virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE; virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE;
......
...@@ -71,12 +71,9 @@ const int kHeaderPaddingTop = 12; ...@@ -71,12 +71,9 @@ const int kHeaderPaddingTop = 12;
// the popup header. // the popup header.
const int kHeaderRowSpacing = 4; const int kHeaderRowSpacing = 4;
// In order to make the arrow of the bubble point directly at the location icon // To make the bubble's arrow point directly at the location icon rather than at
// in the Omnibox rather then the bottom border of the Omnibox, the position of // the Omnibox's edge, inset the bubble's anchor rect by this amount of pixels.
// the bubble must be adjusted. This is the number of pixel the bubble must be const int kLocationIconVerticalMargin = 5;
// moved towards the top of the screen (starting from the bottom border of the
// Omnibox).
const int kLocationIconBottomMargin = 5;
// The margins between the popup border and the popup content. // The margins between the popup border and the popup content.
const int kPopupMarginTop = 4; const int kPopupMarginTop = 4;
...@@ -143,9 +140,6 @@ class InternalPageInfoPopupView : public views::BubbleDelegateView { ...@@ -143,9 +140,6 @@ class InternalPageInfoPopupView : public views::BubbleDelegateView {
virtual ~InternalPageInfoPopupView(); virtual ~InternalPageInfoPopupView();
private: private:
// views::BubbleDelegate implementations.
virtual gfx::Rect GetAnchorRect() OVERRIDE;
DISALLOW_COPY_AND_ASSIGN(InternalPageInfoPopupView); DISALLOW_COPY_AND_ASSIGN(InternalPageInfoPopupView);
}; };
...@@ -228,6 +222,10 @@ void PopupHeaderView::SetIdentityStatus(const string16& status, ...@@ -228,6 +222,10 @@ void PopupHeaderView::SetIdentityStatus(const string16& status,
InternalPageInfoPopupView::InternalPageInfoPopupView(views::View* anchor_view) InternalPageInfoPopupView::InternalPageInfoPopupView(views::View* anchor_view)
: BubbleDelegateView(anchor_view, views::BubbleBorder::TOP_LEFT) { : BubbleDelegateView(anchor_view, views::BubbleBorder::TOP_LEFT) {
// Compensate for built-in vertical padding in the anchor view's image.
set_anchor_insets(gfx::Insets(kLocationIconVerticalMargin, 0,
kLocationIconVerticalMargin, 0));
const int kSpacing = 4; const int kSpacing = 4;
SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal, kSpacing, SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal, kSpacing,
kSpacing, kSpacing)); kSpacing, kSpacing));
...@@ -251,14 +249,6 @@ InternalPageInfoPopupView::InternalPageInfoPopupView(views::View* anchor_view) ...@@ -251,14 +249,6 @@ InternalPageInfoPopupView::InternalPageInfoPopupView(views::View* anchor_view)
InternalPageInfoPopupView::~InternalPageInfoPopupView() { InternalPageInfoPopupView::~InternalPageInfoPopupView() {
} }
gfx::Rect InternalPageInfoPopupView::GetAnchorRect() {
// Compensate for some built-in padding in the icon. This will make the arrow
// point to the middle of the icon.
gfx::Rect anchor(BubbleDelegateView::GetAnchorRect());
anchor.Inset(0, anchor_view() ? kLocationIconBottomMargin : 0);
return anchor;
}
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// WebsiteSettingsPopupView // WebsiteSettingsPopupView
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
...@@ -296,52 +286,56 @@ WebsiteSettingsPopupView::WebsiteSettingsPopupView( ...@@ -296,52 +286,56 @@ WebsiteSettingsPopupView::WebsiteSettingsPopupView(
cert_id_(0), cert_id_(0),
connection_info_content_(NULL), connection_info_content_(NULL),
page_info_content_(NULL) { page_info_content_(NULL) {
views::GridLayout* layout = new views::GridLayout(this); // Compensate for built-in vertical padding in the anchor view's image.
SetLayoutManager(layout); set_anchor_insets(gfx::Insets(kLocationIconVerticalMargin, 0,
const int content_column = 0; kLocationIconVerticalMargin, 0));
views::ColumnSet* column_set = layout->AddColumnSet(content_column);
column_set->AddColumn(views::GridLayout::FILL,
views::GridLayout::FILL,
1,
views::GridLayout::USE_PREF,
0,
0);
header_ = new PopupHeaderView(this);
layout->StartRow(1, content_column);
layout->AddView(header_);
layout->AddPaddingRow(1, kHeaderMarginBottom); views::GridLayout* layout = new views::GridLayout(this);
tabbed_pane_ = new views::TabbedPane(); SetLayoutManager(layout);
layout->StartRow(1, content_column); const int content_column = 0;
layout->AddView(tabbed_pane_); views::ColumnSet* column_set = layout->AddColumnSet(content_column);
// Tabs must be added after the tabbed_pane_ was added to the views column_set->AddColumn(views::GridLayout::FILL,
// hierachy. Adding the |tabbed_pane_| to the views hierachy triggers the views::GridLayout::FILL,
// initialization of the native tab UI element. If the native tab UI 1,
// element is not initalized adding a tab will result in a NULL pointer views::GridLayout::USE_PREF,
// excetion. 0,
tabbed_pane_->AddTab( 0);
l10n_util::GetStringUTF16(IDS_WEBSITE_SETTINGS_TAB_LABEL_PERMISSIONS),
CreatePermissionsTab()); header_ = new PopupHeaderView(this);
tabbed_pane_->AddTab( layout->StartRow(1, content_column);
l10n_util::GetStringUTF16(IDS_WEBSITE_SETTINGS_TAB_LABEL_CONNECTION), layout->AddView(header_);
CreateConnectionTab());
tabbed_pane_->SelectTabAt(0); layout->AddPaddingRow(1, kHeaderMarginBottom);
tabbed_pane_->set_listener(this); tabbed_pane_ = new views::TabbedPane();
layout->StartRow(1, content_column);
set_margins(gfx::Insets(kPopupMarginTop, kPopupMarginLeft, layout->AddView(tabbed_pane_);
kPopupMarginBottom, kPopupMarginRight)); // Tabs must be added after the tabbed_pane_ was added to the views
// hierachy. Adding the |tabbed_pane_| to the views hierachy triggers the
views::BubbleDelegateView::CreateBubble(this); // initialization of the native tab UI element. If the native tab UI
this->Show(); // element is not initalized adding a tab will result in a NULL pointer
SizeToContents(); // excetion.
tabbed_pane_->AddTab(
presenter_.reset(new WebsiteSettings(this, profile, l10n_util::GetStringUTF16(IDS_WEBSITE_SETTINGS_TAB_LABEL_PERMISSIONS),
tab_contents->content_settings(), CreatePermissionsTab());
tab_contents->infobar_tab_helper(), tabbed_pane_->AddTab(
url, l10n_util::GetStringUTF16(IDS_WEBSITE_SETTINGS_TAB_LABEL_CONNECTION),
ssl, CreateConnectionTab());
content::CertStore::GetInstance())); tabbed_pane_->SelectTabAt(0);
tabbed_pane_->set_listener(this);
set_margins(gfx::Insets(kPopupMarginTop, kPopupMarginLeft,
kPopupMarginBottom, kPopupMarginRight));
views::BubbleDelegateView::CreateBubble(this);
this->Show();
SizeToContents();
presenter_.reset(new WebsiteSettings(this, profile,
tab_contents->content_settings(),
tab_contents->infobar_tab_helper(),
url,
ssl,
content::CertStore::GetInstance()));
} }
void WebsiteSettingsPopupView::OnPermissionChanged( void WebsiteSettingsPopupView::OnPermissionChanged(
...@@ -352,14 +346,6 @@ void WebsiteSettingsPopupView::OnPermissionChanged( ...@@ -352,14 +346,6 @@ void WebsiteSettingsPopupView::OnPermissionChanged(
permission_selector->GetSelectedSetting()); permission_selector->GetSelectedSetting());
} }
gfx::Rect WebsiteSettingsPopupView::GetAnchorRect() {
// Compensate for some built-in padding in the icon. This will make the arrow
// point to the middle of the icon.
gfx::Rect anchor(BubbleDelegateView::GetAnchorRect());
anchor.Inset(0, anchor_view() ? kLocationIconBottomMargin : 0);
return anchor;
}
void WebsiteSettingsPopupView::OnWidgetClosing(views::Widget* widget) { void WebsiteSettingsPopupView::OnWidgetClosing(views::Widget* widget) {
presenter_->OnUIClosing(); presenter_->OnUIClosing();
} }
......
...@@ -60,8 +60,7 @@ class WebsiteSettingsPopupView ...@@ -60,8 +60,7 @@ class WebsiteSettingsPopupView
virtual void OnPermissionChanged( virtual void OnPermissionChanged(
PermissionSelectorView* selector) OVERRIDE; PermissionSelectorView* selector) OVERRIDE;
// views::BubbleDelegate implementations. // views::BubbleDelegate implementation.
virtual gfx::Rect GetAnchorRect() OVERRIDE;
virtual void OnWidgetClosing(views::Widget* widget) OVERRIDE; virtual void OnWidgetClosing(views::Widget* widget) OVERRIDE;
// views::ButtonListener implementation. // views::ButtonListener implementation.
......
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