Skip to content

Commit

Permalink
Add build option to install the extension.crx locally
Browse files Browse the repository at this point in the history
Run cmake with -DINSTALL_CHROME_EXTENSION=ON if you want to install the provided
extension.crx file locally instead of having Chrome download it from the store.

Default is off where it will download the newest version from the store.
  • Loading branch information
kbroulik committed Apr 25, 2017
1 parent ee2f438 commit 3ea446a
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 9 deletions.
33 changes: 25 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,20 @@ find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS
Activities
)

# Options
option(INSTALL_CHROME_EXTENSION "Whether to install the Chrome extension locally instead of downloading it from the Extension Store")

add_subdirectory(host)
add_subdirectory(tabsrunner)

if(NOT DEFINED CHROME_EXTENSION_ID)
# The extension ID is based on the key used to sign the extension
# see https://stackoverflow.com/questions/23873623/obtaining-chrome-extension-id-for-development
set(CHROME_EXTENSION_ID "cimiefiiaegbelhefglklhhakcgmhkai")

# TODO would be nice if we could automate the packaging and generation of the crx
endif()

# TODO configure manifest.json

configure_file(org.kde.plasma.chrome_integration.json.in org.kde.plasma.chrome_integration.json @ONLY)
configure_file(org.kde.plasma.firefox_integration.json.in org.kde.plasma.firefox_integration.json @ONLY)

Expand All @@ -53,11 +56,25 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/org.kde.plasma.chrome_integration.json
# firefox
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/org.kde.plasma.firefox_integration.json DESTINATION /usr/lib/mozilla/native-messaging-hosts/ RENAME org.kde.plasma.browser_integration.json)

# Install a policy to have browsers automatically add the extension
configure_file(chrome_auto_install_policy.json.in chrome_auto_install_policy.json @ONLY)
if(INSTALL_CHROME_EXTENSION)
configure_file(chrome_install_locally_policy.in chrome_install_locally_policy @ONLY)

# google-chrome
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/chrome_install_locally_policy DESTINATION /usr/share/google-chrome/extensions RENAME ${CHROME_EXTENSION_ID}.json)
# chromium
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/chrome_install_locally_policy DESTINATION /usr/share/chromium-browser/extensions RENAME ${CHROME_EXTENSION_ID}.json)

# The actual extension file
# TODO would be nice if we could automate the packaging and generation of the crx
# TODO do we need to use some form of KDE_INSTALL_TARGETS_DEFAULT_ARGS?
install(FILES extension.crx DESTINATION ${CMAKE_INSTALL_PREFIX}/share/plasma-browser-integration)

else() # Install a policy to have browsers automatically add the extension

# google-chrome
install(FILES chrome_install_from_store_policy DESTINATION /usr/share/google-chrome/extensions RENAME ${CHROME_EXTENSION_ID}.json)
# chromium
install(FILES chrome_install_from_store_policy DESTINATION /usr/share/chromium-browser/extensions RENAME ${CHROME_EXTENSION_ID}.json)
endif()

# google-chrome
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/chrome_auto_install_policy.json DESTINATION /usr/share/google-chrome/extensions RENAME ${CHROME_EXTENSION_ID}.json)
# chromium
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/chrome_auto_install_policy.json DESTINATION /usr/share/chromium-browser/extensions RENAME ${CHROME_EXTENSION_ID}.json)
# TODO firefox
File renamed without changes.
4 changes: 4 additions & 0 deletions chrome_install_locally_policy.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"external_crx": "@CMAKE_INSTALL_PREFIX@/share/plasma-browser-integration/extension.crx",
"external_version": "@PROJECT_VERSION@"
}
Binary file added extension.crx
Binary file not shown.
2 changes: 1 addition & 1 deletion extension/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"name": "Plasma Integration",
"short_name": "Plasma",
"description": "Provides better integration with the KDE Plasma 5 desktop.",
"version": "0.0.1",
"version": "0.0.3",

"default_locale": "en",

Expand Down

0 comments on commit 3ea446a

Please sign in to comment.