Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(889)

Unified Diff: chrome/browser/ui/views/apps/app_info_dialog/app_info_summary_panel.cc

Issue 691253002: Move the Developer Website and Licenses links in the App Info dialog (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/views/apps/app_info_dialog/app_info_summary_panel.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/apps/app_info_dialog/app_info_summary_panel.cc
diff --git a/chrome/browser/ui/views/apps/app_info_dialog/app_info_summary_panel.cc b/chrome/browser/ui/views/apps/app_info_dialog/app_info_summary_panel.cc
index fae9adcb79267eedbeeb9440305679d8057c54c4..797ddea81f3592770f153982cc488f2095ed8a48 100644
--- a/chrome/browser/ui/views/apps/app_info_dialog/app_info_summary_panel.cc
+++ b/chrome/browser/ui/views/apps/app_info_dialog/app_info_summary_panel.cc
@@ -22,11 +22,14 @@
#include "extensions/browser/extension_system.h"
#include "extensions/common/extension.h"
#include "extensions/common/manifest.h"
+#include "extensions/common/manifest_handlers/shared_module_info.h"
+#include "extensions/common/manifest_url_handlers.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/models/combobox_model.h"
#include "ui/base/text/bytes_formatting.h"
#include "ui/views/controls/combobox/combobox.h"
#include "ui/views/controls/label.h"
+#include "ui/views/controls/link.h"
#include "ui/views/layout/box_layout.h"
#include "ui/views/layout/layout_constants.h"
#include "ui/views/view.h"
@@ -128,6 +131,8 @@ AppInfoSummaryPanel::AppInfoSummaryPanel(Profile* profile,
const extensions::Extension* app)
: AppInfoPanel(profile, app),
size_value_(NULL),
+ homepage_link_(NULL),
+ licenses_link_(NULL),
launch_options_combobox_(NULL),
weak_ptr_factory_(this) {
SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical,
@@ -143,24 +148,48 @@ AppInfoSummaryPanel::~AppInfoSummaryPanel() {
RemoveAllChildViews(true);
}
-void AppInfoSummaryPanel::AddDescriptionControl(views::View* vertical_stack) {
- if (app_->description().empty())
- return;
+void AppInfoSummaryPanel::AddDescriptionAndLinksControl(
+ views::View* vertical_stack) {
+ views::View* description_and_labels_stack = new views::View();
+ description_and_labels_stack->SetLayoutManager(
+ new views::BoxLayout(views::BoxLayout::kVertical,
+ 0,
+ 0,
+ views::kRelatedControlSmallVerticalSpacing));
+
+ if (!app_->description().empty()) {
+ // TODO(sashab): Clip the app's description to 4 lines, and use Label's
+ // built-in elide behavior to add ellipses at the end: crbug.com/358053
+ const size_t max_length = 400;
+ base::string16 text = base::UTF8ToUTF16(app_->description());
+ if (text.length() > max_length) {
+ text = text.substr(0, max_length);
+ text += base::ASCIIToUTF16(" ... ");
+ }
+
+ views::Label* description_label = new views::Label(text);
+ description_label->SetMultiLine(true);
+ description_label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
+ description_and_labels_stack->AddChildView(description_label);
+ }
- // TODO(sashab): Clip the app's description to 4 lines, and use Label's
- // built-in elide behavior to add ellipses at the end: crbug.com/358053
- const size_t max_length = 400;
- base::string16 text = base::UTF8ToUTF16(app_->description());
- if (text.length() > max_length) {
- text = text.substr(0, max_length);
- text += base::ASCIIToUTF16(" ... ");
+ if (CanShowAppHomePage()) {
+ homepage_link_ = new views::Link(
+ l10n_util::GetStringUTF16(IDS_APPLICATION_INFO_HOMEPAGE_LINK));
+ homepage_link_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
+ homepage_link_->set_listener(this);
+ description_and_labels_stack->AddChildView(homepage_link_);
}
- views::Label* description_label = new views::Label(text);
- description_label->SetMultiLine(true);
- description_label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
+ if (CanDisplayLicenses()) {
+ licenses_link_ = new views::Link(
+ l10n_util::GetStringUTF16(IDS_APPLICATION_INFO_LICENSES_BUTTON_TEXT));
+ licenses_link_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
+ licenses_link_->set_listener(this);
+ description_and_labels_stack->AddChildView(licenses_link_);
+ }
- vertical_stack->AddChildView(description_label);
+ vertical_stack->AddChildView(description_and_labels_stack);
}
void AppInfoSummaryPanel::AddDetailsControl(views::View* vertical_stack) {
@@ -222,7 +251,7 @@ void AppInfoSummaryPanel::AddSubviews() {
CreateVerticalStack(views::kUnrelatedControlVerticalSpacing);
AddChildView(vertical_stack);
- AddDescriptionControl(vertical_stack);
+ AddDescriptionAndLinksControl(vertical_stack);
AddDetailsControl(vertical_stack);
AddLaunchOptionControl(vertical_stack);
}
@@ -236,6 +265,16 @@ void AppInfoSummaryPanel::OnPerformAction(views::Combobox* combobox) {
}
}
+void AppInfoSummaryPanel::LinkClicked(views::Link* source, int event_flags) {
+ if (source == homepage_link_) {
+ ShowAppHomePage();
+ } else if (source == licenses_link_) {
+ DisplayLicenses();
+ } else {
+ NOTREACHED();
+ }
+}
+
void AppInfoSummaryPanel::StartCalculatingAppSize() {
base::PostTaskAndReplyWithResult(
content::BrowserThread::GetBlockingPool(),
@@ -274,3 +313,46 @@ bool AppInfoSummaryPanel::CanSetLaunchType() const {
return !app_->is_platform_app() && !app_->is_extension() &&
app_->id() != extension_misc::kChromeAppId;
}
+void AppInfoSummaryPanel::ShowAppHomePage() {
+ DCHECK(CanShowAppHomePage());
+ OpenLink(extensions::ManifestURL::GetHomepageURL(app_));
+ Close();
+}
+
+bool AppInfoSummaryPanel::CanShowAppHomePage() const {
+ return extensions::ManifestURL::SpecifiedHomepageURL(app_);
+}
+
+void AppInfoSummaryPanel::DisplayLicenses() {
+ DCHECK(CanDisplayLicenses());
+ for (const auto& license_url : GetLicenseUrls())
+ OpenLink(license_url);
+ Close();
+}
+
+bool AppInfoSummaryPanel::CanDisplayLicenses() const {
+ return !GetLicenseUrls().empty();
+}
+
+const std::vector<GURL> AppInfoSummaryPanel::GetLicenseUrls() const {
+ if (!extensions::SharedModuleInfo::ImportsModules(app_))
+ return std::vector<GURL>();
+
+ std::vector<GURL> license_urls;
+ ExtensionService* service =
+ extensions::ExtensionSystem::Get(profile_)->extension_service();
+ DCHECK(service);
+ const std::vector<extensions::SharedModuleInfo::ImportInfo>& imports =
+ extensions::SharedModuleInfo::GetImports(app_);
+
+ for (const auto& shared_module : imports) {
+ const extensions::Extension* imported_module =
+ service->GetExtensionById(shared_module.extension_id, true);
+ DCHECK(imported_module);
+
+ GURL about_page = extensions::ManifestURL::GetAboutPage(imported_module);
+ if (about_page != GURL::EmptyGURL())
+ license_urls.push_back(about_page);
+ }
+ return license_urls;
+}
« no previous file with comments | « chrome/browser/ui/views/apps/app_info_dialog/app_info_summary_panel.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698