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() { ...@@ -173,6 +173,7 @@ void AppInfoHeaderPanel::ShowAppInWebStore() {
extensions::ManifestURL::GetDetailsURL(app_), extensions::ManifestURL::GetDetailsURL(app_),
extension_urls::kWebstoreSourceField, extension_urls::kWebstoreSourceField,
extension_urls::kLaunchSourceAppListInfoDialog)); extension_urls::kLaunchSourceAppListInfoDialog));
Close();
} }
bool AppInfoHeaderPanel::CanShowAppInWebStore() const { bool AppInfoHeaderPanel::CanShowAppInWebStore() const {
...@@ -182,6 +183,7 @@ bool AppInfoHeaderPanel::CanShowAppInWebStore() const { ...@@ -182,6 +183,7 @@ bool AppInfoHeaderPanel::CanShowAppInWebStore() const {
void AppInfoHeaderPanel::ShowAppHomePage() { void AppInfoHeaderPanel::ShowAppHomePage() {
DCHECK(CanShowAppHomePage()); DCHECK(CanShowAppHomePage());
OpenLink(extensions::ManifestURL::GetHomepageURL(app_)); OpenLink(extensions::ManifestURL::GetHomepageURL(app_));
Close();
} }
bool AppInfoHeaderPanel::CanShowAppHomePage() const { bool AppInfoHeaderPanel::CanShowAppHomePage() const {
...@@ -190,34 +192,40 @@ bool AppInfoHeaderPanel::CanShowAppHomePage() const { ...@@ -190,34 +192,40 @@ bool AppInfoHeaderPanel::CanShowAppHomePage() const {
void AppInfoHeaderPanel::DisplayLicenses() { void AppInfoHeaderPanel::DisplayLicenses() {
DCHECK(CanDisplayLicenses()); DCHECK(CanDisplayLicenses());
OpenLink(GetLicenseUrl()); for (const auto& license_url : GetLicenseUrls())
OpenLink(license_url);
Close();
} }
bool AppInfoHeaderPanel::CanDisplayLicenses() const { bool AppInfoHeaderPanel::CanDisplayLicenses() const {
return !GetLicenseUrl().is_empty(); return !GetLicenseUrls().empty();
} }
const GURL& AppInfoHeaderPanel::GetLicenseUrl() const { const std::vector<GURL> AppInfoHeaderPanel::GetLicenseUrls() 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.
if (!extensions::SharedModuleInfo::ImportsModules(app_)) if (!extensions::SharedModuleInfo::ImportsModules(app_))
return GURL::EmptyGURL(); return std::vector<GURL>();
std::vector<GURL> license_urls;
ExtensionService* service = ExtensionService* service =
extensions::ExtensionSystem::Get(profile_)->extension_service(); extensions::ExtensionSystem::Get(profile_)->extension_service();
DCHECK(service); DCHECK(service);
const std::vector<extensions::SharedModuleInfo::ImportInfo>& imports = const std::vector<extensions::SharedModuleInfo::ImportInfo>& imports =
extensions::SharedModuleInfo::GetImports(app_); extensions::SharedModuleInfo::GetImports(app_);
for (const auto& shared_module : imports) {
const extensions::Extension* imported_module = const extensions::Extension* imported_module =
service->GetExtensionById(imports[0].extension_id, true); service->GetExtensionById(shared_module.extension_id, true);
DCHECK(imported_module); DCHECK(imported_module);
return extensions::ManifestURL::GetAboutPage(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) { void AppInfoHeaderPanel::OpenLink(const GURL& url) {
DCHECK(!url.is_empty()); DCHECK(!url.is_empty());
chrome::NavigateParams params(profile_, url, ui::PAGE_TRANSITION_LINK); chrome::NavigateParams params(profile_, url, ui::PAGE_TRANSITION_LINK);
chrome::Navigate(&params); chrome::Navigate(&params);
Close();
} }
...@@ -58,9 +58,9 @@ class AppInfoHeaderPanel : public AppInfoPanel, ...@@ -58,9 +58,9 @@ class AppInfoHeaderPanel : public AppInfoPanel,
// CanDisplayLicenses() returns true. // CanDisplayLicenses() returns true.
void DisplayLicenses(); void DisplayLicenses();
bool CanDisplayLicenses() const; 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); void OpenLink(const GURL& url);
// UI elements on the dialog. Elements are NULL if they are not displayed. // 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