| 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/extensions/extension_installed_bubble.h" | 5 #include "chrome/browser/ui/views/extensions/extension_installed_bubble.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | |
| 9 | 8 |
| 10 #include "base/i18n/rtl.h" | 9 #include "base/i18n/rtl.h" |
| 11 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| 12 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
| 13 #include "chrome/browser/extensions/extension_install_ui.h" | 12 #include "chrome/browser/extensions/extension_install_ui.h" |
| 14 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/browser/ui/browser.h" | 14 #include "chrome/browser/ui/browser.h" |
| 16 #include "chrome/browser/ui/browser_window.h" | 15 #include "chrome/browser/ui/browser_window.h" |
| 17 #include "chrome/browser/ui/views/browser_actions_container.h" | 16 #include "chrome/browser/ui/views/browser_actions_container.h" |
| 18 #include "chrome/browser/ui/views/frame/browser_view.h" | 17 #include "chrome/browser/ui/views/frame/browser_view.h" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 namespace browser { | 69 namespace browser { |
| 71 | 70 |
| 72 void ShowExtensionInstalledBubble( | 71 void ShowExtensionInstalledBubble( |
| 73 const Extension* extension, | 72 const Extension* extension, |
| 74 Browser* browser, | 73 Browser* browser, |
| 75 const SkBitmap& icon, | 74 const SkBitmap& icon, |
| 76 Profile* profile) { | 75 Profile* profile) { |
| 77 ExtensionInstalledBubble::Show(extension, browser, icon); | 76 ExtensionInstalledBubble::Show(extension, browser, icon); |
| 78 } | 77 } |
| 79 | 78 |
| 80 } // namespace browser | 79 } // namespace browser |
| 81 | 80 |
| 82 // InstalledBubbleContent is the content view which is placed in the | 81 // InstalledBubbleContent is the content view which is placed in the |
| 83 // ExtensionInstalledBubble. It displays the install icon and explanatory | 82 // ExtensionInstalledBubble. It displays the install icon and explanatory |
| 84 // text about the installed extension. | 83 // text about the installed extension. |
| 85 class InstalledBubbleContent : public views::View, | 84 class InstalledBubbleContent : public views::View, |
| 86 public views::ButtonListener, | 85 public views::ButtonListener, |
| 87 public views::LinkListener { | 86 public views::LinkListener { |
| 88 public: | 87 public: |
| 89 InstalledBubbleContent(Browser* browser, | 88 InstalledBubbleContent(Browser* browser, |
| 90 const Extension* extension, | 89 const Extension* extension, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 102 gfx::Size size(icon->width(), icon->height()); | 101 gfx::Size size(icon->width(), icon->height()); |
| 103 if (size.width() > kIconSize || size.height() > kIconSize) | 102 if (size.width() > kIconSize || size.height() > kIconSize) |
| 104 size = gfx::Size(kIconSize, kIconSize); | 103 size = gfx::Size(kIconSize, kIconSize); |
| 105 icon_ = new views::ImageView(); | 104 icon_ = new views::ImageView(); |
| 106 icon_->SetImageSize(size); | 105 icon_->SetImageSize(size); |
| 107 icon_->SetImage(*icon); | 106 icon_->SetImage(*icon); |
| 108 AddChildView(icon_); | 107 AddChildView(icon_); |
| 109 | 108 |
| 110 string16 extension_name = UTF8ToUTF16(extension->name()); | 109 string16 extension_name = UTF8ToUTF16(extension->name()); |
| 111 base::i18n::AdjustStringForLocaleDirection(&extension_name); | 110 base::i18n::AdjustStringForLocaleDirection(&extension_name); |
| 112 heading_ = new views::Label( | 111 heading_ = new views::Label(UTF16ToWide( |
| 113 l10n_util::GetStringFUTF16(IDS_EXTENSION_INSTALLED_HEADING, | 112 l10n_util::GetStringFUTF16(IDS_EXTENSION_INSTALLED_HEADING, |
| 114 extension_name)); | 113 extension_name))); |
| 115 heading_->SetFont(rb.GetFont(ResourceBundle::MediumFont)); | 114 heading_->SetFont(rb.GetFont(ResourceBundle::MediumFont)); |
| 116 heading_->SetMultiLine(true); | 115 heading_->SetMultiLine(true); |
| 117 heading_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); | 116 heading_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); |
| 118 AddChildView(heading_); | 117 AddChildView(heading_); |
| 119 | 118 |
| 120 switch (type_) { | 119 switch (type_) { |
| 121 case ExtensionInstalledBubble::PAGE_ACTION: { | 120 case ExtensionInstalledBubble::PAGE_ACTION: { |
| 122 info_ = new views::Label(l10n_util::GetStringUTF16( | 121 info_ = new views::Label(UTF16ToWide(l10n_util::GetStringUTF16( |
| 123 IDS_EXTENSION_INSTALLED_PAGE_ACTION_INFO)); | 122 IDS_EXTENSION_INSTALLED_PAGE_ACTION_INFO))); |
| 124 info_->SetFont(font); | 123 info_->SetFont(font); |
| 125 info_->SetMultiLine(true); | 124 info_->SetMultiLine(true); |
| 126 info_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); | 125 info_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); |
| 127 AddChildView(info_); | 126 AddChildView(info_); |
| 128 break; | 127 break; |
| 129 } | 128 } |
| 130 case ExtensionInstalledBubble::OMNIBOX_KEYWORD: { | 129 case ExtensionInstalledBubble::OMNIBOX_KEYWORD: { |
| 131 info_ = new views::Label(l10n_util::GetStringFUTF16( | 130 info_ = new views::Label(UTF16ToWide(l10n_util::GetStringFUTF16( |
| 132 IDS_EXTENSION_INSTALLED_OMNIBOX_KEYWORD_INFO, | 131 IDS_EXTENSION_INSTALLED_OMNIBOX_KEYWORD_INFO, |
| 133 UTF8ToUTF16(extension->omnibox_keyword()))); | 132 UTF8ToUTF16(extension->omnibox_keyword())))); |
| 134 info_->SetFont(font); | 133 info_->SetFont(font); |
| 135 info_->SetMultiLine(true); | 134 info_->SetMultiLine(true); |
| 136 info_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); | 135 info_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); |
| 137 AddChildView(info_); | 136 AddChildView(info_); |
| 138 break; | 137 break; |
| 139 } | 138 } |
| 140 case ExtensionInstalledBubble::APP: { | 139 case ExtensionInstalledBubble::APP: { |
| 141 views::Link* link = new views::Link( | 140 views::Link* link = new views::Link(UTF16ToWide( |
| 142 l10n_util::GetStringUTF16(IDS_EXTENSION_INSTALLED_APP_INFO)); | 141 l10n_util::GetStringUTF16(IDS_EXTENSION_INSTALLED_APP_INFO))); |
| 143 link->set_listener(this); | 142 link->set_listener(this); |
| 144 manage_ = link; | 143 manage_ = link; |
| 145 manage_->SetFont(font); | 144 manage_->SetFont(font); |
| 146 manage_->SetMultiLine(true); | 145 manage_->SetMultiLine(true); |
| 147 manage_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); | 146 manage_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); |
| 148 AddChildView(manage_); | 147 AddChildView(manage_); |
| 149 break; | 148 break; |
| 150 } | 149 } |
| 151 default: | 150 default: |
| 152 break; | 151 break; |
| 153 } | 152 } |
| 154 | 153 |
| 155 if (type_ != ExtensionInstalledBubble::APP) { | 154 if (type_ != ExtensionInstalledBubble::APP) { |
| 156 manage_ = new views::Label( | 155 manage_ = new views::Label(UTF16ToWide( |
| 157 l10n_util::GetStringUTF16(IDS_EXTENSION_INSTALLED_MANAGE_INFO)); | 156 l10n_util::GetStringUTF16(IDS_EXTENSION_INSTALLED_MANAGE_INFO))); |
| 158 manage_->SetFont(font); | 157 manage_->SetFont(font); |
| 159 manage_->SetMultiLine(true); | 158 manage_->SetMultiLine(true); |
| 160 manage_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); | 159 manage_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); |
| 161 AddChildView(manage_); | 160 AddChildView(manage_); |
| 162 } | 161 } |
| 163 | 162 |
| 164 close_button_ = new views::ImageButton(this); | 163 close_button_ = new views::ImageButton(this); |
| 165 close_button_->SetImage(views::CustomButton::BS_NORMAL, | 164 close_button_->SetImage(views::CustomButton::BS_NORMAL, |
| 166 rb.GetBitmapNamed(IDR_CLOSE_BAR)); | 165 rb.GetBitmapNamed(IDR_CLOSE_BAR)); |
| 167 close_button_->SetImage(views::CustomButton::BS_HOT, | 166 close_button_->SetImage(views::CustomButton::BS_HOT, |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 Release(); // Balanced in ctor. | 421 Release(); // Balanced in ctor. |
| 423 } | 422 } |
| 424 | 423 |
| 425 bool ExtensionInstalledBubble::CloseOnEscape() { | 424 bool ExtensionInstalledBubble::CloseOnEscape() { |
| 426 return true; | 425 return true; |
| 427 } | 426 } |
| 428 | 427 |
| 429 bool ExtensionInstalledBubble::FadeInOnShow() { | 428 bool ExtensionInstalledBubble::FadeInOnShow() { |
| 430 return true; | 429 return true; |
| 431 } | 430 } |
| OLD | NEW |