1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef CHROME_BROWSER_UI_VIEWS_THEME_INSTALL_BUBBLE_VIEW_H_ 6 #define CHROME_BROWSER_UI_VIEWS_THEME_INSTALL_BUBBLE_VIEW_H_ 7 #pragma once 8 9 #include "base/string16.h" 10 #include "content/common/notification_observer.h" 11 #include "content/common/notification_registrar.h" 12 #include "ui/gfx/canvas.h" 13 #include "views/controls/label.h" 14 15 class TabContents; 16 17 namespace views { 18 class Widget; 19 } 20 21 // ThemeInstallBubbleView is a view that provides a "Loading..." bubble in the 22 // center of a browser window for use when an extension or theme is loaded. 23 // (The Browser class only calls it to install itself into the currently active 24 // browser window.) If an extension is being applied, the bubble goes away 25 // immediately. If a theme is being applied, it disappears when the theme has 26 // been loaded. The purpose of this bubble is to warn the user that the browser 27 // may be unresponsive while the theme is being installed. 28 // 29 // Edge case: note that if one installs a theme in one window and then switches 30 // rapidly to another window to install a theme there as well (in the short time 31 // between install begin and theme caching seizing the UI thread), the loading 32 // bubble will only appear over the first window, as there is only ever one 33 // instance of the bubble. 34 class ThemeInstallBubbleView : public NotificationObserver, 35 public views::Label { 36 public: 37 virtual ~ThemeInstallBubbleView(); 38 39 // NotificationObserver 40 virtual void Observe(NotificationType type, 41 const NotificationSource& source, 42 const NotificationDetails& details); 43 44 // Show the loading bubble. 45 static void Show(TabContents* tab_contents); 46 47 private: 48 explicit ThemeInstallBubbleView(TabContents* tab_contents); 49 50 // Put the popup in the correct place on the tab. 51 void Reposition(); 52 53 // Inherited from views. 54 virtual gfx::Size GetPreferredSize(); 55 56 // Shut down the popup and remove our notifications. 57 void Close(); 58 59 virtual void OnPaint(gfx::Canvas* canvas); 60 61 // The content area at the start of the animation. 62 gfx::Rect tab_contents_bounds_; 63 64 // Widget containing us. 65 views::Widget* popup_; 66 67 // Text to show warning that theme is being installed. 68 string16 text_; 69 70 // A scoped container for notification registries. 71 NotificationRegistrar registrar_; 72 73 DISALLOW_COPY_AND_ASSIGN(ThemeInstallBubbleView); 74 }; 75 76 #endif // CHROME_BROWSER_UI_VIEWS_THEME_INSTALL_BUBBLE_VIEW_H_ 77