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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/extensions/api/page_launcher/page_launcher_api.h"
6
7 #include "base/lazy_instance.h"
8 #include "base/memory/linked_ptr.h"
9 #include "chrome/browser/extensions/event_router.h"
10 #include "chrome/browser/extensions/extension_system.h"
11 #include "chrome/common/extensions/api/page_launcher.h"
12 #include "chrome/common/extensions/api/page_launcher/page_launcher_handler.h"
13 #include "chrome/common/extensions/extension_manifest_constants.h"
14 #include "chrome/common/extensions/manifest_handler.h"
15 #include "googleurl/src/gurl.h"
16
17 namespace extensions {
18
19 static base::LazyInstance<ProfileKeyedAPIFactory<PageLauncherAPI> >
20 g_factory = LAZY_INSTANCE_INITIALIZER;
21
22 PageLauncherAPI::PageLauncherAPI(Profile* profile) {
23 ManifestHandler::Register(extension_manifest_keys::kPageLauncher,
24 make_linked_ptr(new PageLauncherHandler));
25 }
26
27 PageLauncherAPI::~PageLauncherAPI() {
28 }
29
30 // static
31 void PageLauncherAPI::DispatchOnClickedEvent(
32 Profile* profile,
33 const std::string& extension_id,
34 const GURL& url,
35 const std::string& mimetype,
36 const std::string* page_title,
37 const std::string* selected_text) {
38 api::page_launcher::PageData data;
39 data.url = url.spec();
40 data.mimetype = mimetype;
41 if (page_title)
42 data.title.reset(new std::string(*page_title));
43 if (selected_text)
44 data.selection_text.reset(new std::string(*selected_text));
45
46 scoped_ptr<Event> event(
47 new Event("pageLauncher.onClicked",
48 api::page_launcher::OnClicked::Create(data)));
49 EventRouter* event_router = ExtensionSystem::Get(profile)->event_router();
50 event_router->DispatchEventToExtension(extension_id, event.Pass());
51 }
52
53
54 // static
55 ProfileKeyedAPIFactory<PageLauncherAPI>* PageLauncherAPI::GetFactoryInstance() {
56 return &g_factory.Get();
57 }
58
59 } // namespace extensions
OLDNEW
« 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