diff options
author | mirandac@chromium.org <mirandac@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-03 22:04:40 +0000 |
---|---|---|
committer | mirandac@chromium.org <mirandac@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-03 22:04:40 +0000 |
commit | 91e1bd8b364d374372ab7be8c133ca03ffa1d2dd (patch) | |
tree | cc09b2d614599d8d3c3311d9a2080c071817f0f7 /chrome/browser/views/theme_install_bubble_view.h | |
parent | 673336b8ef5a8708d7d3fe0dc8c3daa8d12d4097 (diff) | |
download | chromium_src-91e1bd8b364d374372ab7be8c133ca03ffa1d2dd.zip chromium_src-91e1bd8b364d374372ab7be8c133ca03ffa1d2dd.tar.gz chromium_src-91e1bd8b364d374372ab7be8c133ca03ffa1d2dd.tar.bz2 |
Add "loading..." message to theme install to counter jank.
BUG= http://crbug.com/17696
TEST= Install a theme. Note that a "loading" message appears to notify you that a theme is loading.
Review URL: http://codereview.chromium.org/191011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25383 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views/theme_install_bubble_view.h')
-rw-r--r-- | chrome/browser/views/theme_install_bubble_view.h | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/chrome/browser/views/theme_install_bubble_view.h b/chrome/browser/views/theme_install_bubble_view.h new file mode 100644 index 0000000..3ac742f --- /dev/null +++ b/chrome/browser/views/theme_install_bubble_view.h @@ -0,0 +1,67 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "app/gfx/canvas.h" +#include "chrome/browser/tab_contents/tab_contents.h" +#include "chrome/common/notification_registrar.h" +#include "chrome/common/notification_service.h" +#include "views/controls/label.h" +#include "views/widget/widget_win.h" + +// ThemeInstallBubbleView launches a "loading..." bubble in the center of the +// currently active browser window when an extension or theme is loaded. If +// an extension is being applied, the bubble goes away immediately. If a theme +// is being applied, it disappears when the theme has been loaded. The purpose +// of this bubble is to warn the user that the browser may be unresponsive +// while the theme is being installed. +// +// Edge case: note that if one installs a theme in one window and then switches +// rapidly to another window to install a theme there as well (in the short +// time between install begin and theme caching seizing the UI thread), the +// loading bubble will only appear over the first window. +class ThemeInstallBubbleView : public NotificationObserver, + public views::Label { + public: + explicit ThemeInstallBubbleView(TabContents* tab_contents); + + ~ThemeInstallBubbleView(); + + // NotificationObserver + virtual void Observe(NotificationType type, + const NotificationSource& source, + const NotificationDetails& details); + + // Show the loading bubble. + static void Show(TabContents* tab_contents); + + private: + // The roundedness of the edges of our bubble. + static const int kBubbleCornerRadius = 4; + + // The content area at the start of the animation. + gfx::Rect tab_contents_bounds_; + + // We use a HWND for the popup so that it may float above any HWNDs in our UI. + views::WidgetWin* popup_; + + // Text to show warning that theme is being installed. + std::wstring text_; + + // A scoped container for notification registries. + NotificationRegistrar registrar_; + + // Put the popup in the correct place on the tab. + void Reposition(); + + // Inherited from views. + gfx::Size GetPreferredSize(); + + // Shut down the popup and remove our notifications. + void Close(); + + virtual void Paint(gfx::Canvas* canvas); + + DISALLOW_COPY_AND_ASSIGN(ThemeInstallBubbleView); +}; + |