| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/i18n/rtl.h" | 5 #include "base/i18n/rtl.h" |
| 6 #include "base/utf_string_conversions.h" | 6 #include "base/utf_string_conversions.h" |
| 7 #include "chrome/browser/extensions/bundle_installer.h" | 7 #include "chrome/browser/extensions/bundle_installer.h" |
| 8 #include "chrome/browser/ui/browser.h" | 8 #include "chrome/browser/ui/browser.h" |
| 9 #include "chrome/browser/ui/views/frame/browser_view.h" | 9 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 10 #include "chrome/browser/ui/views/toolbar_view.h" | 10 #include "chrome/browser/ui/views/toolbar_view.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 using views::GridLayout; | 25 using views::GridLayout; |
| 26 | 26 |
| 27 namespace { | 27 namespace { |
| 28 | 28 |
| 29 // The ID of the column set for the bubble. | 29 // The ID of the column set for the bubble. |
| 30 const int kColumnSetId = 0; | 30 const int kColumnSetId = 0; |
| 31 | 31 |
| 32 // The width of the left column. | 32 // The width of the left column. |
| 33 const int kLeftColumnWidth = 325; | 33 const int kLeftColumnWidth = 325; |
| 34 | 34 |
| 35 // Heading font size correction. | |
| 36 const int kHeadingFontSizeDelta = 1; | |
| 37 | |
| 38 class BundleInstalledBubble : public views::BubbleDelegateView, | 35 class BundleInstalledBubble : public views::BubbleDelegateView, |
| 39 public views::ButtonListener { | 36 public views::ButtonListener { |
| 40 public: | 37 public: |
| 41 BundleInstalledBubble(const BundleInstaller* bundle, | 38 BundleInstalledBubble(const BundleInstaller* bundle, |
| 42 View* anchor_view, | 39 View* anchor_view, |
| 43 views::BubbleBorder::ArrowLocation arrow_location) | 40 views::BubbleBorder::ArrowLocation arrow_location) |
| 44 : views::BubbleDelegateView(anchor_view, arrow_location) { | 41 : views::BubbleDelegateView(anchor_view, arrow_location) { |
| 45 GridLayout* layout = GridLayout::CreatePanel(this); | 42 GridLayout* layout = GridLayout::CreatePanel(this); |
| 46 SetLayoutManager(layout); | 43 SetLayoutManager(layout); |
| 47 views::ColumnSet* column_set = layout->AddColumnSet(kColumnSetId); | 44 views::ColumnSet* column_set = layout->AddColumnSet(kColumnSetId); |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 rb.GetImageSkiaNamed(IDR_CLOSE_BAR)); | 126 rb.GetImageSkiaNamed(IDR_CLOSE_BAR)); |
| 130 button->SetImage(views::CustomButton::STATE_HOVERED, | 127 button->SetImage(views::CustomButton::STATE_HOVERED, |
| 131 rb.GetImageSkiaNamed(IDR_CLOSE_BAR_H)); | 128 rb.GetImageSkiaNamed(IDR_CLOSE_BAR_H)); |
| 132 button->SetImage(views::CustomButton::STATE_PRESSED, | 129 button->SetImage(views::CustomButton::STATE_PRESSED, |
| 133 rb.GetImageSkiaNamed(IDR_CLOSE_BAR_P)); | 130 rb.GetImageSkiaNamed(IDR_CLOSE_BAR_P)); |
| 134 layout->AddView(button); | 131 layout->AddView(button); |
| 135 } | 132 } |
| 136 | 133 |
| 137 void AddHeading(GridLayout* layout, const string16& heading) { | 134 void AddHeading(GridLayout* layout, const string16& heading) { |
| 138 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 135 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 139 gfx::Font bold_font = rb.GetFont(ui::ResourceBundle::BaseFont).DeriveFont( | 136 views::Label* heading_label = new views::Label( |
| 140 kHeadingFontSizeDelta, gfx::Font::BOLD); | 137 heading, rb.GetFont(ui::ResourceBundle::MediumFont)); |
| 141 | |
| 142 views::Label* heading_label = new views::Label(heading, bold_font); | |
| 143 heading_label->SetMultiLine(true); | 138 heading_label->SetMultiLine(true); |
| 144 heading_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 139 heading_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 145 heading_label->SizeToFit(kLeftColumnWidth); | 140 heading_label->SizeToFit(kLeftColumnWidth); |
| 146 layout->AddView(heading_label); | 141 layout->AddView(heading_label); |
| 147 } | 142 } |
| 148 | 143 |
| 149 // views::ButtonListener implementation: | 144 // views::ButtonListener implementation: |
| 150 virtual void ButtonPressed(views::Button* sender, | 145 virtual void ButtonPressed(views::Button* sender, |
| 151 const ui::Event& event) OVERRIDE { | 146 const ui::Event& event) OVERRIDE { |
| 152 StartFade(false); | 147 StartFade(false); |
| 153 } | 148 } |
| 154 | 149 |
| 155 DISALLOW_COPY_AND_ASSIGN(BundleInstalledBubble); | 150 DISALLOW_COPY_AND_ASSIGN(BundleInstalledBubble); |
| 156 }; | 151 }; |
| 157 | 152 |
| 158 } // namespace | 153 } // namespace |
| 159 | 154 |
| 160 void BundleInstaller::ShowInstalledBubble( | 155 void BundleInstaller::ShowInstalledBubble( |
| 161 const BundleInstaller* bundle, Browser* browser) { | 156 const BundleInstaller* bundle, Browser* browser) { |
| 162 BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser); | 157 BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser); |
| 163 views::View* anchor = browser_view->GetToolbarView()->app_menu(); | 158 views::View* anchor = browser_view->GetToolbarView()->app_menu(); |
| 164 new BundleInstalledBubble(bundle, anchor, views::BubbleBorder::TOP_RIGHT); | 159 new BundleInstalledBubble(bundle, anchor, views::BubbleBorder::TOP_RIGHT); |
| 165 } | 160 } |
| OLD | NEW |