summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/app/theme/theme_resources.grd1
-rw-r--r--chrome/app/theme/throbber_waiting_light.pngbin0 -> 26328 bytes
-rw-r--r--chrome/browser/gtk/browser_titlebar.cc58
-rw-r--r--chrome/browser/gtk/browser_titlebar.h13
-rw-r--r--chrome/browser/gtk/browser_window_gtk.cc2
5 files changed, 50 insertions, 24 deletions
diff --git a/chrome/app/theme/theme_resources.grd b/chrome/app/theme/theme_resources.grd
index 80580bb..df90eeb 100644
--- a/chrome/app/theme/theme_resources.grd
+++ b/chrome/app/theme/theme_resources.grd
@@ -231,6 +231,7 @@
<include name="IDR_DOWNLOADS_SECTION" file="downloads_section.png" type="BINDATA" />
<include name="IDR_DEFAULT_THUMBNAIL" file="default_thumbnail.png" type="BINDATA" />
<include name="IDR_THROBBER_WAITING" file="throbber_waiting.png" type="BINDATA" />
+ <include name="IDR_THROBBER_WAITING_LIGHT" file="throbber_waiting_light.png" type="BINDATA" />
<include name="IDR_INFOBAR_PLUGIN_CRASHED" file="infobar_plugin_crashed.png" type="BINDATA" />
<include name="IDR_UPDATE_UPTODATE" file="update_uptodate.png" type="BINDATA" />
<include name="IDR_UPDATE_FAIL" file="update_fail.png" type="BINDATA" />
diff --git a/chrome/app/theme/throbber_waiting_light.png b/chrome/app/theme/throbber_waiting_light.png
new file mode 100644
index 0000000..08d4349
--- /dev/null
+++ b/chrome/app/theme/throbber_waiting_light.png
Binary files differ
diff --git a/chrome/browser/gtk/browser_titlebar.cc b/chrome/browser/gtk/browser_titlebar.cc
index 26a57d1..594d673 100644
--- a/chrome/browser/gtk/browser_titlebar.cc
+++ b/chrome/browser/gtk/browser_titlebar.cc
@@ -22,6 +22,7 @@
#include "chrome/browser/gtk/standard_menus.h"
#include "chrome/browser/gtk/tabs/tab_strip_gtk.h"
#include "chrome/browser/profile.h"
+#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/pref_service.h"
#include "grit/app_resources.h"
@@ -271,11 +272,12 @@ void BrowserTitlebar::UpdateTitle() {
g_free(label_markup);
}
-void BrowserTitlebar::UpdateThrobber(bool is_loading) {
+void BrowserTitlebar::UpdateThrobber(TabContents* tab_contents) {
DCHECK(app_mode_favicon_);
- if (is_loading) {
- GdkPixbuf* icon_pixbuf = throbber_.GetNextFrame();
+ if (tab_contents && tab_contents->is_loading()) {
+ GdkPixbuf* icon_pixbuf =
+ throbber_.GetNextFrame(tab_contents->waiting_for_response());
gtk_image_set_from_pixbuf(GTK_IMAGE(app_mode_favicon_), icon_pixbuf);
} else {
if (browser_window_->browser()->type() == Browser::TYPE_APP) {
@@ -453,16 +455,43 @@ void BrowserTitlebar::ExecuteCommand(int command_id) {
// BrowserTitlebar::Throbber implementation
// TODO(tc): Handle anti-clockwise spinning when waiting for a connection.
-// We don't bother to clean this or the pixbufs it contains when we exit.
+// We don't bother to clean up these or the pixbufs they contain when we exit.
static std::vector<GdkPixbuf*>* g_throbber_frames = NULL;
+static std::vector<GdkPixbuf*>* g_throbber_waiting_frames = NULL;
-GdkPixbuf* BrowserTitlebar::Throbber::GetNextFrame() {
+// Load |resource_id| from the ResourceBundle and split it into a series of
+// square GdkPixbufs that get stored in |frames|.
+static void MakeThrobberFrames(int resource_id,
+ std::vector<GdkPixbuf*>* frames) {
+ ResourceBundle &rb = ResourceBundle::GetSharedInstance();
+ SkBitmap* frame_strip = rb.GetBitmapNamed(resource_id);
+
+ // Each frame of the animation is a square, so we use the height as the
+ // frame size.
+ int frame_size = frame_strip->height();
+ size_t num_frames = frame_strip->width() / frame_size;
+
+ // Make a separate GdkPixbuf for each frame of the animation.
+ for (size_t i = 0; i < num_frames; ++i) {
+ SkBitmap frame = skia::ImageOperations::CreateTiledBitmap(*frame_strip,
+ i * frame_size, 0, frame_size, frame_size);
+ frames->push_back(gfx::GdkPixbufFromSkBitmap(&frame));
+ }
+}
+
+GdkPixbuf* BrowserTitlebar::Throbber::GetNextFrame(bool is_waiting) {
Throbber::InitFrames();
- return (*g_throbber_frames)[current_frame_++ % g_throbber_frames->size()];
+ if (is_waiting) {
+ return (*g_throbber_waiting_frames)[current_waiting_frame_++ %
+ g_throbber_waiting_frames->size()];
+ } else {
+ return (*g_throbber_frames)[current_frame_++ % g_throbber_frames->size()];
+ }
}
void BrowserTitlebar::Throbber::Reset() {
current_frame_ = 0;
+ current_waiting_frame_ = 0;
}
// static
@@ -470,19 +499,10 @@ void BrowserTitlebar::Throbber::InitFrames() {
if (g_throbber_frames)
return;
- ResourceBundle &rb = ResourceBundle::GetSharedInstance();
- SkBitmap* frame_strip = rb.GetBitmapNamed(IDR_THROBBER_LIGHT);
-
- // Each frame of the animation is a square, so we use the height as the
- // frame size.
- int frame_size = frame_strip->height();
- size_t num_frames = frame_strip->width() / frame_size;
+ // We load the light version of the throbber since it'll be in the titlebar.
g_throbber_frames = new std::vector<GdkPixbuf*>;
+ MakeThrobberFrames(IDR_THROBBER_LIGHT, g_throbber_frames);
- // Make a separate GdkPixbuf for each frame of the animation.
- for (size_t i = 0; i < num_frames; ++i) {
- SkBitmap frame = skia::ImageOperations::CreateTiledBitmap(*frame_strip,
- i * frame_size, 0, frame_size, frame_size);
- g_throbber_frames->push_back(gfx::GdkPixbufFromSkBitmap(&frame));
- }
+ g_throbber_waiting_frames = new std::vector<GdkPixbuf*>;
+ MakeThrobberFrames(IDR_THROBBER_WAITING_LIGHT, g_throbber_waiting_frames);
}
diff --git a/chrome/browser/gtk/browser_titlebar.h b/chrome/browser/gtk/browser_titlebar.h
index 98a56ab..29b3cb2 100644
--- a/chrome/browser/gtk/browser_titlebar.h
+++ b/chrome/browser/gtk/browser_titlebar.h
@@ -17,6 +17,7 @@
class BrowserWindowGtk;
class CustomDrawButton;
+class TabContents;
class TabStripGtk;
class BrowserTitlebar : public MenuGtk::Delegate {
@@ -37,7 +38,9 @@ class BrowserTitlebar : public MenuGtk::Delegate {
void UpdateTitle();
// Called by the browser asking us to update the loading throbber.
- void UpdateThrobber(bool is_loading);
+ // |tab_contents| is the tab that is associated with the window throbber.
+ // |tab_contents| can be null.
+ void UpdateThrobber(TabContents* tab_contents);
// On Windows, right clicking in the titlebar background brings up the system
// menu. There's no such thing on linux, so we just show the menu items we
@@ -49,11 +52,12 @@ class BrowserTitlebar : public MenuGtk::Delegate {
// we're showing.
class Throbber {
public:
- Throbber() : current_frame_(0) {}
+ Throbber() : current_frame_(0), current_waiting_frame_(0) {}
// Get the next frame in the animation. The image is owned by the throbber
- // so the caller doesn't need to unref.
- GdkPixbuf* GetNextFrame();
+ // so the caller doesn't need to unref. |is_waiting| is true if we're
+ // still waiting for a response.
+ GdkPixbuf* GetNextFrame(bool is_waiting);
// Reset back to the first frame.
void Reset();
@@ -62,6 +66,7 @@ class BrowserTitlebar : public MenuGtk::Delegate {
static void InitFrames();
int current_frame_;
+ int current_waiting_frame_;
};
// Build the titlebar, the space above the tab
diff --git a/chrome/browser/gtk/browser_window_gtk.cc b/chrome/browser/gtk/browser_window_gtk.cc
index c962fbb..b005664 100644
--- a/chrome/browser/gtk/browser_window_gtk.cc
+++ b/chrome/browser/gtk/browser_window_gtk.cc
@@ -758,7 +758,7 @@ void BrowserWindowGtk::LoadingAnimationCallback() {
// GetSelectedTabContents can return NULL for example under Purify when
// the animations are running slowly and this function is called on
// a timer through LoadingAnimationCallback.
- titlebar_->UpdateThrobber(tab_contents && tab_contents->is_loading());
+ titlebar_->UpdateThrobber(tab_contents);
}
}