| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/views/theme_install_bubble_view.h" | 5 #include "chrome/browser/ui/views/theme_install_bubble_view.h" |
| 6 | 6 |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "chrome/common/chrome_notification_types.h" | 8 #include "chrome/common/chrome_notification_types.h" |
| 9 #include "content/browser/tab_contents/tab_contents.h" | 9 #include "content/browser/tab_contents/tab_contents.h" |
| 10 #include "content/common/notification_service.h" | 10 #include "content/public/browser/notification_service.h" |
| 11 #include "grit/generated_resources.h" | 11 #include "grit/generated_resources.h" |
| 12 #include "ui/base/l10n/l10n_util.h" | 12 #include "ui/base/l10n/l10n_util.h" |
| 13 #include "ui/base/resource/resource_bundle.h" | 13 #include "ui/base/resource/resource_bundle.h" |
| 14 #include "ui/gfx/canvas_skia.h" | 14 #include "ui/gfx/canvas_skia.h" |
| 15 #include "views/widget/widget.h" | 15 #include "views/widget/widget.h" |
| 16 | 16 |
| 17 namespace { | 17 namespace { |
| 18 | 18 |
| 19 // The roundedness of the edges of our bubble. | 19 // The roundedness of the edges of our bubble. |
| 20 static const int kBubbleCornerRadius = 4; | 20 static const int kBubbleCornerRadius = 4; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 42 // We can't check for the size of tab_contents before we've generated | 42 // We can't check for the size of tab_contents before we've generated |
| 43 // the string and the font that determine the size of the bubble. | 43 // the string and the font that determine the size of the bubble. |
| 44 tab_contents->GetContainerBounds(&tab_contents_bounds_); | 44 tab_contents->GetContainerBounds(&tab_contents_bounds_); |
| 45 if (tab_contents_bounds_.height() < GetPreferredSize().height()) | 45 if (tab_contents_bounds_.height() < GetPreferredSize().height()) |
| 46 Close(); | 46 Close(); |
| 47 | 47 |
| 48 // Close when theme has been installed. | 48 // Close when theme has been installed. |
| 49 registrar_.Add( | 49 registrar_.Add( |
| 50 this, | 50 this, |
| 51 chrome::NOTIFICATION_BROWSER_THEME_CHANGED, | 51 chrome::NOTIFICATION_BROWSER_THEME_CHANGED, |
| 52 NotificationService::AllBrowserContextsAndSources()); | 52 content::NotificationService::AllBrowserContextsAndSources()); |
| 53 | 53 |
| 54 // Close when we are installing an extension, not a theme. | 54 // Close when we are installing an extension, not a theme. |
| 55 registrar_.Add( | 55 registrar_.Add( |
| 56 this, | 56 this, |
| 57 chrome::NOTIFICATION_NO_THEME_DETECTED, | 57 chrome::NOTIFICATION_NO_THEME_DETECTED, |
| 58 NotificationService::AllSources()); | 58 content::NotificationService::AllSources()); |
| 59 registrar_.Add( | 59 registrar_.Add( |
| 60 this, | 60 this, |
| 61 chrome::NOTIFICATION_EXTENSION_INSTALLED, | 61 chrome::NOTIFICATION_EXTENSION_INSTALLED, |
| 62 NotificationService::AllSources()); | 62 content::NotificationService::AllSources()); |
| 63 registrar_.Add( | 63 registrar_.Add( |
| 64 this, | 64 this, |
| 65 chrome::NOTIFICATION_EXTENSION_INSTALL_ERROR, | 65 chrome::NOTIFICATION_EXTENSION_INSTALL_ERROR, |
| 66 NotificationService::AllSources()); | 66 content::NotificationService::AllSources()); |
| 67 | 67 |
| 68 // Don't let the bubble overlap the confirm dialog. | 68 // Don't let the bubble overlap the confirm dialog. |
| 69 registrar_.Add( | 69 registrar_.Add( |
| 70 this, | 70 this, |
| 71 chrome::NOTIFICATION_EXTENSION_WILL_SHOW_CONFIRM_DIALOG, | 71 chrome::NOTIFICATION_EXTENSION_WILL_SHOW_CONFIRM_DIALOG, |
| 72 NotificationService::AllSources()); | 72 content::NotificationService::AllSources()); |
| 73 | 73 |
| 74 popup_ = new views::Widget; | 74 popup_ = new views::Widget; |
| 75 views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP); | 75 views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP); |
| 76 params.transparent = true; | 76 params.transparent = true; |
| 77 params.accept_events = false; | 77 params.accept_events = false; |
| 78 params.parent = tab_contents->GetNativeView(); | 78 params.parent = tab_contents->GetNativeView(); |
| 79 popup_->Init(params); | 79 popup_->Init(params); |
| 80 popup_->SetContentsView(this); | 80 popup_->SetContentsView(this); |
| 81 popup_->SetOpacity(0xCC); | 81 popup_->SetOpacity(0xCC); |
| 82 Reposition(); | 82 Reposition(); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 const content::NotificationDetails& details) { | 163 const content::NotificationDetails& details) { |
| 164 Close(); | 164 Close(); |
| 165 } | 165 } |
| 166 | 166 |
| 167 // static | 167 // static |
| 168 void ThemeInstallBubbleView::Show(TabContents* tab_contents) { | 168 void ThemeInstallBubbleView::Show(TabContents* tab_contents) { |
| 169 ++num_loads_extant_; | 169 ++num_loads_extant_; |
| 170 if (num_loads_extant_ < 2) | 170 if (num_loads_extant_ < 2) |
| 171 new ThemeInstallBubbleView(tab_contents); | 171 new ThemeInstallBubbleView(tab_contents); |
| 172 } | 172 } |
| OLD | NEW |