| 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 "chrome/browser/ui/views/extensions/extension_install_dialog_view.h" | 5 #include "chrome/browser/ui/views/extensions/extension_install_dialog_view.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <algorithm> | 8 #include <algorithm> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/callback_helpers.h" | 13 #include "base/callback_helpers.h" |
| 14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
| 15 #include "base/compiler_specific.h" | 15 #include "base/compiler_specific.h" |
| 16 #include "base/i18n/rtl.h" | 16 #include "base/i18n/rtl.h" |
| 17 #include "base/macros.h" | 17 #include "base/macros.h" |
| 18 #include "base/metrics/histogram_macros.h" | 18 #include "base/metrics/histogram_macros.h" |
| 19 #include "base/strings/string_util.h" | 19 #include "base/strings/string_util.h" |
| 20 #include "base/strings/utf_string_conversions.h" | 20 #include "base/strings/utf_string_conversions.h" |
| 21 #include "chrome/app/vector_icons/vector_icons.h" | 21 #include "chrome/app/vector_icons/vector_icons.h" |
| 22 #include "chrome/browser/browser_process.h" | 22 #include "chrome/browser/browser_process.h" |
| 23 #include "chrome/browser/extensions/api/experience_sampling_private/experience_s
ampling.h" | 23 #include "chrome/browser/extensions/api/experience_sampling_private/experience_s
ampling.h" |
| 24 #include "chrome/browser/extensions/extension_install_prompt_show_params.h" | 24 #include "chrome/browser/extensions/extension_install_prompt_show_params.h" |
| 25 #include "chrome/browser/profiles/profile.h" | 25 #include "chrome/browser/profiles/profile.h" |
| 26 #include "chrome/browser/ui/browser.h" | 26 #include "chrome/browser/ui/browser.h" |
| 27 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" | 27 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" |
| 28 #include "chrome/browser/ui/views/harmony/chrome_typography.h" |
| 28 #include "chrome/browser/ui/views/harmony/layout_delegate.h" | 29 #include "chrome/browser/ui/views/harmony/layout_delegate.h" |
| 29 #include "chrome/common/extensions/extension_constants.h" | 30 #include "chrome/common/extensions/extension_constants.h" |
| 30 #include "chrome/grit/generated_resources.h" | 31 #include "chrome/grit/generated_resources.h" |
| 31 #include "components/constrained_window/constrained_window_views.h" | 32 #include "components/constrained_window/constrained_window_views.h" |
| 32 #include "content/public/browser/browser_thread.h" | 33 #include "content/public/browser/browser_thread.h" |
| 33 #include "content/public/browser/page_navigator.h" | 34 #include "content/public/browser/page_navigator.h" |
| 34 #include "content/public/browser/web_contents.h" | 35 #include "content/public/browser/web_contents.h" |
| 35 #include "extensions/common/extension.h" | 36 #include "extensions/common/extension.h" |
| 36 #include "extensions/common/extension_urls.h" | 37 #include "extensions/common/extension_urls.h" |
| 37 #include "ui/base/l10n/l10n_util.h" | 38 #include "ui/base/l10n/l10n_util.h" |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 225 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 225 | 226 |
| 226 if (prompt_->has_webstore_data()) { | 227 if (prompt_->has_webstore_data()) { |
| 227 layout->StartRow(0, column_set_id); | 228 layout->StartRow(0, column_set_id); |
| 228 views::View* rating = new views::View(); | 229 views::View* rating = new views::View(); |
| 229 rating->SetLayoutManager(new views::BoxLayout( | 230 rating->SetLayoutManager(new views::BoxLayout( |
| 230 views::BoxLayout::kHorizontal, 0, 0, 0)); | 231 views::BoxLayout::kHorizontal, 0, 0, 0)); |
| 231 layout->AddView(rating); | 232 layout->AddView(rating); |
| 232 prompt_->AppendRatingStars(AddResourceIcon, rating); | 233 prompt_->AppendRatingStars(AddResourceIcon, rating); |
| 233 | 234 |
| 234 const gfx::FontList& small_font_list = | 235 int rating_text_context, user_count_text_context; |
| 235 rb.GetFontList(ui::ResourceBundle::SmallFont); | 236 if (LayoutDelegate::Get()->IsHarmonyMode()) { |
| 237 rating_text_context = CONTEXT_BODY_TEXT_LARGE; |
| 238 user_count_text_context = CONTEXT_BODY_TEXT_SMALL; |
| 239 } else { |
| 240 rating_text_context = user_count_text_context = CONTEXT_DEPRECATED_SMALL; |
| 241 } |
| 236 views::Label* rating_count = | 242 views::Label* rating_count = |
| 237 new views::Label(prompt_->GetRatingCount(), small_font_list); | 243 new views::Label(prompt_->GetRatingCount(), rating_text_context, |
| 244 views::style::STYLE_PRIMARY); |
| 238 // Add some space between the stars and the rating count. | 245 // Add some space between the stars and the rating count. |
| 239 rating_count->SetBorder(views::CreateEmptyBorder(0, 2, 0, 0)); | 246 rating_count->SetBorder(views::CreateEmptyBorder(0, 2, 0, 0)); |
| 240 rating->AddChildView(rating_count); | 247 rating->AddChildView(rating_count); |
| 241 | 248 |
| 242 layout->StartRow(0, column_set_id); | 249 layout->StartRow(0, column_set_id); |
| 243 views::Label* user_count = | 250 views::Label* user_count = new views::Label( |
| 244 new views::Label(prompt_->GetUserCount(), small_font_list); | 251 prompt_->GetUserCount(), user_count_text_context, STYLE_SECONDARY); |
| 245 user_count->SetAutoColorReadabilityEnabled(false); | 252 user_count->SetAutoColorReadabilityEnabled(false); |
| 246 user_count->SetEnabledColor(SK_ColorGRAY); | 253 user_count->SetEnabledColor(SK_ColorGRAY); |
| 247 layout->AddView(user_count); | 254 layout->AddView(user_count); |
| 248 } | 255 } |
| 249 | 256 |
| 250 if (prompt_->ShouldShowPermissions()) { | 257 if (prompt_->ShouldShowPermissions()) { |
| 251 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 258 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
| 252 layout->StartRow(0, column_set_id); | 259 layout->StartRow(0, column_set_id); |
| 253 layout->AddView(new views::Separator(), 3, 1, views::GridLayout::FILL, | 260 layout->AddView(new views::Separator(), 3, 1, views::GridLayout::FILL, |
| 254 views::GridLayout::FILL); | 261 views::GridLayout::FILL); |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 435 0, LayoutDelegate::Get()->GetMetric( | 442 0, LayoutDelegate::Get()->GetMetric( |
| 436 LayoutDelegate::Metric::PANEL_CONTENT_MARGIN)); | 443 LayoutDelegate::Metric::PANEL_CONTENT_MARGIN)); |
| 437 column_set->AddColumn(views::GridLayout::TRAILING, views::GridLayout::LEADING, | 444 column_set->AddColumn(views::GridLayout::TRAILING, views::GridLayout::LEADING, |
| 438 0, // no resizing | 445 0, // no resizing |
| 439 views::GridLayout::USE_PREF, | 446 views::GridLayout::USE_PREF, |
| 440 0, // no fixed width | 447 0, // no fixed width |
| 441 kIconSize); | 448 kIconSize); |
| 442 column_set->AddPaddingColumn(0, views::kButtonHEdgeMarginNew); | 449 column_set->AddPaddingColumn(0, views::kButtonHEdgeMarginNew); |
| 443 | 450 |
| 444 layout->StartRow(0, column_set_id); | 451 layout->StartRow(0, column_set_id); |
| 445 views::Label* title = | 452 views::Label* title = new views::Label(prompt_->GetDialogTitle(), |
| 446 new views::Label(prompt_->GetDialogTitle(), | 453 views::style::CONTEXT_DIALOG_TITLE); |
| 447 ui::ResourceBundle::GetSharedInstance().GetFontList( | |
| 448 ui::ResourceBundle::MediumFont)); | |
| 449 title->SetMultiLine(true); | 454 title->SetMultiLine(true); |
| 450 title->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 455 title->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 451 title->SizeToFit(left_column_width); | 456 title->SizeToFit(left_column_width); |
| 452 | 457 |
| 453 // Center align the title along the vertical axis. | 458 // Center align the title along the vertical axis. |
| 454 layout->AddView(title, 1, 1, views::GridLayout::LEADING, | 459 layout->AddView(title, 1, 1, views::GridLayout::LEADING, |
| 455 views::GridLayout::CENTER); | 460 views::GridLayout::CENTER); |
| 456 | 461 |
| 457 // Scale down to icon size, but allow smaller icons (don't scale up). | 462 // Scale down to icon size, but allow smaller icons (don't scale up). |
| 458 const gfx::ImageSkia* image = prompt_->icon().ToImageSkia(); | 463 const gfx::ImageSkia* image = prompt_->icon().ToImageSkia(); |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 740 gfx::ImageSkia icon = gfx::CreateVectorIcon( | 745 gfx::ImageSkia icon = gfx::CreateVectorIcon( |
| 741 expanded ? kCaretUpIcon : kCaretDownIcon, gfx::kChromeIconGrey); | 746 expanded ? kCaretUpIcon : kCaretDownIcon, gfx::kChromeIconGrey); |
| 742 arrow_toggle_->SetImage(views::Button::STATE_NORMAL, &icon); | 747 arrow_toggle_->SetImage(views::Button::STATE_NORMAL, &icon); |
| 743 } | 748 } |
| 744 | 749 |
| 745 // static | 750 // static |
| 746 ExtensionInstallPrompt::ShowDialogCallback | 751 ExtensionInstallPrompt::ShowDialogCallback |
| 747 ExtensionInstallPrompt::GetViewsShowDialogCallback() { | 752 ExtensionInstallPrompt::GetViewsShowDialogCallback() { |
| 748 return base::Bind(&ShowExtensionInstallDialogImpl); | 753 return base::Bind(&ShowExtensionInstallDialogImpl); |
| 749 } | 754 } |
| OLD | NEW |