summaryrefslogtreecommitdiffstats
path: root/chrome/browser/views/frame
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-14 22:40:44 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-14 22:40:44 +0000
commitafb738834f1e43f4607f1d5d00bae23aa740dbaa (patch)
treed12bcf05a51aeb5369b72c1ee838e984a7b9d76f /chrome/browser/views/frame
parent5a068bd029b1d28374f0cf26cbb74bc1ef33bd0c (diff)
downloadchromium_src-afb738834f1e43f4607f1d5d00bae23aa740dbaa.zip
chromium_src-afb738834f1e43f4607f1d5d00bae23aa740dbaa.tar.gz
chromium_src-afb738834f1e43f4607f1d5d00bae23aa740dbaa.tar.bz2
Rewire the throbber so that the timer for updating lives on BrowserView, not TabStrip, so that app window/popup throbber updating doesn't need to be plumbed through the tabstrip and the browser object!
http://crbug.com/3297 Review URL: http://codereview.chromium.org/10761 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@5513 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views/frame')
-rw-r--r--chrome/browser/views/frame/browser_view.cc33
-rw-r--r--chrome/browser/views/frame/browser_view.h8
2 files changed, 36 insertions, 5 deletions
diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc
index 8e5cff1..873d38a 100644
--- a/chrome/browser/views/frame/browser_view.cc
+++ b/chrome/browser/views/frame/browser_view.cc
@@ -7,6 +7,7 @@
#include "chrome/browser/views/frame/browser_view.h"
#include "base/file_version_info.h"
+#include "base/time.h"
#include "chrome/app/chrome_dll_resource.h"
#include "chrome/app/theme/theme_resources.h"
#include "chrome/browser/app_modal_dialog_queue.h"
@@ -47,6 +48,8 @@
#include "chromium_strings.h"
#include "generated_resources.h"
+using base::TimeDelta;
+
// static
SkBitmap BrowserView::default_favicon_;
SkBitmap BrowserView::otr_avatar_;
@@ -73,6 +76,8 @@ static const int kWindowTilePixels = 10;
static const int kDefaultHungPluginDetectFrequency = 2000;
// How long do we wait before we consider a window hung (in ms).
static const int kDefaultPluginMessageResponseTimeout = 30000;
+// The number of milliseconds between loading animation frames.
+static const int kLoadingAnimationFrameTimeMs = 30;
static const struct { bool separator; int command; int label; } kMenuLayout[] = {
{ true, 0, 0 },
@@ -416,10 +421,20 @@ void BrowserView::UpdateTitleBar() {
frame_->GetWindow()->UpdateWindowIcon();
}
-void BrowserView::ValidateThrobber() {
- if (ShouldShowWindowIcon()) {
- TabContents* tab_contents = browser_->GetSelectedTabContents();
- frame_->UpdateThrobber(tab_contents ? tab_contents->is_loading() : false);
+void BrowserView::UpdateLoadingAnimations(bool should_animate) {
+ if (should_animate) {
+ if (!loading_animation_timer_.IsRunning()) {
+ // Loads are happening, and the timer isn't running, so start it.
+ loading_animation_timer_.Start(
+ TimeDelta::FromMilliseconds(kLoadingAnimationFrameTimeMs), this,
+ &BrowserView::LoadingAnimationCallback);
+ }
+ } else {
+ if (loading_animation_timer_.IsRunning()) {
+ loading_animation_timer_.Stop();
+ // Loads are now complete, update the state if a task was scheduled.
+ LoadingAnimationCallback();
+ }
}
}
@@ -1274,6 +1289,16 @@ int BrowserView::GetCommandIDForAppCommandID(int app_command_id) const {
return -1;
}
+void BrowserView::LoadingAnimationCallback() {
+ if (SupportsWindowFeature(FEATURE_TABSTRIP)) {
+ // Loading animations are shown in the tab for tabbed windows.
+ tabstrip_->UpdateLoadingAnimations();
+ } else if (ShouldShowWindowIcon()) {
+ // ... or in the window icon area for popups and app windows.
+ frame_->UpdateThrobber(browser_->IsCurrentPageLoading());
+ }
+}
+
void BrowserView::InitHangMonitor() {
PrefService* pref_service = g_browser_process->local_state();
int plugin_message_response_timeout =
diff --git a/chrome/browser/views/frame/browser_view.h b/chrome/browser/views/frame/browser_view.h
index fde7d12..bf6a41b 100644
--- a/chrome/browser/views/frame/browser_view.h
+++ b/chrome/browser/views/frame/browser_view.h
@@ -151,7 +151,7 @@ class BrowserView : public BrowserWindow,
virtual StatusBubble* GetStatusBubble();
virtual void SelectedTabToolbarSizeChanged(bool is_animating);
virtual void UpdateTitleBar();
- virtual void ValidateThrobber();
+ virtual void UpdateLoadingAnimations(bool should_animate);
virtual gfx::Rect GetNormalBounds() const;
virtual bool IsMaximized();
virtual ToolbarStarToggle* GetStarButton() const;
@@ -308,6 +308,9 @@ class BrowserView : public BrowserWindow,
// Retrieves the command id for the specified Windows app command.
int GetCommandIDForAppCommandID(int app_command_id) const;
+ // Callback for the loading animation(s) associated with this view.
+ void LoadingAnimationCallback();
+
// Initialize the hung plugin detector.
void InitHangMonitor();
@@ -385,6 +388,9 @@ class BrowserView : public BrowserWindow,
// plugin window.
HungPluginAction hung_plugin_action_;
+ // The timer used to update frames for the Loading Animation.
+ base::RepeatingTimer<BrowserView> loading_animation_timer_;
+
// P13N stuff
#ifdef CHROME_PERSONALIZATION
FramePersonalization personalization_;