summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/animation.cc24
-rw-r--r--app/animation.h5
-rw-r--r--app/animation_unittest.cc25
-rw-r--r--chrome/browser/browser.cc4
-rw-r--r--chrome/browser/dom_ui/new_tab_ui.cc6
-rw-r--r--chrome/browser/resources/new_new_tab.html5
-rw-r--r--chrome/browser/resources/new_tab.html5
7 files changed, 69 insertions, 5 deletions
diff --git a/app/animation.cc b/app/animation.cc
index 6a4e7b7..59d3dea 100644
--- a/app/animation.cc
+++ b/app/animation.cc
@@ -6,6 +6,10 @@
#include "base/message_loop.h"
+#if defined(OS_WIN)
+#include "base/win_util.h"
+#endif
+
using base::TimeDelta;
Animation::Animation(int frame_rate,
@@ -122,3 +126,23 @@ int Animation::CalculateInterval(int frame_rate) {
timer_interval = 10;
return timer_interval;
}
+
+// static
+bool Animation::ShouldRenderRichAnimation() {
+#if defined(OS_WIN)
+ if (win_util::GetWinVersion() >= win_util::WINVERSION_VISTA) {
+ BOOL result;
+ // Get "Turn off all unnecessary animations" value.
+ if (::SystemParametersInfo(SPI_GETCLIENTAREAANIMATION, 0, &result, 0)) {
+ // There seems to be a typo in the MSDN document (as of May 2009):
+ // http://msdn.microsoft.com/en-us/library/ms724947(VS.85).aspx
+ // The document states that the result is TRUE when animations are
+ // _disabled_, but in fact, it is TRUE when they are _enabled_.
+ return !!result;
+ }
+ }
+ return !::GetSystemMetrics(SM_REMOTESESSION);
+#endif
+ return true;
+}
+
diff --git a/app/animation.h b/app/animation.h
index 58a2c67..8228d62 100644
--- a/app/animation.h
+++ b/app/animation.h
@@ -89,6 +89,11 @@ class Animation {
// state of the animation to the beginning.
void SetDuration(int duration);
+ // Returns true if rich animations should be rendered.
+ // Looks at session type (e.g. remote desktop) and accessibility settings
+ // to give guidance for heavy animations such as "start download" arrow.
+ static bool ShouldRenderRichAnimation();
+
protected:
// Overriddable, called by Run.
virtual void Step();
diff --git a/app/animation_unittest.cc b/app/animation_unittest.cc
index a7450e3..bc1ebe5 100644
--- a/app/animation_unittest.cc
+++ b/app/animation_unittest.cc
@@ -4,10 +4,11 @@
#include "app/animation.h"
#include "base/message_loop.h"
+#if defined(OS_WIN)
+#include "base/win_util.h"
+#endif
#include "testing/gtest/include/gtest/gtest.h"
-using namespace std;
-
class AnimationTest: public testing::Test {
private:
MessageLoopForUI message_loop_;
@@ -100,3 +101,23 @@ TEST_F(AnimationTest, CancelCase) {
EXPECT_TRUE(ad.finished());
EXPECT_TRUE(ad.canceled());
}
+
+TEST_F(AnimationTest, ShouldRenderRichAnimation) {
+#if defined(OS_WIN)
+ if (win_util::GetWinVersion() >= win_util::WINVERSION_VISTA) {
+ BOOL result;
+ ASSERT_NE(
+ 0, ::SystemParametersInfo(SPI_GETCLIENTAREAANIMATION, 0, &result, 0));
+ // ShouldRenderRichAnimation() should check the SPI_GETCLIENTAREAANIMATION
+ // value on Vista.
+ EXPECT_EQ(!!result, Animation::ShouldRenderRichAnimation());
+ } else {
+ // On XP, the function should check the SM_REMOTESESSION value.
+ EXPECT_EQ(!::GetSystemMetrics(SM_REMOTESESSION),
+ Animation::ShouldRenderRichAnimation());
+ }
+#else
+ EXPECT_TRUE(Animation::ShouldRenderRichAnimation());
+#endif
+}
+
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc
index 0c5f414..dd3ae0f 100644
--- a/chrome/browser/browser.cc
+++ b/chrome/browser/browser.cc
@@ -4,6 +4,7 @@
#include "chrome/browser/browser.h"
+#include "app/animation.h"
#include "app/l10n_util.h"
#include "base/command_line.h"
#include "base/idle_timer.h"
@@ -1178,7 +1179,8 @@ void Browser::OnStartDownload(DownloadItem* download) {
if (download->total_bytes() > 0) {
TabContents* current_tab = GetSelectedTabContents();
// We make this check for the case of minimized windows, unit tests, etc.
- if (platform_util::IsVisible(current_tab->GetNativeView()))
+ if (platform_util::IsVisible(current_tab->GetNativeView()) &&
+ Animation::ShouldRenderRichAnimation())
DownloadStartedAnimation::Show(current_tab);
}
#endif
diff --git a/chrome/browser/dom_ui/new_tab_ui.cc b/chrome/browser/dom_ui/new_tab_ui.cc
index 451369d..2e60110 100644
--- a/chrome/browser/dom_ui/new_tab_ui.cc
+++ b/chrome/browser/dom_ui/new_tab_ui.cc
@@ -6,6 +6,7 @@
#include "chrome/browser/dom_ui/new_tab_ui.h"
+#include "app/animation.h"
#include "app/l10n_util.h"
#include "app/resource_bundle.h"
#include "base/command_line.h"
@@ -298,6 +299,11 @@ void NewTabHTMLSource::StartDataRequest(const std::string& path,
first_view_ ? L"true" : std::wstring());
first_view_ = false;
+ // Control fade and resize animations.
+ std::wstring anim =
+ Animation::ShouldRenderRichAnimation() ? L"true" : L"false";
+ localized_strings.SetString(L"anim", anim);
+
#ifdef CHROME_PERSONALIZATION
localized_strings.SetString(L"p13nsrc", Personalization::GetNewTabSource());
#endif
diff --git a/chrome/browser/resources/new_new_tab.html b/chrome/browser/resources/new_new_tab.html
index a61ddd8..bae7d2f 100644
--- a/chrome/browser/resources/new_new_tab.html
+++ b/chrome/browser/resources/new_new_tab.html
@@ -1,5 +1,5 @@
<!DOCTYPE HTML>
-<html id="t" jsvalues="dir:textdirection;firstview:firstview">
+<html id="t" jsvalues="dir:textdirection;firstview:firstview;anim:anim">
<!--
This page is optimized for perceived performance. Our enemies are the time
taken for the backend to generate our data, and the time taken to parse
@@ -437,6 +437,9 @@ html[firstview='true'] #main {
html[firstview='true'] #main.visible {
opacity:1.0;
}
+html[anim='false'] * {
+ -webkit-transition-property: none !important
+}
#main {
margin-left:auto;
margin-right:auto;
diff --git a/chrome/browser/resources/new_tab.html b/chrome/browser/resources/new_tab.html
index 2bd5389..e65e0e8 100644
--- a/chrome/browser/resources/new_tab.html
+++ b/chrome/browser/resources/new_tab.html
@@ -1,5 +1,5 @@
<!DOCTYPE HTML>
-<html id="t" jsvalues="dir:textdirection;firstview:firstview;bookmarkbarattached:bookmarkbarattached;hasattribution:hasattribution">
+<html id="t" jsvalues="dir:textdirection;firstview:firstview;bookmarkbarattached:bookmarkbarattached;hasattribution:hasattribution;anim:anim">
<!--
This page is optimized for perceived performance. Our enemies are the time
taken for the backend to generate our data, and the time taken to parse
@@ -143,6 +143,9 @@ html[firstview='true'] #main {
html[firstview='true'] #main.visible {
opacity:1.0;
}
+html[anim='false'] * {
+ -webkit-transition-property: none !important
+}
#main {
margin-left:auto;
margin-right:auto;