summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/browser.cc34
-rw-r--r--chrome/browser/browser.h11
-rw-r--r--chrome/browser/simple_xp_frame.cc2
-rw-r--r--chrome/browser/tabs/tab_renderer.cc14
-rw-r--r--chrome/browser/tabs/tab_renderer.h4
-rw-r--r--chrome/browser/views/frame/aero_glass_frame.cc8
-rw-r--r--chrome/browser/views/frame/aero_glass_frame.h4
-rw-r--r--chrome/browser/views/frame/browser_view2.cc21
-rw-r--r--chrome/browser/views/frame/browser_view2.h6
-rw-r--r--chrome/browser/views/frame/opaque_non_client_view.cc23
-rw-r--r--chrome/views/custom_frame_window.cc2
11 files changed, 100 insertions, 29 deletions
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc
index 105654f..866b2a5 100644
--- a/chrome/browser/browser.cc
+++ b/chrome/browser/browser.cc
@@ -1632,7 +1632,7 @@ void Browser::OpenURLOffTheRecord(Profile* profile, const GURL& url) {
std::wstring Browser::ComputePopupTitle(const GURL& url,
const std::wstring& title) {
std::wstring result(title);
- Tab::FormatTitleForDisplay(&result);
+ FormatTitleForDisplay(&result);
return result;
}
@@ -1762,3 +1762,35 @@ NavigationController* Browser::GetSelectedNavigationController() const {
else
return NULL;
}
+
+///////////////////////////////////////////////////////////////////////////////
+// NEW FRAME TODO(beng): clean up this file
+// DO NOT PLACE METHODS NOT RELATED TO NEW FRAMES BELOW THIS LINE.
+
+SkBitmap Browser::GetCurrentPageIcon() const {
+ TabContents* contents = tabstrip_model_.GetSelectedTabContents();
+ return contents ? contents->GetFavIcon() : SkBitmap();
+}
+
+std::wstring Browser::GetCurrentPageTitle() const {
+ TabContents* contents = tabstrip_model_.GetSelectedTabContents();
+ std::wstring title;
+ if (contents) {
+ title = contents->GetTitle();
+ FormatTitleForDisplay(&title);
+ }
+ if (title.empty())
+ title = l10n_util::GetString(IDS_TAB_UNTITLED_TITLE);
+ return title;
+}
+
+// static
+void Browser::FormatTitleForDisplay(std::wstring* title) {
+ size_t current_index = 0;
+ size_t match_index;
+ while ((match_index = title->find(L'\n', current_index)) !=
+ std::wstring::npos) {
+ title->replace(match_index, 1, L"");
+ current_index = match_index;
+ }
+}
diff --git a/chrome/browser/browser.h b/chrome/browser/browser.h
index 1cd1b57..3af7051 100644
--- a/chrome/browser/browser.h
+++ b/chrome/browser/browser.h
@@ -382,6 +382,17 @@ class Browser : public TabStripModelDelegate,
void ConvertTabToApplication(TabContents* contents);
+ // NEW FRAME METHODS BELOW THIS LINE ONLY... TODO(beng): clean up this file!
+
+ // Gets the FavIcon of the page in the selected tab.
+ SkBitmap GetCurrentPageIcon() const;
+
+ // Gets the title of the page in the selected tab.
+ std::wstring GetCurrentPageTitle() const;
+
+ // Prepares a title string for display (removes embedded newlines, etc).
+ static void FormatTitleForDisplay(std::wstring* title);
+
private:
friend class XPFrame;
friend class VistaFrame;
diff --git a/chrome/browser/simple_xp_frame.cc b/chrome/browser/simple_xp_frame.cc
index 54a9d38..f6120f8 100644
--- a/chrome/browser/simple_xp_frame.cc
+++ b/chrome/browser/simple_xp_frame.cc
@@ -253,7 +253,7 @@ bool SimpleXPFrameTitleBar::WillHandleMouseEvent(int x, int y) {
void SimpleXPFrameTitleBar::SetWindowTitle(std::wstring s) {
if (parent_->IsApplication()) {
std::wstring t(s);
- Tab::FormatTitleForDisplay(&t);
+ Browser::FormatTitleForDisplay(&t);
label_->SetText(t);
} else {
label_->SetText(Browser::ComputePopupTitle(
diff --git a/chrome/browser/tabs/tab_renderer.cc b/chrome/browser/tabs/tab_renderer.cc
index 6f7030d..05b2a61 100644
--- a/chrome/browser/tabs/tab_renderer.cc
+++ b/chrome/browser/tabs/tab_renderer.cc
@@ -33,6 +33,7 @@
#include "base/gfx/image_operations.h"
#include "chrome/app/theme/theme_resources.h"
+#include "chrome/browser/browser.h"
#include "chrome/browser/tabs/tab_strip_model.h"
#include "chrome/browser/tab_contents.h"
#include "chrome/common/gfx/chrome_canvas.h"
@@ -379,17 +380,6 @@ gfx::Size TabRenderer::GetStandardSize() {
return standard_size;
}
-// static
-void TabRenderer::FormatTitleForDisplay(std::wstring* title) {
- size_t current_index = 0;
- size_t match_index;
- while ((match_index = title->find(L'\n', current_index)) !=
- std::wstring::npos) {
- title->replace(match_index, 1, L"");
- current_index = match_index;
- }
-}
-
////////////////////////////////////////////////////////////////////////////////
// TabRenderer, protected:
@@ -462,7 +452,7 @@ void TabRenderer::Paint(ChromeCanvas* canvas) {
title = l10n_util::GetString(IDS_TAB_UNTITLED_TITLE);
}
} else {
- FormatTitleForDisplay(&title);
+ Browser::FormatTitleForDisplay(&title);
}
SkColor title_color = IsSelected() ? kSelectedTitleColor
diff --git a/chrome/browser/tabs/tab_renderer.h b/chrome/browser/tabs/tab_renderer.h
index 2c7ad58..625a0ed 100644
--- a/chrome/browser/tabs/tab_renderer.h
+++ b/chrome/browser/tabs/tab_renderer.h
@@ -88,10 +88,6 @@ class TabRenderer : public ChromeViews::View,
// available.
static gfx::Size GetStandardSize();
- // Remove invalid characters from the title (e.g. newlines) that may
- // interfere with rendering.
- static void FormatTitleForDisplay(std::wstring* title);
-
protected:
ChromeViews::Button* close_button() const { return close_button_; }
const gfx::Rect& title_bounds() const { return title_bounds_; }
diff --git a/chrome/browser/views/frame/aero_glass_frame.cc b/chrome/browser/views/frame/aero_glass_frame.cc
index 410e254..96e89f1 100644
--- a/chrome/browser/views/frame/aero_glass_frame.cc
+++ b/chrome/browser/views/frame/aero_glass_frame.cc
@@ -66,6 +66,14 @@ void AeroGlassFrame::Init(const gfx::Rect& bounds) {
Window::Init(NULL, bounds);
}
+bool AeroGlassFrame::IsTabStripVisible() const {
+ return browser_view_->IsTabStripVisible();
+}
+
+bool AeroGlassFrame::IsToolbarVisible() const {
+ return browser_view_->IsToolbarVisible();
+}
+
gfx::Rect AeroGlassFrame::GetToolbarBounds() const {
return browser_view_->GetToolbarBounds();
}
diff --git a/chrome/browser/views/frame/aero_glass_frame.h b/chrome/browser/views/frame/aero_glass_frame.h
index e8f298e..a08581c 100644
--- a/chrome/browser/views/frame/aero_glass_frame.h
+++ b/chrome/browser/views/frame/aero_glass_frame.h
@@ -51,8 +51,8 @@ class AeroGlassFrame : public BrowserFrame,
void Init(const gfx::Rect& bounds);
- bool IsToolbarVisible() const { return true; }
- bool IsTabStripVisible() const { return true; }
+ bool IsToolbarVisible() const;
+ bool IsTabStripVisible() const;
// Returns bounds of various areas within the BrowserView ClientView.
gfx::Rect GetToolbarBounds() const;
diff --git a/chrome/browser/views/frame/browser_view2.cc b/chrome/browser/views/frame/browser_view2.cc
index 518134b..7163686 100644
--- a/chrome/browser/views/frame/browser_view2.cc
+++ b/chrome/browser/views/frame/browser_view2.cc
@@ -29,6 +29,7 @@
#include "chrome/browser/views/frame/browser_view2.h"
+#include "chrome/app/theme/theme_resources.h"
#include "chrome/browser/browser.h"
#include "chrome/browser/browser_list.h"
#include "chrome/browser/tab_contents_container_view.h"
@@ -41,9 +42,11 @@
#include "chrome/browser/views/toolbar_view.h"
#include "chrome/common/l10n_util.h"
#include "chrome/common/pref_names.h"
+#include "chrome/common/resource_bundle.h"
#include "generated_resources.h"
// static
+SkBitmap BrowserView2::default_favicon_;
static const int kToolbarTabStripVerticalOverlap = 3;
static const int kTabShadowSize = 2;
static const int kStatusBubbleHeight = 20;
@@ -64,6 +67,7 @@ BrowserView2::BrowserView2(Browser* browser)
toolbar_(NULL),
contents_container_(NULL),
initialized_(false) {
+ InitClass();
show_bookmark_bar_pref_.Init(prefs::kShowBookmarkBar,
browser_->profile()->GetPrefs(), this);
browser_->tabstrip_model()->AddObserver(this);
@@ -451,7 +455,7 @@ bool BrowserView2::IsModal() const {
}
std::wstring BrowserView2::GetWindowTitle() const {
- return L"Magic browzR";
+ return browser_->GetCurrentPageTitle();
}
ChromeViews::View* BrowserView2::GetInitiallyFocusedView() const {
@@ -463,7 +467,10 @@ bool BrowserView2::ShouldShowWindowTitle() const {
}
SkBitmap BrowserView2::GetWindowIcon() {
- return SkBitmap();
+ SkBitmap favicon = browser_->GetCurrentPageIcon();
+ if (favicon.isNull())
+ return default_favicon_;
+ return favicon;
}
bool BrowserView2::ShouldShowWindowIcon() const {
@@ -836,3 +843,13 @@ void BrowserView2::LoadAccelerators() {
// We don't need the Windows accelerator table anymore.
free(accelerators);
}
+
+// static
+void BrowserView2::InitClass() {
+ static bool initialized = false;
+ if (!initialized) {
+ ResourceBundle& rb = ResourceBundle::GetSharedInstance();
+ default_favicon_ = *rb.GetBitmapNamed(IDR_DEFAULT_FAVICON);
+ initialized = true;
+ }
+}
diff --git a/chrome/browser/views/frame/browser_view2.h b/chrome/browser/views/frame/browser_view2.h
index 3a7fdec..164451c 100644
--- a/chrome/browser/views/frame/browser_view2.h
+++ b/chrome/browser/views/frame/browser_view2.h
@@ -245,6 +245,9 @@ class BrowserView2 : public BrowserWindow,
// use.
void LoadAccelerators();
+ // Initialize class statics.
+ static void InitClass();
+
// The BrowserFrame that hosts this view.
BrowserFrame* frame_;
@@ -280,6 +283,9 @@ class BrowserView2 : public BrowserWindow,
// True if we have already been initialized.
bool initialized_;
+ // The default favicon image.
+ static SkBitmap default_favicon_;
+
DISALLOW_EVIL_CONSTRUCTORS(BrowserView2);
};
diff --git a/chrome/browser/views/frame/opaque_non_client_view.cc b/chrome/browser/views/frame/opaque_non_client_view.cc
index a64ebdf..823014c 100644
--- a/chrome/browser/views/frame/opaque_non_client_view.cc
+++ b/chrome/browser/views/frame/opaque_non_client_view.cc
@@ -631,6 +631,16 @@ void OpaqueNonClientView::EnableClose(bool enable) {
// OpaqueNonClientView, ChromeViews::View overrides:
void OpaqueNonClientView::Paint(ChromeCanvas* canvas) {
+ // Clip the content area out of the rendering.
+ gfx::Rect contents_bounds = frame_->GetContentsBounds();
+ SkRect clip;
+ clip.set(SkIntToScalar(contents_bounds.x()),
+ SkIntToScalar(contents_bounds.y()),
+ SkIntToScalar(contents_bounds.right()),
+ SkIntToScalar(contents_bounds.bottom()));
+ canvas->clipRect(clip, SkRegion::kDifference_Op);
+
+ // Render the remaining portions of the non-client area.
if (frame_->IsMaximized()) {
PaintMaximizedFrameBorder(canvas);
} else {
@@ -640,11 +650,6 @@ void OpaqueNonClientView::Paint(ChromeCanvas* canvas) {
PaintTitleBar(canvas);
PaintToolbarBackground(canvas);
PaintClientEdge(canvas);
-
- // TODO(beng): remove this
- gfx::Rect contents_bounds = frame_->GetContentsBounds();
- canvas->FillRectInt(SK_ColorRED, contents_bounds.x(), contents_bounds.y(),
- contents_bounds.width(), contents_bounds.height());
}
void OpaqueNonClientView::Layout() {
@@ -834,12 +839,16 @@ void OpaqueNonClientView::PaintClientEdge(ChromeCanvas* canvas) {
gfx::Rect client_area_bounds = frame_->GetContentsBounds();
// For some reason things don't line up quite right, so we add and subtract
// pixels here and there for aesthetic bliss.
+ // Enlarge the client area to include the toolbar, since the top edge of
+ // the client area is the toolbar background and the client edge renders
+ // the left and right sides of the toolbar background.
+ int fudge = frame_->window_delegate()->ShouldShowWindowTitle() ? 0 : 1;
client_area_bounds.SetRect(
client_area_bounds.x(),
- frame_->client_view()->GetY() + toolbar_bounds.bottom() - 1,
+ frame_->client_view()->GetY() + toolbar_bounds.bottom() - fudge,
client_area_bounds.width(),
std::max(0, GetHeight() - frame_->client_view()->GetY() -
- toolbar_bounds.bottom() + 1 - kWindowVerticalBorderBottomSize));
+ toolbar_bounds.bottom() + fudge - kWindowVerticalBorderBottomSize));
canvas->TileImageInt(*right, client_area_bounds.right(),
client_area_bounds.y() + 1,
diff --git a/chrome/views/custom_frame_window.cc b/chrome/views/custom_frame_window.cc
index 0acf4b3..08f8e6d 100644
--- a/chrome/views/custom_frame_window.cc
+++ b/chrome/views/custom_frame_window.cc
@@ -885,6 +885,8 @@ void CustomFrameWindow::UpdateWindowTitle() {
// Layout winds up causing the title to be re-validated during
// string measurement.
non_client_view_->Layout();
+ // Must call the base class too so that places like the Task Bar get updated.
+ Window::UpdateWindowTitle();
}
void CustomFrameWindow::EnableClose(bool enable) {