diff options
author | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-03 03:06:37 +0000 |
---|---|---|
committer | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-03 03:06:37 +0000 |
commit | 1c41af415bd13bf25db073ee898eb416ead52ef4 (patch) | |
tree | 30ae00f0bc481cf88a1d27de5d21dbb493e0bbbc | |
parent | c6fd2097f07574f616de929b75ae3bf31b0ca78b (diff) | |
download | chromium_src-1c41af415bd13bf25db073ee898eb416ead52ef4.zip chromium_src-1c41af415bd13bf25db073ee898eb416ead52ef4.tar.gz chromium_src-1c41af415bd13bf25db073ee898eb416ead52ef4.tar.bz2 |
Tear out all the old infobar code.
http://crbug.com/4620
Review URL: http://codereview.chromium.org/13077
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@6273 0039d316-1c4b-4281-b951-d872f2087c98
23 files changed, 5 insertions, 1231 deletions
diff --git a/chrome/browser/browser_init.cc b/chrome/browser/browser_init.cc index ddc3861..0908689 100644 --- a/chrome/browser/browser_init.cc +++ b/chrome/browser/browser_init.cc @@ -31,7 +31,6 @@ #include "chrome/browser/tabs/tab_strip_model.h" #include "chrome/browser/url_fixer_upper.h" #include "chrome/browser/web_app_launcher.h" -#include "chrome/browser/web_contents_view.h" #include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_switches.h" diff --git a/chrome/browser/native_ui_contents.h b/chrome/browser/native_ui_contents.h index d6de98c..54319b7 100644 --- a/chrome/browser/native_ui_contents.h +++ b/chrome/browser/native_ui_contents.h @@ -16,6 +16,7 @@ namespace views { class CheckBox; class FocusTraversable; +class ImageView; class ScrollView; class Throbber; } diff --git a/chrome/browser/password_manager.cc b/chrome/browser/password_manager.cc index 74b4d44..97c8ea7 100644 --- a/chrome/browser/password_manager.cc +++ b/chrome/browser/password_manager.cc @@ -8,7 +8,6 @@ #include "chrome/app/theme/theme_resources.h" #include "chrome/browser/profile.h" #include "chrome/browser/web_contents.h" -#include "chrome/browser/web_contents_view.h" #include "chrome/common/l10n_util.h" #include "chrome/common/pref_names.h" #include "chrome/common/pref_service.h" diff --git a/chrome/browser/resource_dispatcher_host.cc b/chrome/browser/resource_dispatcher_host.cc index 9d385c1..6ebf412 100644 --- a/chrome/browser/resource_dispatcher_host.cc +++ b/chrome/browser/resource_dispatcher_host.cc @@ -27,8 +27,6 @@ #include "chrome/browser/safe_browsing/safe_browsing_service.h" #include "chrome/browser/tab_contents.h" #include "chrome/browser/tab_util.h" -#include "chrome/browser/views/info_bar_view.h" -#include "chrome/browser/views/info_bar_message_view.h" #include "chrome/common/notification_source.h" #include "chrome/common/notification_types.h" #include "chrome/common/render_messages.h" diff --git a/chrome/browser/session_crashed_view.cc b/chrome/browser/session_crashed_view.cc deleted file mode 100644 index e69de29..0000000 --- a/chrome/browser/session_crashed_view.cc +++ /dev/null diff --git a/chrome/browser/session_crashed_view.h b/chrome/browser/session_crashed_view.h deleted file mode 100644 index e69de29..0000000 --- a/chrome/browser/session_crashed_view.h +++ /dev/null diff --git a/chrome/browser/ssl_manager.cc b/chrome/browser/ssl_manager.cc index 1881fdf..f76774a0 100644 --- a/chrome/browser/ssl_manager.cc +++ b/chrome/browser/ssl_manager.cc @@ -20,10 +20,7 @@ #include "chrome/browser/ssl_policy.h" #include "chrome/browser/tab_contents.h" #include "chrome/browser/tab_util.h" -#include "chrome/browser/views/info_bar_view.h" -#include "chrome/browser/views/standard_layout.h" #include "chrome/browser/web_contents.h" -#include "chrome/browser/web_contents_view.h" #include "chrome/common/l10n_util.h" #include "chrome/common/notification_service.h" #include "chrome/common/pref_names.h" diff --git a/chrome/browser/ssl_manager.h b/chrome/browser/ssl_manager.h index 0610403..29c01f3 100644 --- a/chrome/browser/ssl_manager.h +++ b/chrome/browser/ssl_manager.h @@ -14,7 +14,6 @@ #include "chrome/browser/provisional_load_details.h" #include "chrome/browser/resource_dispatcher_host.h" #include "chrome/browser/security_style.h" -#include "chrome/browser/views/info_bar_message_view.h" #include "chrome/common/notification_registrar.h" #include "chrome/common/notification_service.h" #include "chrome/common/render_messages.h" diff --git a/chrome/browser/views/browser_views.vcproj b/chrome/browser/views/browser_views.vcproj index f7ca623..6eed9d0 100644 --- a/chrome/browser/views/browser_views.vcproj +++ b/chrome/browser/views/browser_views.vcproj @@ -177,46 +177,6 @@ Name="Info Bars" > <File - RelativePath=".\info_bar_alternate_nav_url_view.cc" - > - </File> - <File - RelativePath=".\info_bar_alternate_nav_url_view.h" - > - </File> - <File - RelativePath=".\info_bar_confirm_view.cc" - > - </File> - <File - RelativePath=".\info_bar_confirm_view.h" - > - </File> - <File - RelativePath=".\info_bar_item_view.cc" - > - </File> - <File - RelativePath=".\info_bar_item_view.h" - > - </File> - <File - RelativePath=".\info_bar_message_view.cc" - > - </File> - <File - RelativePath=".\info_bar_message_view.h" - > - </File> - <File - RelativePath=".\info_bar_view.cc" - > - </File> - <File - RelativePath=".\info_bar_view.h" - > - </File> - <File RelativePath=".\infobars\infobar_container.cc" > </File> diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc index 019fdc8..ccbb950 100644 --- a/chrome/browser/views/frame/browser_view.cc +++ b/chrome/browser/views/frame/browser_view.cc @@ -1091,21 +1091,10 @@ int BrowserView::LayoutBookmarkBar(int top) { } int BrowserView::LayoutInfoBar(int top) { if (SupportsWindowFeature(FEATURE_INFOBAR)) { - // Layout the new infobar. + // Layout the InfoBar container. gfx::Size ps = infobar_container_->GetPreferredSize(); infobar_container_->SetBounds(0, top, width(), ps.height()); top += ps.height(); - - if (active_info_bar_) { - // Layout the old infobar. - ps = active_info_bar_->GetPreferredSize(); - active_info_bar_->SetBounds(0, top, width(), ps.height()); - top += ps.height(); - if (SupportsWindowFeature(FEATURE_BOOKMARKBAR) && active_bookmark_bar_ && - !show_bookmark_bar_pref_.GetValue()) { - top -= kSeparationLineHeight; - } - } } return top; } @@ -1147,13 +1136,9 @@ bool BrowserView::MaybeShowBookmarkBar(TabContents* contents) { } bool BrowserView::MaybeShowInfoBar(TabContents* contents) { - views::View* new_info_bar = NULL; - if (contents && contents->AsWebContents() && - contents->AsWebContents()->view()->IsInfoBarVisible()) - new_info_bar = contents->AsWebContents()->view()->GetInfoBarView(); - UpdateChildViewAndLayout(new_info_bar, &active_info_bar_); - - // TODO(beng): remove this function once the InfoBar rejiggering is complete. + // TODO(beng): Remove this function once the interface between + // InfoBarContainer, DownloadShelfView and TabContents and this + // view is sorted out. return true; } diff --git a/chrome/browser/views/info_bar_alternate_nav_url_view.cc b/chrome/browser/views/info_bar_alternate_nav_url_view.cc deleted file mode 100644 index 2eaa9e02..0000000 --- a/chrome/browser/views/info_bar_alternate_nav_url_view.cc +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/views/info_bar_alternate_nav_url_view.h" - -#include "chrome/app/theme/theme_resources.h" -#include "chrome/browser/web_contents.h" -#include "chrome/browser/views/event_utils.h" -#include "chrome/browser/views/info_bar_view.h" -#include "chrome/browser/views/standard_layout.h" -#include "chrome/common/l10n_util.h" -#include "chrome/common/page_transition_types.h" -#include "chrome/common/resource_bundle.h" -#include "chrome/views/label.h" - -#include "generated_resources.h" - -InfoBarAlternateNavURLView::InfoBarAlternateNavURLView( - const std::wstring& alternate_nav_url) - : alternate_nav_url_(alternate_nav_url) { - size_t offset; - const std::wstring label(l10n_util::GetStringF( - IDS_ALTERNATE_NAV_URL_VIEW_LABEL, std::wstring(), &offset)); - DCHECK(offset != std::wstring::npos); - - ResourceBundle& rb = ResourceBundle::GetSharedInstance(); - if (offset > 0) { - views::Label* label_1 = new views::Label(label.substr(0, offset)); - label_1->SetFont(rb.GetFont(ResourceBundle::MediumFont)); - AddChildViewLeading(label_1, 0); - } - - views::Link* link = new views::Link(alternate_nav_url_); - link->SetFont(rb.GetFont(ResourceBundle::MediumFont)); - link->SetController(this); - AddChildViewLeading(link, 0); - - if (offset < label.length()) { - views::Label* label_2 = new views::Label(label.substr(offset)); - label_2->SetFont(rb.GetFont(ResourceBundle::MediumFont)); - AddChildViewLeading(label_2, 0); - } - - SetIcon(*rb.GetBitmapNamed(IDR_INFOBAR_ALT_NAV_URL)); -} - -void InfoBarAlternateNavURLView::LinkActivated(views::Link* source, - int event_flags) { - // Navigating may or may not automatically close the infobar, depending on - // whether the desired disposition replaces the current tab. We always want - // the bar to close, so we close it ourselves before navigating (doing things - // in the other order would be problematic if navigation synchronously closed - // the bar, as on return from the call, |this| would not exist, and calling - // Close() would corrupt memory). This means we need to save off all members - // we need before calling Close(), which destroys us. - PageNavigator* const navigator = - static_cast<InfoBarView*>(GetParent())->web_contents(); - const GURL gurl(alternate_nav_url_); - - BeginClose(); - - navigator->OpenURL(gurl, GURL(), - event_utils::DispositionFromEventFlags(event_flags), - // Pretend the user typed this URL, so that navigating to - // it will be the default action when it's typed again in - // the future. - PageTransition::TYPED); -} - diff --git a/chrome/browser/views/info_bar_alternate_nav_url_view.h b/chrome/browser/views/info_bar_alternate_nav_url_view.h deleted file mode 100644 index f32697f..0000000 --- a/chrome/browser/views/info_bar_alternate_nav_url_view.h +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_VIEWS_INFO_BAR_ALTERNATE_NAV_URL_VIEW_H__ -#define CHROME_BROWSER_VIEWS_INFO_BAR_ALTERNATE_NAV_URL_VIEW_H__ - -#include "chrome/browser/views/info_bar_item_view.h" -#include "chrome/views/link.h" - -class InfoBarAlternateNavURLView : public InfoBarItemView, - public views::LinkController { - public: - explicit InfoBarAlternateNavURLView(const std::wstring& alternate_nav_url); - virtual ~InfoBarAlternateNavURLView() { } - - // LinkController - virtual void LinkActivated(views::Link* source, int event_flags); - - private: - std::wstring alternate_nav_url_; - - DISALLOW_EVIL_CONSTRUCTORS(InfoBarAlternateNavURLView); -}; - -#endif // CHROME_BROWSER_VIEWS_INFO_BAR_ALTERNATE_NAV_URL_VIEW_H__ diff --git a/chrome/browser/views/info_bar_confirm_view.cc b/chrome/browser/views/info_bar_confirm_view.cc deleted file mode 100644 index 6c6a15a..0000000 --- a/chrome/browser/views/info_bar_confirm_view.cc +++ /dev/null @@ -1,98 +0,0 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/views/info_bar_confirm_view.h" -#include "chrome/browser/views/standard_layout.h" -#include "chrome/common/l10n_util.h" - -#include "generated_resources.h" - -InfoBarConfirmView::InfoBarConfirmView(const std::wstring& message) - : ok_button_(NULL), - cancel_button_(NULL), - InfoBarMessageView(message) { - Init(); -} - -InfoBarConfirmView::~InfoBarConfirmView() {} - -void InfoBarConfirmView::OKButtonPressed() { - // Delete and close this view by default. - BeginClose(); -} - -void InfoBarConfirmView::CancelButtonPressed() { - // Delete and close this view by default. - BeginClose(); -} - -void InfoBarConfirmView::ButtonPressed(views::NativeButton* sender) { - // If you close the bar from one of these functions, make sure to use - // BeginClose() - Close() could delete us and cause the rest of the - // function to go bananas. - if (sender == ok_button_) - OKButtonPressed(); - else if (sender == cancel_button_) - CancelButtonPressed(); - - // Disable our buttons - we only want to allow users to press one, and - // leaving them enabled could allow further interaction during the close - // animation. - if (ok_button_) - ok_button_->SetEnabled(false); - if (cancel_button_) - cancel_button_->SetEnabled(false); -} - -void InfoBarConfirmView::SetOKButtonLabel(const std::wstring& label) { - if (ok_button_) { - ok_button_->SetLabel(label); - ok_button_->SetAccessibleName(label); - Layout(); - } -} - -void InfoBarConfirmView::SetCancelButtonLabel(const std::wstring& label) { - if (cancel_button_) { - cancel_button_->SetLabel(label); - cancel_button_->SetAccessibleName(label); - Layout(); - } -} - -void InfoBarConfirmView::RemoveCancelButton() { - if (cancel_button_) { - RemoveChildView(cancel_button_); - delete cancel_button_; - cancel_button_ = NULL; - Layout(); - } -} - -void InfoBarConfirmView::RemoveOKButton() { - if (ok_button_) { - RemoveChildView(ok_button_); - delete ok_button_; - ok_button_ = NULL; - Layout(); - } -} - -bool InfoBarConfirmView::GetAccessibleRole(VARIANT* role) { - DCHECK(role); - - role->vt = VT_I4; - role->lVal = ROLE_SYSTEM_GROUPING; - return true; -} - -void InfoBarConfirmView::Init() { - ok_button_ = new views::NativeButton(l10n_util::GetString(IDS_OK)); - ok_button_->SetListener(this); - - cancel_button_ = new views::NativeButton(l10n_util::GetString(IDS_CANCEL)); - cancel_button_->SetListener(this); - AddChildViewTrailing(cancel_button_, kRelatedButtonHSpacing); - AddChildViewTrailing(ok_button_); -} diff --git a/chrome/browser/views/info_bar_confirm_view.h b/chrome/browser/views/info_bar_confirm_view.h deleted file mode 100644 index 586e734..0000000 --- a/chrome/browser/views/info_bar_confirm_view.h +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_VIEWS_INFO_BAR_CONFIRM_VIEW_H__ -#define CHROME_BROWSER_VIEWS_INFO_BAR_CONFIRM_VIEW_H__ - -#include "chrome/browser/views/info_bar_message_view.h" -#include "chrome/views/native_button.h" - -// An info bar with a message, two buttons (labeled OK and Cancel by -// default), and a close button. Can be inherited to override the behavior -// of button presses. -class InfoBarConfirmView : public InfoBarMessageView, - public views::NativeButton::Listener { - public: - explicit InfoBarConfirmView(const std::wstring& message); - - virtual ~InfoBarConfirmView(); - - // Invoked when the OK button is pressed. Closes info bar by default. - virtual void OKButtonPressed(); - - // Invoked when the Cancel button is pressed. Closes info bar by default. - virtual void CancelButtonPressed(); - - // ButtonListener Method: - // Invokes OKButtonPressed or CancelButtonPressed() when their - // respective buttons are pressed. - virtual void ButtonPressed(views::NativeButton* sender); - - // Sets the label on the OK button, if it exists. - void SetOKButtonLabel(const std::wstring& label); - - // Sets the label on the Cancel button, if it exists. - void SetCancelButtonLabel(const std::wstring& label); - - // Removes the cancel button from the info bar. - // Can't be re-added. - void RemoveCancelButton(); - - // Removes the OK button from the info bar. - // Can't be re-added. - void RemoveOKButton(); - - // Returns the MSAA role of the current view. The role is what assistive - // technologies (ATs) use to determine what behavior to expect from a given - // control. - bool GetAccessibleRole(VARIANT* role); - - private: - // Creates the ok and cancel buttons. And then calls the InfoBarMessageViews - // init to set up the message and close buttons which will - // then call AddAllChildViews. - void Init(); - - views::NativeButton* ok_button_; - - views::NativeButton* cancel_button_; - - DISALLOW_EVIL_CONSTRUCTORS(InfoBarConfirmView); -}; - -#endif // CHROME_BROWSER_VIEWS_INFO_BAR_CONFIRM_VIEW_H__ diff --git a/chrome/browser/views/info_bar_item_view.cc b/chrome/browser/views/info_bar_item_view.cc deleted file mode 100644 index 843f92e..0000000 --- a/chrome/browser/views/info_bar_item_view.cc +++ /dev/null @@ -1,289 +0,0 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/app/theme/theme_resources.h" -#include "chrome/browser/views/info_bar_item_view.h" -#include "chrome/browser/views/standard_layout.h" -#include "chrome/common/l10n_util.h" -#include "chrome/common/resource_bundle.h" -#include "chrome/views/external_focus_tracker.h" -#include "chrome/views/image_view.h" -#include "chrome/views/root_view.h" -#include "chrome/views/widget.h" - -#include "generated_resources.h" - -namespace { - -class HorizontalSpacer : public views::View { - public: - explicit HorizontalSpacer(int width) : width_(width) {} - - gfx::Size GetPreferredSize() { - return gfx::Size(width_, 0); - } - - private: - int width_; -}; - -const int kInfoBarVerticalSpacing = 3; -const int kInfoBarLeftMargin = 3; -const double kInfoBarHeight = 37.0; - -} // namespace - -InfoBarItemView::InfoBarItemView() - : insert_index_(0), - close_button_(NULL), - icon_(NULL) { - Init(); -} - -InfoBarItemView::~InfoBarItemView() { -} - -// static -int InfoBarItemView::CenterPosition(int size, int target_size) { - return (target_size - size) / 2; -} - -gfx::Size InfoBarItemView::GetPreferredSize() { - return gfx::Size( - GetParent()->width(), - static_cast<int>(kInfoBarHeight * animation_->GetCurrentValue())); -} - -// The following is an overall note on the underlying implementation. You don't -// need this in order to use this view. Ignore unless you're editing -// implementation: -// Layout() lays out all of its child views, but it uses insert_index_ to -// decide whether to lay out on the left or right. Whenever a view is added or -// removed the insert_index_ is updated accordingly to make sure it is directly -// between left aligned views and right aligned views. Whenever a view is added, -// a spacer view provides padding to the right of the view if the view is -// left aligned, or to the left of the view if the view is right aligned. -// Removing assumes this spacer view exists. -// -// For example, below M stands for built in margins, I stands for the icon -// which is optional and includes padding of its own. L stands for a left -// aligned view, and R for a right aligned view. P is padding, which can be -// zero. The insert index is currently 4, separating the right of left views. -// The numbers represent what index the child views P, R, and L occupy. -// -// M I L P L P P R P R M -// 0 1 2 3 ^4 5 6 7 -// Say we call AddChildViewTrailing(right_view, 10). We end up with: -// M I L P L P P R P R P R M -// 0 1 2 3 ^4 5 6 7 8 9 -// First the right view was added, then its padding was added, the insert index -// did not need to change because it still separates the right and left views. -// Note that the padding showed up at the lower index, or to the left of the -// right aligned view. -// Then we call AddChildViewLeading(left_view, 0). We end up with: -// M I L P L P L P P R P R P R M -// 0 1 2 3 4 5 ^6 7 8 9 10 11 -// First the left view was added, then the insert_index_ was incremented, then -// the padding is added, even though it is zero (It has no effect on layout) -// and insert_index_ is incremented again to keep it between the right and -// left views. Note in this case, the padding appears to the right of the view -// left aligned view. Removing works the same, but in reverse. -void InfoBarItemView::Layout() { - int next_x = width() - kButtonHEdgeMargin; - int height_diff = static_cast<int>(kInfoBarHeight) - height(); - const int child_count = GetChildViewCount(); - // Anything greater than or equal to insert_index_ is laid out on the right, - // with the greatest index (the first one added to the right) being laid out - // rightmost. - for (int i = child_count - 1; i >= insert_index_ ; i--) { - View* v = GetChildViewAt(i); - if (v->IsVisible()) { - gfx::Size view_size = v->GetPreferredSize(); - next_x = next_x - view_size.width(); - v->SetBounds(next_x, - CenterPosition(view_size.height(), - static_cast<int>(kInfoBarHeight)) - height_diff, - view_size.width(), - view_size.height()); - } - } - int left_most_x = next_x; - - next_x = kInfoBarLeftMargin; - - // Anything less than insert_index_ is laid out on the left, with the - // smallest index (the first one added to the left) being laid out leftmost. - for (int i = 0; i < insert_index_ ; i++) { - View* v = GetChildViewAt(i); - if (v->IsVisible()) { - gfx::Size view_size = v->GetPreferredSize(); - int remaining_space = std::max(0, left_most_x - next_x); - if (view_size.width() > remaining_space) { - view_size.set_width(remaining_space); - } - v->SetBounds(next_x, - CenterPosition(view_size.height(), - static_cast<int>(kInfoBarHeight)) - height_diff, - view_size.width(), - view_size.height()); - next_x = next_x + view_size.width(); - } - } -} - -void InfoBarItemView::DidChangeBounds(const gfx::Rect& previous, - const gfx::Rect& current) { - if (GetParent() != NULL) - Layout(); -} - -void InfoBarItemView::BeginClose() { - animation_->Hide(); -} - -void InfoBarItemView::Close() { - views::View* parent = GetParent(); - parent->RemoveChildView(this); - if (focus_tracker_.get() != NULL) - focus_tracker_->FocusLastFocusedExternalView(); - delete this; -} - -void InfoBarItemView::CloseButtonPressed() { - // Close this view by default. - BeginClose(); -} - -void InfoBarItemView::AddChildViewTrailing(views::View* view, - int leading_padding) { - views::View::AddChildView(insert_index_, view); - View* padding = new HorizontalSpacer(leading_padding); - views::View::AddChildView(insert_index_, padding); -} - -void InfoBarItemView::AddChildViewTrailing(views::View* view) { - AddChildViewTrailing(view, kUnrelatedControlHorizontalSpacing); -} - -void InfoBarItemView::AddChildViewLeading(views::View* view, - int trailing_padding) { - views::View::AddChildView(insert_index_, view); - insert_index_++; - View* padding = new HorizontalSpacer(trailing_padding); - views::View::AddChildView(insert_index_, padding); - insert_index_++; -} - -void InfoBarItemView::AddChildViewLeading(views::View* view) { - AddChildViewLeading(view, kRelatedControlSmallHorizontalSpacing); -} - -void InfoBarItemView::SetIcon(const SkBitmap& icon) { - if (icon_ == NULL) { - // Add the icon and its padding to the far left of the info bar, and adjust - // the insert index accordingly. - icon_ = new views::ImageView(); - View* padding = new HorizontalSpacer(kRelatedControlHorizontalSpacing); - views::View::AddChildView(0, padding); - views::View::AddChildView(0, icon_); - insert_index_ += 2; - } - icon_->SetImage(icon); - Layout(); -} - -void InfoBarItemView::ViewHierarchyChanged(bool is_add, - View *parent, - View *child) { - if (child == this) { - if (is_add) { - Layout(); - - View* root_view = GetRootView(); - HWND root_hwnd = NULL; - if (root_view) - root_hwnd = root_view->GetWidget()->GetHWND(); - - if (root_hwnd) { - focus_tracker_.reset(new views::ExternalFocusTracker( - this, views::FocusManager::GetFocusManager(root_hwnd))); - } - } else { - // When we're removed from the hierarchy our focus manager is no longer - // valid. - if (focus_tracker_.get() != NULL) - focus_tracker_->SetFocusManager(NULL); - } - } -} - -void InfoBarItemView::AddChildView(views::View* view) { - AddChildViewTrailing(view, kUnrelatedControlHorizontalSpacing); -} - -void InfoBarItemView::AddChildView(int index, views::View* view) { - if (index < insert_index_) - AddChildViewLeading(view); - else - AddChildViewTrailing(view); -} - -void InfoBarItemView::RemoveChildView(views::View* view) { - int index = GetChildIndex(view); - if (index >= 0) { - if (index < insert_index_) { - // We're removing a leading view. So the view at index + 1 (immediately - // trailing) is the corresponding spacer view. - View* spacer_view = GetChildViewAt(index + 1); - views::View::RemoveChildView(view); - views::View::RemoveChildView(spacer_view); - delete spacer_view; - // Need to change the insert_index_ so it is still pointing at the - // "middle" index between left and right aligned views. - insert_index_ -= 2; - } else { - // We're removing a trailing view. So the view at index - 1 (immediately - // leading) is the corresponding spacer view. - View* spacer_view = GetChildViewAt(index - 1); - views::View::RemoveChildView(view); - views::View::RemoveChildView(spacer_view); - delete spacer_view; - } - } -} - -void InfoBarItemView::ButtonPressed(views::BaseButton* button) { - if (button == close_button_) - CloseButtonPressed(); -} - -void InfoBarItemView::AnimationProgressed(const Animation* animation) { - static_cast<InfoBarView*>(GetParent())->ChildAnimationProgressed(); -} - -void InfoBarItemView::AnimationEnded(const Animation* animation) { - static_cast<InfoBarView*>(GetParent())->ChildAnimationEnded(); - - if (!animation_->IsShowing()) - Close(); -} - -void InfoBarItemView::Init() { - ResourceBundle &rb = ResourceBundle::GetSharedInstance(); - close_button_ = new views::Button(); - close_button_->SetImage(views::Button::BS_NORMAL, - rb.GetBitmapNamed(IDR_CLOSE_BAR)); - close_button_->SetImage(views::Button::BS_HOT, - rb.GetBitmapNamed(IDR_CLOSE_BAR_H)); - close_button_->SetImage(views::Button::BS_PUSHED, - rb.GetBitmapNamed(IDR_CLOSE_BAR_P)); - close_button_->SetListener(this, 0); - close_button_->SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_CLOSE)); - AddChildViewTrailing(close_button_); - - animation_.reset(new SlideAnimation(this)); - animation_->SetTweenType(SlideAnimation::NONE); - animation_->Show(); -} - diff --git a/chrome/browser/views/info_bar_item_view.h b/chrome/browser/views/info_bar_item_view.h deleted file mode 100644 index 7c42478..0000000 --- a/chrome/browser/views/info_bar_item_view.h +++ /dev/null @@ -1,140 +0,0 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_VIEWS_INFO_BAR_ITEM_VIEW_H__ -#define CHROME_BROWSER_VIEWS_INFO_BAR_ITEM_VIEW_H__ - -#include "chrome/browser/views/info_bar_view.h" -#include "chrome/common/slide_animation.h" -#include "chrome/views/button.h" - -namespace views { -class ExternalFocusTracker; -class ImageView; -} -// Note: An InfoBarItemView must be added as a child of InfoBarView to be -// displayed correctly. -// -// InfoBarItemView is basically a view container that lays out views in a -// horizontal row, on either the left or the right, with specified padding. It -// has a close button on the far right, which can't be removed, and closes the -// info bar by default. An icon can be set to be displayed leading all other -// views by calling SetIcon(). -// -// A view can be added to either the left or the right of the info bar by -// calling AddChildViewTrailing and AddChildViewLeading. -// -// The most recently added views to either side will always be located further -// towards the center than views added less recently, with the first views added -// to the left or right being located on the leftmost or rightmost sides of the -// info bar, respectively. Each view has a default spacing from the next -// view added to that side, but you can edit that by specifying a padding when -// you add a view. For example, if you add a view to the left with a padding of -// 6 specified, it will be placed in the leftmost position, and the next view -// added to the left will be 6 pixels to the right of the previously added view. -class InfoBarItemView : public views::View, - public views::BaseButton::ButtonListener, - public AnimationDelegate { - public: - InfoBarItemView(); - - virtual ~InfoBarItemView(); - - // The preferred height is equal to the maximum height of all views - // in the info bar. Preferred width is equal to the parents width. - virtual gfx::Size GetPreferredSize(); - - // Lays out all child views of the info bar from trailing to leading. - virtual void Layout(); - - virtual void DidChangeBounds(const gfx::Rect& previous, - const gfx::Rect& current); - - // Starts the close animation, which will end in the bar closing itself. - void BeginClose(); - - // Removes this InfoBarItem from its parent view and then deletes it. - void Close(); - - // ButtonListener Method - // Calls CloseButtonPressed() when the close button is pressed - virtual void ButtonPressed(views::BaseButton* button); - - // Adds |view| to the info bar, directly leading the last trailing view - // added, according to that views specified padding. The next trailing view - // added will in turn be leading this view by |leading_padding| pixels. - // Specify 0 for |leading_padding| if the views should be flush. - void AddChildViewTrailing(views::View* view, int leading_padding); - - // Calls AddChildViewTrailing with a default amount of padding. - void AddChildViewTrailing(views::View* view); - - // Adds |view| to the info bar, directly trailing the last leading view - // added, according to that views specified padding. The next leading view - // added will in turn be trailing this view by |trailing_padding| pixels. - // Specify 0 for |trailing_padding| if the views should be flush. - void AddChildViewLeading(views::View* view, int trailing_padding); - - // Calls AddChildViewLeading with a default amount of padding. - void AddChildViewLeading(views::View* view); - - // Sets the icon to be displayed leading all other views in the info bar. - // The icon will be displayed at its images height and width by default. - void SetIcon(const SkBitmap& icon); - - protected: - // Returns the desired position for a centered object of size |size| within - // a region of size |target_size|. - static int CenterPosition(int size, int target_size); - - virtual void ViewHierarchyChanged(bool is_add, View *parent, View *child); - - // Overridden from the basic Views AddChildView. Calls - // AddChildViewTrailing(view) - virtual void AddChildView(views::View* view); - - // Overridden from basic View. Adds the view to the same side as the view - // at index. Does *not* insert at the specified index, or even neccesarily - // close to it. - virtual void AddChildView(int index, views::View* view); - - // Overridden from the basic Views AddChildView, removes the specified view - // as well as its padding. - virtual void RemoveChildView(views::View* view); - - // Invoked whenever the close button is pressed. Closes infobar by default. - virtual void CloseButtonPressed(); - - private: - // Creates cancel button. - void Init(); - - // SlideAnimationDelegate implementation. - virtual void AnimationProgressed(const Animation* animation); - virtual void AnimationEnded(const Animation* animation); - - scoped_ptr<SlideAnimation> animation_; - - // View index where all new views will be inserted. Any view at an index less - // than insert_index will be laid out will be leading views (left aligned in - // left to right languages), any view greater than or equal to insert_index_ - // will be laid out trailing (right aligned in left to right languages). - int insert_index_; - - // Dismisses the info bar by default. - views::Button* close_button_; - - // Optional icon to be displayed at the far left of the infobar. - views::ImageView* icon_; - - // Tracks and stores the last focused view which is not the InfoBarItemView or - // any of its children. Used to restore focus once the InfoBarItemView is - // closed. - scoped_ptr<views::ExternalFocusTracker> focus_tracker_; - - DISALLOW_EVIL_CONSTRUCTORS(InfoBarItemView); -}; - -#endif // CHROME_BROWSER_VIEWS_INFO_BAR_ITEM_VIEW_H__ - diff --git a/chrome/browser/views/info_bar_message_view.cc b/chrome/browser/views/info_bar_message_view.cc deleted file mode 100644 index 7c9cfbb..0000000 --- a/chrome/browser/views/info_bar_message_view.cc +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/views/info_bar_message_view.h" -#include "chrome/common/resource_bundle.h" -#include "chrome/views/label.h" - -InfoBarMessageView::InfoBarMessageView(const std::wstring& message) - : message_string_(message), - message_label_(NULL) { - Init(); -} - -InfoBarMessageView::InfoBarMessageView(views::Label* message) - : message_string_(), - message_label_(message) { - Init(); -} - -InfoBarMessageView::~InfoBarMessageView() {} - -void InfoBarMessageView::SetMessageText(const std::wstring& message) { - message_label_->SetText(message); - Layout(); -} - -std::wstring InfoBarMessageView::GetMessageText() { - return message_label_->GetText(); -} - -void InfoBarMessageView::Init() { - if (message_label_ == NULL) { - message_label_ = new views::Label(message_string_); - message_label_->SetFont( - ResourceBundle::GetSharedInstance().GetFont(ResourceBundle::MediumFont)); - } else { - message_string_ = message_label_->GetText(); - } - - AddChildViewLeading(message_label_); -} diff --git a/chrome/browser/views/info_bar_message_view.h b/chrome/browser/views/info_bar_message_view.h deleted file mode 100644 index 67be918..0000000 --- a/chrome/browser/views/info_bar_message_view.h +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_VIEWS_INFO_BAR_MESSAGE_VIEW_H__ -#define CHROME_BROWSER_VIEWS_INFO_BAR_MESSAGE_VIEW_H__ - -#include "chrome/browser/views/info_bar_item_view.h" -#include "chrome/views/label.h" - -// A generic message for the info bar. Displays a label and a close button. -// Can be inherited to override the default behavior of the close button, which -// closes and deletes the info bar by default. -class InfoBarMessageView : public InfoBarItemView { - - public: - explicit InfoBarMessageView(const std::wstring& message); - - explicit InfoBarMessageView(views::Label* message); - - virtual ~InfoBarMessageView(); - - void SetMessageText(const std::wstring& message); - - std::wstring GetMessageText(); - - private: - // Creates message label. - void Init(); - - std::wstring message_string_; - - views::Label* message_label_; - - DISALLOW_EVIL_CONSTRUCTORS(InfoBarMessageView); -}; - -#endif // CHROME_BROWSER_VIEWS_INFO_BAR_MESSAGE_VIEW_H__ diff --git a/chrome/browser/views/info_bar_view.cc b/chrome/browser/views/info_bar_view.cc deleted file mode 100644 index 116a00b..0000000 --- a/chrome/browser/views/info_bar_view.cc +++ /dev/null @@ -1,233 +0,0 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/views/info_bar_view.h" - -#include "base/logging.h" -#include "chrome/browser/navigation_controller.h" -#include "chrome/browser/navigation_entry.h" -#include "chrome/browser/tab_contents_delegate.h" -#include "chrome/browser/web_contents.h" -#include "chrome/browser/web_contents_view.h" -#include "chrome/common/gfx/chrome_canvas.h" -#include "chrome/common/l10n_util.h" -#include "chrome/common/resource_bundle.h" -#include "chrome/views/background.h" - -#include "generated_resources.h" - -// Color for the separator. -static const SkColor kSeparatorColor = SkColorSetRGB(165, 165, 165); - -// Default background color for the info bar. -static const SkColor kBackgroundColorTop = SkColorSetRGB(255, 242, 183); -static const SkColor kBackgroundColorBottom = SkColorSetRGB(250, 230, 145); - -static const SkColor kBorderColorTop = SkColorSetRGB(240, 230, 170); -static const SkColor kBorderColorBottom = SkColorSetRGB(236, 216, 133); - -// Height of the separator. -static const int kSeparatorHeight = 1; - -InfoBarView::InfoBarView(WebContents* web_contents) - : web_contents_(web_contents) { - Init(); - NotificationService::current()->AddObserver( - this, NOTIFY_NAV_ENTRY_COMMITTED, - Source<NavigationController>(web_contents_->controller())); -} - -InfoBarView::~InfoBarView() { - NotificationService::current()->RemoveObserver( - this, NOTIFY_NAV_ENTRY_COMMITTED, - Source<NavigationController>(web_contents_->controller())); -} - -void InfoBarView::AppendInfoBarItem(views::View* view, bool auto_expire) { - // AddChildView adds an entry to expire_map_ for view. - AddChildView(view); - if (auto_expire) - expire_map_[view] = GetActiveID(); - else - expire_map_.erase(expire_map_.find(view)); -} - -// Preferred size is equal to the max of the childrens horizontal sizes -// and the sum of their vertical sizes. -gfx::Size InfoBarView::GetPreferredSize() { - gfx::Size prefsize; - - // We count backwards so the most recently added view is on the top. - for (int i = GetChildViewCount() - 1; i >= 0; i--) { - View* v = GetChildViewAt(i); - if (v->IsVisible()) { - prefsize.set_width(std::max(prefsize.width(), v->width())); - prefsize.Enlarge(0, v->GetPreferredSize().height() + kSeparatorHeight); - } - } - - return prefsize; -} - -void InfoBarView::Layout() { - int x = 0; - int y = height(); - - // We lay the bars out from bottom to top. - for (int i = 0; i < GetChildViewCount(); ++i) { - View* v = GetChildViewAt(i); - if (!v->IsVisible()) - continue; - - gfx::Size view_size = v->GetPreferredSize(); - int view_width = std::max(view_size.width(), width()); - y = y - view_size.height() - kSeparatorHeight; - v->SetBounds(x, y, view_width, view_size.height()); - } -} - -void InfoBarView::Paint(ChromeCanvas* canvas) { - PaintBackground(canvas); - PaintBorder(canvas); - PaintSeparators(canvas); -} - -void InfoBarView::ChildAnimationProgressed() { - if (web_contents_) - web_contents_->ToolbarSizeChanged(true); -} - -void InfoBarView::ChildAnimationEnded() { - if (web_contents_) - web_contents_->ToolbarSizeChanged(false); -} - -void InfoBarView::ViewHierarchyChanged(bool is_add, View *parent, - View *child) { - if (parent == this && child->GetParent() == this) { - // ViewHierarchyChanged is actually called before a child is removed. - // So set child to not be visible so it isn't included in the layout. - if (!is_add) { - child->SetVisible(false); - - // If there's an entry in the expire map, nuke it. - std::map<View*,int>::iterator i = expire_map_.find(child); - if (i != expire_map_.end()) - expire_map_.erase(i); - } else { - expire_map_[child] = GetActiveID(); - } - - // TODO(brettw) clean up the ownership of this info bar. It should be owned - // by the web contents view instead. In the meantime, we assume we're owned - // by a WebContents. - if (web_contents_->AsWebContents()->view()->IsInfoBarVisible()) { - web_contents_->ToolbarSizeChanged(false); - } else { - web_contents_->view()->SetInfoBarVisible(true); - } - } -} - -void InfoBarView::Init() { - set_background( - views::Background::CreateVerticalGradientBackground( - kBackgroundColorTop, kBackgroundColorBottom)); -} - -int InfoBarView::GetActiveID() const { - if (!web_contents_) - return 0; - - // The WebContents is guaranteed to have a controller. - const NavigationEntry* const entry = - web_contents_->controller()->GetActiveEntry(); - return entry ? entry->unique_id() : 0; -} - -void InfoBarView::PaintBorder(ChromeCanvas* canvas) { - canvas->FillRectInt(kBorderColorTop, 0, 0, width(), 1); - canvas->FillRectInt(kBorderColorBottom, - 0, height() - kSeparatorHeight - 1, - width(), kSeparatorHeight); - - if (GetChildViewCount() > 0) - canvas->FillRectInt(kSeparatorColor, 0, height() - kSeparatorHeight, - width(), kSeparatorHeight); -} - -void InfoBarView::PaintSeparators(ChromeCanvas* canvas) { - views::View* last_view = NULL; - for (int i = GetChildViewCount() - 1; i >= 0; i--) { - views::View* view = GetChildViewAt(i); - if (last_view != NULL) { - if (view->IsVisible()) { - PaintSeparator(canvas, last_view, view); - } else { - // We aren't interested in views we can't see. - continue; - } - } - last_view = view; - } -} - -void InfoBarView::PaintSeparator(ChromeCanvas* canvas, - views::View* v1, - views::View* v2) { - canvas->FillRectInt(kSeparatorColor, - 0, - v2->y() - kSeparatorHeight, - width(), - kSeparatorHeight); -} - -void InfoBarView::Observe(NotificationType type, - const NotificationSource& source, - const NotificationDetails& in_details) { - // We should get only commit notifications from our controller. - DCHECK(type == NOTIFY_NAV_ENTRY_COMMITTED); - DCHECK(web_contents_->controller() == - Source<NavigationController>(source).ptr()); - - NavigationController::LoadCommittedDetails& details = - *(Details<NavigationController::LoadCommittedDetails>(in_details).ptr()); - - // Only hide infobars when the user has done something that makes the main - // frame load. We don't want various automatic or subframe navigations making - // it disappear. - if (!details.is_user_initiated_main_frame_load()) - return; - - // Determine the views to remove first. - std::vector<views::View*> to_remove; - for (std::map<View*,int>::iterator i = expire_map_.begin(); - i != expire_map_.end(); ++i) { - if (PageTransition::StripQualifier(details.entry->transition_type()) == - PageTransition::RELOAD || - i->second != details.entry->unique_id()) - to_remove.push_back(i->first); - } - - if (to_remove.empty()) - return; - - // Remove the views. - for (std::vector<views::View*>::iterator i = to_remove.begin(); - i != to_remove.end(); ++i) { - // RemoveChildView takes care of removing from expire_map for us. - RemoveChildView(*i); - - // We own the child and we're removing it, need to delete it. - delete *i; - } - - if (GetChildViewCount() == 0) { - // All our views have been removed, no need to stay visible. - web_contents_->view()->SetInfoBarVisible(false); - } else if (web_contents_) { - // This triggers a layout. - web_contents_->ToolbarSizeChanged(false); - } -} diff --git a/chrome/browser/views/info_bar_view.h b/chrome/browser/views/info_bar_view.h deleted file mode 100644 index 52a761d..0000000 --- a/chrome/browser/views/info_bar_view.h +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_VIEWS_INFO_BAR_VIEW_H_ -#define CHROME_BROWSER_VIEWS_INFO_BAR_VIEW_H_ - -#include <map> - -#include "chrome/common/notification_service.h" -#include "chrome/views/view.h" - -class NavigationEntry; -class WebContents; - -// This view is used to store and display views in the info bar. -// -// It will paint all of its children vertically, with the most recently -// added child displayed at the top of the info bar. -class InfoBarView : public views::View, - public NotificationObserver { - public: - explicit InfoBarView(WebContents* web_contents); - - virtual ~InfoBarView(); - - // Adds view as a child. Views adding using AddChildView() are automatically - // removed after 1 navigation, which is also the behavior if you set - // |auto_expire| to true here. You mainly need this function if you want to - // add an infobar that should not expire. - void AppendInfoBarItem(views::View* view, bool auto_expire); - - virtual gfx::Size GetPreferredSize(); - - virtual void Layout(); - - // API to allow infobar children to notify us of size changes. - virtual void ChildAnimationProgressed(); - virtual void ChildAnimationEnded(); - - // Invokes the following methods to do painting: - // PaintBackground, PaintBorder and PaintSeparators. - virtual void Paint(ChromeCanvas* canvas); - - WebContents* web_contents() { return web_contents_; } - - protected: - // Overridden to force the frame to re-layout the info bar whenever a view - // is added or removed. - virtual void ViewHierarchyChanged(bool is_add, View *parent, View *child); - - private: - void Init(); - - // Returns the unique ID of the active entry on the WebContents' - // NavigationController. - int GetActiveID() const; - - // Paints the border. - void PaintBorder(ChromeCanvas* canvas); - - // Paints the separators. This invokes PaintSeparator to paint a particular - // separator. - void PaintSeparators(ChromeCanvas* canvas); - - // Paints the separator between views. - void PaintSeparator(ChromeCanvas* canvas, - views::View* v1, - views::View* v2); - - // NotificationObserver implementation. - virtual void Observe(NotificationType type, - const NotificationSource& source, - const NotificationDetails& details); - - WebContents* web_contents_; - - // Map from view to number of navigations before it is removed. If a child - // doesn't have an entry in here, it is NOT removed on navigations. - std::map<View*,int> expire_map_; - - DISALLOW_COPY_AND_ASSIGN(InfoBarView); -}; - -#endif // CHROME_BROWSER_VIEWS_INFO_BAR_VIEW_H_ - diff --git a/chrome/browser/web_contents_view.h b/chrome/browser/web_contents_view.h index c197c00..2bf1ac7 100644 --- a/chrome/browser/web_contents_view.h +++ b/chrome/browser/web_contents_view.h @@ -16,7 +16,6 @@ #include "chrome/browser/render_view_host_delegate.h" class Browser; -class InfoBarView; class RenderViewHost; class RenderWidgetHost; class RenderWidgetHostView; @@ -77,26 +76,6 @@ class WebContentsView : public RenderViewHostDelegate::View { // implement functions that way rather than adding stuff here. virtual void OnContentsDestroy() = 0; - // Displays the given error in the info bar. A new info bar will be shown if - // one is not shown already. The new error text will replace any existing - // text shown by this same function. - // - // Note: this replacement behavior is historical; crashed plugin and out of - // JS memory used the same message. This seems reasonable, but it may not be - // the best thing for all error messages. - virtual void DisplayErrorInInfoBar(const std::wstring& text) = 0; - - // Set/get whether or not the info bar is visible. See also the ChromeFrame - // method InfoBarVisibilityChanged and TabContents::IsInfoBarVisible. - virtual void SetInfoBarVisible(bool visible) = 0; - virtual bool IsInfoBarVisible() const = 0; - - // Create the InfoBarView and returns it if none has been created. - // Just returns existing InfoBarView if it is already created. - // TODO(brettw) this probably shouldn't be here. There should be methods to - // tell us what we need to display instead. - virtual InfoBarView* GetInfoBarView() = 0; - // Sets the page title for the native widgets corresponding to the view. This // is not strictly necessary and isn't expected to be displayed anywhere, but // can aid certain debugging tools such as Spy++ on Windows where you are diff --git a/chrome/browser/web_contents_view_win.cc b/chrome/browser/web_contents_view_win.cc index 64f7c95..e29e0c5 100644 --- a/chrome/browser/web_contents_view_win.cc +++ b/chrome/browser/web_contents_view_win.cc @@ -16,8 +16,6 @@ #include "chrome/browser/render_widget_host_view_win.h" #include "chrome/browser/tab_contents_delegate.h" #include "chrome/browser/views/find_bar_win.h" -#include "chrome/browser/views/info_bar_message_view.h" -#include "chrome/browser/views/info_bar_view.h" #include "chrome/browser/views/sad_tab_view.h" #include "chrome/browser/web_contents.h" #include "chrome/browser/web_drag_source.h" @@ -41,8 +39,6 @@ BOOL CALLBACK DetachPluginWindowsCallback(HWND window, LPARAM param) { WebContentsViewWin::WebContentsViewWin(WebContents* web_contents) : web_contents_(web_contents), - error_info_bar_message_(NULL), - info_bar_visible_(false), ignore_next_char_event_(false) { } @@ -168,16 +164,6 @@ void WebContentsViewWin::OnContentsDestroy() { find_bar_->Close(); } -void WebContentsViewWin::DisplayErrorInInfoBar(const std::wstring& text) { - InfoBarView* view = GetInfoBarView(); - if (-1 == view->GetChildIndex(error_info_bar_message_)) { - error_info_bar_message_ = new InfoBarMessageView(text); - view->AddChildView(error_info_bar_message_); - } else { - error_info_bar_message_->SetMessageText(text); - } -} - void WebContentsViewWin::OnDestroy() { if (drop_target_.get()) { RevokeDragDrop(GetHWND()); @@ -185,32 +171,6 @@ void WebContentsViewWin::OnDestroy() { } } -void WebContentsViewWin::SetInfoBarVisible(bool visible) { - if (info_bar_visible_ != visible) { - info_bar_visible_ = visible; - if (info_bar_visible_) { - // Invoke GetInfoBarView to force the info bar to be created. - GetInfoBarView(); - } - web_contents_->ToolbarSizeChanged(false); - } -} - -bool WebContentsViewWin::IsInfoBarVisible() const { - return info_bar_visible_; -} - -InfoBarView* WebContentsViewWin::GetInfoBarView() { - if (info_bar_view_.get() == NULL) { - // TODO(brettw) currently the InfoBar thinks its owned by the WebContents, - // but it should instead think it's owned by us. - info_bar_view_.reset(new InfoBarView(web_contents_)); - // We own the info-bar. - info_bar_view_->SetParentOwned(false); - } - return info_bar_view_.get(); -} - void WebContentsViewWin::SetPageTitle(const std::wstring& title) { if (GetContainerHWND()) { // It's possible to get this after the hwnd has been destroyed. diff --git a/chrome/browser/web_contents_view_win.h b/chrome/browser/web_contents_view_win.h index 4b9d1fb..0956bc2 100644 --- a/chrome/browser/web_contents_view_win.h +++ b/chrome/browser/web_contents_view_win.h @@ -11,8 +11,6 @@ #include "chrome/views/widget_win.h" class FindBarWin; -class InfoBarView; -class InfoBarMessageView; class SadTabView; struct WebDropData; class WebDropTarget; @@ -38,10 +36,6 @@ class WebContentsViewWin : public WebContentsView, virtual HWND GetContentHWND() const; virtual void GetContainerBounds(gfx::Rect* out) const; virtual void OnContentsDestroy(); - virtual void DisplayErrorInInfoBar(const std::wstring& text); - virtual void SetInfoBarVisible(bool visible); - virtual bool IsInfoBarVisible() const; - virtual InfoBarView* GetInfoBarView(); virtual void SetPageTitle(const std::wstring& title); virtual void Invalidate(); virtual void SizeContents(const gfx::Size& size); @@ -121,21 +115,10 @@ class WebContentsViewWin : public WebContentsView, // A drop target object that handles drags over this WebContents. scoped_refptr<WebDropTarget> drop_target_; - // InfoBarView, lazily created. - scoped_ptr<InfoBarView> info_bar_view_; - // Used to render the sad tab. This will be non-NULL only when the sad tab is // visible. scoped_ptr<SadTabView> sad_tab_; - // Info bar for crashed plugin message. - // IMPORTANT: This instance is owned by the InfoBarView. It is valid - // only if InfoBarView::GetChildIndex for this view is valid. - InfoBarMessageView* error_info_bar_message_; - - // Whether the info bar view is visible. - bool info_bar_visible_; - // Whether to ignore the next CHAR keyboard event. bool ignore_next_char_event_; |