Commit c4e6c22a authored by sashab's avatar sashab Committed by Commit bot

Made the 'Licenses' link in the App Info dialog open all licenses

Currently, the 'Licenses' link in the App Info dialog only opens the
license page of the first shared module the app uses. Changed it to open
all licenses for shared modules that provide them in separate tabs, then
close the dialog.

BUG=422116

Review URL: https://codereview.chromium.org/653293004

Cr-Commit-Position: refs/heads/master@{#300660}
parent 53164221
......@@ -173,6 +173,7 @@ void AppInfoHeaderPanel::ShowAppInWebStore() {
extensions::ManifestURL::GetDetailsURL(app_),
extension_urls::kWebstoreSourceField,
extension_urls::kLaunchSourceAppListInfoDialog));
Close();
}
bool AppInfoHeaderPanel::CanShowAppInWebStore() const {
......@@ -182,6 +183,7 @@ bool AppInfoHeaderPanel::CanShowAppInWebStore() const {
void AppInfoHeaderPanel::ShowAppHomePage() {
DCHECK(CanShowAppHomePage());
OpenLink(extensions::ManifestURL::GetHomepageURL(app_));
Close();
}
bool AppInfoHeaderPanel::CanShowAppHomePage() const {
......@@ -190,34 +192,40 @@ bool AppInfoHeaderPanel::CanShowAppHomePage() const {
void AppInfoHeaderPanel::DisplayLicenses() {
DCHECK(CanDisplayLicenses());
OpenLink(GetLicenseUrl());
for (const auto& license_url : GetLicenseUrls())
OpenLink(license_url);
Close();
}
bool AppInfoHeaderPanel::CanDisplayLicenses() const {
return !GetLicenseUrl().is_empty();
return !GetLicenseUrls().empty();
}
const GURL& AppInfoHeaderPanel::GetLicenseUrl() const {
// Find the first shared module for this app, and return its URL.
// TODO(sashab): Support multiple shared modules with licenses once shared
// module usage becomes more common.
const std::vector<GURL> AppInfoHeaderPanel::GetLicenseUrls() const {
if (!extensions::SharedModuleInfo::ImportsModules(app_))
return GURL::EmptyGURL();
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_);
const extensions::Extension* imported_module =
service->GetExtensionById(imports[0].extension_id, true);
DCHECK(imported_module);
return extensions::ManifestURL::GetAboutPage(imported_module);
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;
}
void AppInfoHeaderPanel::OpenLink(const GURL& url) {
DCHECK(!url.is_empty());
chrome::NavigateParams params(profile_, url, ui::PAGE_TRANSITION_LINK);
chrome::Navigate(&params);
Close();
}
......@@ -58,9 +58,9 @@ class AppInfoHeaderPanel : public AppInfoPanel,
// CanDisplayLicenses() returns true.
void DisplayLicenses();
bool CanDisplayLicenses() const;
const GURL& GetLicenseUrl() const;
const std::vector<GURL> GetLicenseUrls() const;
// Opens the given URL in a new browser tab, and closes the dialog.
// Opens the given URL in a new browser tab.
void OpenLink(const GURL& url);
// UI elements on the dialog. Elements are NULL if they are not displayed.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment