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

Side by Side Diff: chrome/browser/extensions/api/page_launcher/page_launcher_api.cc

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

Powered by Google App Engine
This is Rietveld 408576698