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

Unified Diff: chrome/browser/extensions/api/page_launcher/page_launcher_api.cc

Issue 12095023: Allow platform apps to add themselves to the Action Box. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Use raw pointer + IconImage signature changed Created 7 years, 10 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/api/page_launcher/page_launcher_api.cc
diff --git a/chrome/browser/extensions/api/page_launcher/page_launcher_api.cc b/chrome/browser/extensions/api/page_launcher/page_launcher_api.cc
new file mode 100644
index 0000000000000000000000000000000000000000..e7c70c1d519a8496e19e8c478bd6600239cf5930
--- /dev/null
+++ b/chrome/browser/extensions/api/page_launcher/page_launcher_api.cc
@@ -0,0 +1,59 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/extensions/api/page_launcher/page_launcher_api.h"
+
+#include "base/lazy_instance.h"
+#include "base/memory/linked_ptr.h"
+#include "chrome/browser/extensions/event_router.h"
+#include "chrome/browser/extensions/extension_system.h"
+#include "chrome/common/extensions/api/page_launcher.h"
+#include "chrome/common/extensions/api/page_launcher/page_launcher_handler.h"
+#include "chrome/common/extensions/extension_manifest_constants.h"
+#include "chrome/common/extensions/manifest_handler.h"
+#include "googleurl/src/gurl.h"
+
+namespace extensions {
+
+static base::LazyInstance<ProfileKeyedAPIFactory<PageLauncherAPI> >
+ g_factory = LAZY_INSTANCE_INITIALIZER;
+
+PageLauncherAPI::PageLauncherAPI(Profile* profile) {
+ ManifestHandler::Register(extension_manifest_keys::kPageLauncher,
+ make_linked_ptr(new PageLauncherHandler));
+}
+
+PageLauncherAPI::~PageLauncherAPI() {
+}
+
+// static
+void PageLauncherAPI::DispatchOnClickedEvent(
+ Profile* profile,
+ const std::string& extension_id,
+ const GURL& url,
+ const std::string& mimetype,
+ const std::string* page_title,
+ const std::string* selected_text) {
+ api::page_launcher::PageData data;
+ data.url = url.spec();
+ data.mimetype = mimetype;
+ if (page_title)
+ data.title.reset(new std::string(*page_title));
+ if (selected_text)
+ data.selection_text.reset(new std::string(*selected_text));
+
+ scoped_ptr<Event> event(
+ new Event("pageLauncher.onClicked",
+ api::page_launcher::OnClicked::Create(data)));
+ EventRouter* event_router = ExtensionSystem::Get(profile)->event_router();
+ event_router->DispatchEventToExtension(extension_id, event.Pass());
+}
+
+
+// static
+ProfileKeyedAPIFactory<PageLauncherAPI>* PageLauncherAPI::GetFactoryInstance() {
+ return &g_factory.Get();
+}
+
+} // namespace extensions
« no previous file with comments | « chrome/browser/extensions/api/page_launcher/page_launcher_api.h ('k') | chrome/browser/profiles/profile_dependency_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698