summaryrefslogtreecommitdiffstats
path: root/chrome/browser/views
diff options
context:
space:
mode:
authorfinnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-13 18:15:01 +0000
committerfinnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-13 18:15:01 +0000
commit751cef05106cef2269e2d2e2383b6627f4b20318 (patch)
treee2937cea1b816a9dd998a24a539ffea03b375d27 /chrome/browser/views
parent08fb74a9f12f59c531cc5d7acdb0afea183dba12 (diff)
downloadchromium_src-751cef05106cef2269e2d2e2383b6627f4b20318.zip
chromium_src-751cef05106cef2269e2d2e2383b6627f4b20318.tar.gz
chromium_src-751cef05106cef2269e2d2e2383b6627f4b20318.tar.bz2
Reverting 11640.
Reverting for now. Will try again later git-svn-id: svn://svn.chromium.org/chrome/trunk/src@11645 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views')
-rw-r--r--chrome/browser/views/location_bar_view.cc218
-rw-r--r--chrome/browser/views/location_bar_view.h79
2 files changed, 75 insertions, 222 deletions
diff --git a/chrome/browser/views/location_bar_view.cc b/chrome/browser/views/location_bar_view.cc
index d759fc0..0596974 100644
--- a/chrome/browser/views/location_bar_view.cc
+++ b/chrome/browser/views/location_bar_view.cc
@@ -91,7 +91,6 @@ LocationBarView::LocationBarView(Profile* profile,
keyword_hint_view_(profile),
type_to_search_view_(l10n_util::GetString(IDS_OMNIBOX_EMPTY_TEXT)),
security_image_view_(profile, model),
- rss_image_view_(model),
popup_window_mode_(popup_window_mode),
first_run_bubble_(this) {
DCHECK(profile_);
@@ -154,10 +153,6 @@ void LocationBarView::Init() {
keyword_hint_view_.SetColor(gray);
keyword_hint_view_.SetParentOwned(false);
- AddChildView(&rss_image_view_);
- rss_image_view_.SetVisible(false);
- rss_image_view_.SetParentOwned(false);
-
AddChildView(&security_image_view_);
security_image_view_.SetVisible(false);
security_image_view_.SetParentOwned(false);
@@ -179,7 +174,6 @@ void LocationBarView::Init() {
void LocationBarView::Update(const TabContents* tab_for_state_restoring) {
SetSecurityIcon(model_->GetIcon());
- SetRssIconVisibility(model_->GetFeedList().get());
std::wstring info_text, info_tooltip;
SkColor text_color;
model_->GetInfoText(&info_text, &text_color, &info_tooltip);
@@ -189,12 +183,6 @@ void LocationBarView::Update(const TabContents* tab_for_state_restoring) {
SchedulePaint();
}
-void LocationBarView::UpdateFeedIcon() {
- SetRssIconVisibility(model_->GetFeedList().get());
- Layout();
- SchedulePaint();
-}
-
void LocationBarView::Focus() {
::SetFocus(location_entry_->m_hWnd);
}
@@ -347,16 +335,10 @@ void LocationBarView::DoLayout(const bool force_layout) {
location_entry_->GetClientRect(&edit_bounds);
int entry_width = width() - (kEntryPadding * 2);
-
- gfx::Size rss_image_size;
- if (rss_image_view_.IsVisible()) {
- rss_image_size = rss_image_view_.GetPreferredSize();
- entry_width -= rss_image_size.width();
- }
gfx::Size security_image_size;
if (security_image_view_.IsVisible()) {
security_image_size = security_image_view_.GetPreferredSize();
- entry_width -= security_image_size.width() + kInnerPadding;
+ entry_width -= security_image_size.width();
}
gfx::Size info_label_size;
if (info_label_.IsVisible()) {
@@ -383,18 +365,9 @@ void LocationBarView::DoLayout(const bool force_layout) {
location_y,
info_label_size.width(), location_height);
}
- const int info_label_width = info_label_size.width() ?
- info_label_size.width() + kInnerPadding : 0;
- if (rss_image_view_.IsVisible()) {
- rss_image_view_.SetBounds(width() - kEntryPadding -
- info_label_width -
- security_image_size.width() -
- rss_image_size.width(),
- location_y,
- rss_image_size.width(),
- location_height);
- }
if (security_image_view_.IsVisible()) {
+ const int info_label_width = info_label_size.width() ?
+ info_label_size.width() + kInnerPadding : 0;
security_image_view_.SetBounds(width() - kEntryPadding - info_label_width -
security_image_size.width(), location_y, security_image_size.width(),
location_height);
@@ -525,12 +498,6 @@ void LocationBarView::SetSecurityIcon(ToolbarModel::Icon icon) {
}
}
-void LocationBarView::SetRssIconVisibility(FeedList* feeds) {
- bool show_rss = feeds && feeds->list().size() > 0;
- // TODO(finnur): Enable this when we have a good landing page to show feeds.
- rss_image_view_.SetVisible(false);
-}
-
void LocationBarView::SetInfoText(const std::wstring& text,
SkColor text_color,
const std::wstring& tooltip_text) {
@@ -804,20 +771,19 @@ bool LocationBarView::ShouldLookupAccelerators(const views::KeyEvent& e) {
class LocationBarView::ShowInfoBubbleTask : public Task {
public:
- explicit ShowInfoBubbleTask(
- LocationBarView::LocationBarImageView* image_view);
+ explicit ShowInfoBubbleTask(LocationBarView::SecurityImageView* image_view);
virtual void Run();
void Cancel();
private:
- LocationBarView::LocationBarImageView* image_view_;
+ LocationBarView::SecurityImageView* image_view_;
bool cancelled_;
DISALLOW_EVIL_CONSTRUCTORS(ShowInfoBubbleTask);
};
LocationBarView::ShowInfoBubbleTask::ShowInfoBubbleTask(
- LocationBarView::LocationBarImageView* image_view)
+ LocationBarView::SecurityImageView* image_view)
: cancelled_(false),
image_view_(image_view) {
}
@@ -876,14 +842,27 @@ void LocationBarView::ShowFirstRunBubbleInternal() {
bounds);
}
-// LocationBarImageView---------------------------------------------------------
+// SecurityImageView------------------------------------------------------------
+
+// static
+SkBitmap* LocationBarView::SecurityImageView::lock_icon_ = NULL;
+SkBitmap* LocationBarView::SecurityImageView::warning_icon_ = NULL;
-LocationBarView::LocationBarImageView::LocationBarImageView()
- : show_info_bubble_task_(NULL),
- info_bubble_(NULL) {
+LocationBarView::SecurityImageView::SecurityImageView(Profile* profile,
+ ToolbarModel* model)
+ : profile_(profile),
+ model_(model),
+ show_info_bubble_task_(NULL),
+ info_bubble_(NULL) {
+ if (!lock_icon_) {
+ ResourceBundle& rb = ResourceBundle::GetSharedInstance();
+ lock_icon_ = rb.GetBitmapNamed(IDR_LOCK);
+ warning_icon_ = rb.GetBitmapNamed(IDR_WARNING);
+ }
+ SetImageShown(LOCK);
}
-LocationBarView::LocationBarImageView::~LocationBarImageView() {
+LocationBarView::SecurityImageView::~SecurityImageView() {
if (show_info_bubble_task_)
show_info_bubble_task_->Cancel();
@@ -894,41 +873,25 @@ LocationBarView::LocationBarImageView::~LocationBarImageView() {
}
}
-void LocationBarView::LocationBarImageView::OnMouseMoved(
- const views::MouseEvent& event) {
- if (show_info_bubble_task_) {
- show_info_bubble_task_->Cancel();
- show_info_bubble_task_ = NULL;
- }
-
- if (info_bubble_) {
- // If an info bubble is currently showing, nothing to do.
- return;
- }
-
- show_info_bubble_task_ = new ShowInfoBubbleTask(this);
- MessageLoop::current()->PostDelayedTask(FROM_HERE, show_info_bubble_task_,
- kInfoBubbleHoverDelayMs);
-}
-
-void LocationBarView::LocationBarImageView::OnMouseExited(
- const views::MouseEvent& event) {
- if (show_info_bubble_task_) {
- show_info_bubble_task_->Cancel();
- show_info_bubble_task_ = NULL;
+void LocationBarView::SecurityImageView::SetImageShown(Image image) {
+ switch (image) {
+ case LOCK:
+ ImageView::SetImage(lock_icon_);
+ break;
+ case WARNING:
+ ImageView::SetImage(warning_icon_);
+ break;
+ default:
+ NOTREACHED();
+ break;
}
-
- if (info_bubble_)
- info_bubble_->Close();
}
-void LocationBarView::LocationBarImageView::InfoBubbleClosing(
- InfoBubble* info_bubble, bool closed_by_escape) {
- info_bubble_ = NULL;
-}
+void LocationBarView::SecurityImageView::ShowInfoBubble() {
+ std::wstring text;
+ SkColor text_color;
+ model_->GetIconHoverText(&text, &text_color);
-void LocationBarView::LocationBarImageView::ShowInfoBubbleImpl(
- const std::wstring& text, SkColor text_color) {
gfx::Point location;
views::View::ConvertPointToScreen(this, &location);
gfx::Rect bounds(location.x(), location.y(), width(), height());
@@ -946,40 +909,32 @@ void LocationBarView::LocationBarImageView::ShowInfoBubbleImpl(
show_info_bubble_task_ = NULL;
}
-// SecurityImageView------------------------------------------------------------
-
-// static
-SkBitmap* LocationBarView::SecurityImageView::lock_icon_ = NULL;
-SkBitmap* LocationBarView::SecurityImageView::warning_icon_ = NULL;
+void LocationBarView::SecurityImageView::OnMouseMoved(
+ const views::MouseEvent& event) {
+ if (show_info_bubble_task_) {
+ show_info_bubble_task_->Cancel();
+ show_info_bubble_task_ = NULL;
+ }
-LocationBarView::SecurityImageView::SecurityImageView(Profile* profile,
- ToolbarModel* model)
- : LocationBarImageView(),
- profile_(profile),
- model_(model) {
- if (!lock_icon_) {
- ResourceBundle& rb = ResourceBundle::GetSharedInstance();
- lock_icon_ = rb.GetBitmapNamed(IDR_LOCK);
- warning_icon_ = rb.GetBitmapNamed(IDR_WARNING);
+ if (info_bubble_) {
+ // If an info bubble is currently showing, nothing to do.
+ return;
}
- SetImageShown(LOCK);
-}
-LocationBarView::SecurityImageView::~SecurityImageView() {
+ show_info_bubble_task_ = new ShowInfoBubbleTask(this);
+ MessageLoop::current()->PostDelayedTask(FROM_HERE, show_info_bubble_task_,
+ kInfoBubbleHoverDelayMs);
}
-void LocationBarView::SecurityImageView::SetImageShown(Image image) {
- switch (image) {
- case LOCK:
- ImageView::SetImage(lock_icon_);
- break;
- case WARNING:
- ImageView::SetImage(warning_icon_);
- break;
- default:
- NOTREACHED();
- break;
+void LocationBarView::SecurityImageView::OnMouseExited(
+ const views::MouseEvent& event) {
+ if (show_info_bubble_task_) {
+ show_info_bubble_task_->Cancel();
+ show_info_bubble_task_ = NULL;
}
+
+ if (info_bubble_)
+ info_bubble_->Close();
}
bool LocationBarView::SecurityImageView::OnMousePressed(
@@ -998,57 +953,10 @@ bool LocationBarView::SecurityImageView::OnMousePressed(
return true;
}
-void LocationBarView::SecurityImageView::ShowInfoBubble() {
- std::wstring text;
- SkColor text_color;
- model_->GetIconHoverText(&text, &text_color);
-
- ShowInfoBubbleImpl(text, text_color);
-}
-
-// RssImageView------------------------------------------------------------
-
-// static
-SkBitmap* LocationBarView::RssImageView::rss_icon_ = NULL;
-
-LocationBarView::RssImageView::RssImageView(ToolbarModel* model)
- : model_(model),
- LocationBarImageView() {
- if (!rss_icon_) {
- ResourceBundle& rb = ResourceBundle::GetSharedInstance();
- rss_icon_ = rb.GetBitmapNamed(IDR_RSS_ICON);
- }
- ImageView::SetImage(rss_icon_);
-}
-
-LocationBarView::RssImageView::~RssImageView() {
-}
-
-bool LocationBarView::RssImageView::OnMousePressed(
- const views::MouseEvent& event) {
- NavigationEntry* entry =
- BrowserList::GetLastActive()->GetSelectedTabContents()->
- controller()->GetActiveEntry();
- if (!entry) {
- NOTREACHED();
- return true;
- }
-
- // Navigate to the first item in the feed list.
- scoped_refptr<FeedList> feeds = model_->GetFeedList();
- DCHECK(feeds.get() && feeds->list().size() > 0);
-
- // TODO(finnur): Make this do more than just display the XML in the browser.
- BrowserList::GetLastActive()->OpenURL(feeds->list()[0].url, GURL(),
- CURRENT_TAB, PageTransition::LINK);
- return true;
-}
-
-void LocationBarView::RssImageView::ShowInfoBubble() {
- // TODO(finnur): Get this string from the resources.
- std::wstring text = L"Subscribe to this feed";
- SkColor text_color = SK_ColorBLUE;
- ShowInfoBubbleImpl(text, text_color);
+void LocationBarView::SecurityImageView::InfoBubbleClosing(
+ InfoBubble* info_bubble,
+ bool closed_by_escape) {
+ info_bubble_ = NULL;
}
bool LocationBarView::OverrideAccelerator(
diff --git a/chrome/browser/views/location_bar_view.h b/chrome/browser/views/location_bar_view.h
index 99822f4..07b9e06 100644
--- a/chrome/browser/views/location_bar_view.h
+++ b/chrome/browser/views/location_bar_view.h
@@ -120,7 +120,6 @@ class LocationBarView : public LocationBar,
virtual void AcceptInput();
virtual void FocusLocation();
virtual void FocusSearch();
- virtual void UpdateFeedIcon();
virtual void SaveStateToContents(TabContents* contents);
static const int kVertMargin;
@@ -225,45 +224,13 @@ class LocationBarView : public LocationBar,
class ShowInfoBubbleTask;
class ShowFirstRunBubbleTask;
- class LocationBarImageView : public views::ImageView,
- public InfoBubbleDelegate {
- public:
- LocationBarImageView();
- virtual ~LocationBarImageView();
-
- // Overridden from view for the mouse hovering.
- virtual void OnMouseMoved(const views::MouseEvent& event);
- virtual void OnMouseExited(const views::MouseEvent& event);
- virtual bool OnMousePressed(const views::MouseEvent& event) = 0;
-
- // InfoBubbleDelegate
- void InfoBubbleClosing(InfoBubble* info_bubble, bool closed_by_escape);
- bool CloseOnEscape() { return true; }
-
- virtual void ShowInfoBubble() = 0;
-
- protected:
- void ShowInfoBubbleImpl(const std::wstring& text, SkColor text_color);
-
- private:
- friend class ShowInfoBubbleTask;
-
- // The currently shown info bubble if any.
- InfoBubble* info_bubble_;
-
- // A task used to display the info bubble when the mouse hovers on the
- // image.
- ShowInfoBubbleTask* show_info_bubble_task_;
-
- DISALLOW_COPY_AND_ASSIGN(LocationBarImageView);
- };
-
// SecurityImageView is used to display the lock or warning icon when the
// current URL's scheme is https.
//
// If a message has been set with SetInfoBubbleText, it displays an info
// bubble when the mouse hovers on the image.
- class SecurityImageView : public LocationBarImageView {
+ class SecurityImageView : public views::ImageView,
+ public InfoBubbleDelegate {
public:
enum Image {
LOCK = 0,
@@ -277,13 +244,21 @@ class LocationBarView : public LocationBar,
void SetImageShown(Image image);
// Overridden from view for the mouse hovering.
+ virtual void OnMouseMoved(const views::MouseEvent& event);
+ virtual void OnMouseExited(const views::MouseEvent& event);
virtual bool OnMousePressed(const views::MouseEvent& event);
- void set_profile(Profile* profile) { profile_ = profile; }
+ // InfoBubbleDelegate
+ void InfoBubbleClosing(InfoBubble* info_bubble, bool closed_by_escape);
+ bool CloseOnEscape() { return true; }
- virtual void ShowInfoBubble();
+ void set_profile(Profile* profile) { profile_ = profile; }
private:
+ friend class ShowInfoBubbleTask;
+
+ void ShowInfoBubble();
+
// The lock icon shown when using HTTPS.
static SkBitmap* lock_icon_;
@@ -304,30 +279,6 @@ class LocationBarView : public LocationBar,
DISALLOW_EVIL_CONSTRUCTORS(SecurityImageView);
};
- // RssImageView is used to display the RSS icon when the page has a feed that
- // you can subscribe to.
- //
- // If a message has been set with SetInfoBubbleText, it displays an info
- // bubble when the mouse hovers on the image.
- class RssImageView : public LocationBarImageView {
- public:
- explicit RssImageView(ToolbarModel* model);
- virtual ~RssImageView();
-
- // Overridden from view for the mouse hovering.
- virtual bool OnMousePressed(const views::MouseEvent& event);
-
- virtual void ShowInfoBubble();
-
- private:
- // The RSS icon shown when page has a feed.
- static SkBitmap* rss_icon_;
-
- ToolbarModel* model_;
-
- DISALLOW_COPY_AND_ASSIGN(RssImageView);
- };
-
// Both Layout and OnChanged call into this. This updates the contents
// of the 3 views: selected_keyword, keyword_hint and type_search_view. If
// force_layout is true, or one of these views has changed in such a way as
@@ -365,9 +316,6 @@ class LocationBarView : public LocationBar,
// Sets the security icon to display. Note that no repaint is done.
void SetSecurityIcon(ToolbarModel::Icon icon);
- // Sets the RSS icon visibility.
- void SetRssIconVisibility(FeedList* feeds);
-
// Sets the text that should be displayed in the info label and its associated
// tooltip text. Call with an empty string if the info label should be
// hidden.
@@ -433,9 +381,6 @@ class LocationBarView : public LocationBar,
// The view that shows the lock/warning when in HTTPS mode.
SecurityImageView security_image_view_;
- // The view that shows the RSS icon when the page has an RSS feed.
- RssImageView rss_image_view_;
-
// A label displayed after the lock icon to show some extra information.
views::Label info_label_;