diff options
author | yusukes@google.com <yusukes@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-06 10:04:15 +0000 |
---|---|---|
committer | yusukes@google.com <yusukes@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-06 10:04:15 +0000 |
commit | 6289beb1a1caa052d9379923e2a7a344edb74839 (patch) | |
tree | d86ead3d27e21eafe2490a9ddc0526cd5b57bf22 | |
parent | 8a17bd55d6f0336a3d8e3c66af61a0a3b074dfe9 (diff) | |
download | chromium_src-6289beb1a1caa052d9379923e2a7a344edb74839.zip chromium_src-6289beb1a1caa052d9379923e2a7a344edb74839.tar.gz chromium_src-6289beb1a1caa052d9379923e2a7a344edb74839.tar.bz2 |
Second (and hopefully the final) fix for the issue 805:
Killed (1) the "start download" (big arrow) animation and (2) fade and resize animation on NTP page, when the following conditions is met:
(XP) Chromium is used over RDP.
(Vista) "Turn off all unnecessary animations (when possible)" option in "Control Panel - Ease of Access Center - Make the computer easier to see" is checked. Note that the option automatically becomes checked when a user turns off the "Menu and window animation" option of a remote-desktop client.
Review: http://codereview.chromium.org/115304
BUG=805
TEST=For (1), download a file and verify the arrow doesn't appear over RDP. For (2), set NTP as your homepage, start chromium on RDP session, verify fade animations on thumbnails are killed, then resize browser window, verify resize animations on thumbnails are also killed. Do the same thing with --new-new-tab-page command line flag.
Review URL: http://codereview.chromium.org/118307
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17827 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | app/animation.cc | 24 | ||||
-rw-r--r-- | app/animation.h | 5 | ||||
-rw-r--r-- | app/animation_unittest.cc | 25 | ||||
-rw-r--r-- | chrome/browser/browser.cc | 4 | ||||
-rw-r--r-- | chrome/browser/dom_ui/new_tab_ui.cc | 6 | ||||
-rw-r--r-- | chrome/browser/resources/new_new_tab.html | 5 | ||||
-rw-r--r-- | chrome/browser/resources/new_tab.html | 5 |
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; |