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

Unified Diff: chrome/browser/extensions/extension_service.cc

Issue 22944002: Implementation of the "Redirect URLs to Packaged Apps" feature. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 4 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
Index: chrome/browser/extensions/extension_service.cc
diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc
index 8fc25936e35cbc882f8ff4f3fafdc3b9c56e78b5..352c0d72aad105e9cedd5d720e5f309887602ea2 100644
--- a/chrome/browser/extensions/extension_service.cc
+++ b/chrome/browser/extensions/extension_service.cc
@@ -78,6 +78,7 @@
#include "chrome/common/chrome_switches.h"
#include "chrome/common/chrome_version_info.h"
#include "chrome/common/extensions/api/plugins/plugins_handler.h"
+#include "chrome/common/extensions/api/url_handlers/url_handlers_parser.h"
#include "chrome/common/extensions/background_info.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_file_util.h"
@@ -131,6 +132,7 @@ using extensions::PermissionMessage;
using extensions::PermissionMessages;
using extensions::PermissionSet;
using extensions::UnloadedExtensionInfo;
+using extensions::AppEventRouter;
namespace errors = extension_manifest_errors;
@@ -199,6 +201,16 @@ const char ExtensionService::kManagedSettingsDirectoryName[] =
const char ExtensionService::kStateStoreName[] = "Extension State";
const char ExtensionService::kRulesStoreName[] = "Extension Rules";
+bool ExtensionService::OnMessageReceived(const IPC::Message& message) {
+ bool handled = true;
+ IPC_BEGIN_MESSAGE_MAP(ExtensionService, message)
+ IPC_MESSAGE_HANDLER(ExtensionHostMsg_OnRedirectUrlToApp,
+ OnRedirectUrlToApp)
+ IPC_MESSAGE_UNHANDLED(handled = false)
+ IPC_END_MESSAGE_MAP()
+ return handled;
+}
+
void ExtensionService::CheckExternalUninstall(const std::string& id) {
CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
@@ -2493,6 +2505,34 @@ bool ExtensionService::ShouldBlockUrlInBrowserTab(GURL* url) {
return false;
}
+bool ExtensionService::MaybeRedirectUrlToApp(const GURL& url,
+ const GURL& referrer_url) {
+ // NOTE: The current API spec enforces at most a single app matching a URL.
+ // TODO: Actually implement the above-mentioned enforcement.
+ const extensions::UrlHandlerInfo* handler =
+ extensions_.GetHandlingAppForURL(url);
+ if (handler) {
+ CHECK(handler->app->is_platform_app());
+ extensions::AppEventRouter::DispatchOnLaunchedEventWithURL(
+ profile_, handler->app, handler->id, url, referrer_url);
+ return true;
+ }
+
+ return false;
+}
+
+void ExtensionService::OnRedirectUrlToApp(const std::string& app_id,
+ const std::string& handler_id,
+ const GURL& url,
+ const GURL& referrer_url) {
+ const Extension* app = GetExtensionById(app_id, true);
+ if (app) {
+ CHECK(app->is_platform_app());
asargent_no_longer_on_chrome 2013/08/14 18:05:12 Note that a renderer process could be compromised,
sergeygs 2013/08/18 11:40:24 After more careful thinking, this should have been
+ extensions::AppEventRouter::DispatchOnLaunchedEventWithURL(
+ profile_, app, handler_id, url, referrer_url);
+ }
+}
+
bool ExtensionService::OnExternalExtensionFileFound(
const std::string& id,
const Version* version,

Powered by Google App Engine
This is Rietveld 408576698