OLD | NEW |
| (Empty) |
1 // Copyright (c) 2012 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 // Native services are implemented with UI code necessitating portions | |
6 // of native_services.h to be defined in | |
7 // chrome/browser/ui/intents/native_file_picker_service.cc | |
8 | |
9 #include "base/command_line.h" | |
10 #include "base/logging.h" | |
11 #include "base/string16.h" | |
12 #include "base/string_util.h" | |
13 #include "base/utf_string_conversions.h" | |
14 #include "chrome/browser/intents/native_services.h" | |
15 #include "chrome/browser/intents/web_intents_util.h" | |
16 #include "chrome/common/chrome_switches.h" | |
17 #include "googleurl/src/gurl.h" | |
18 #include "webkit/glue/web_intent_service_data.h" | |
19 | |
20 namespace web_intents { | |
21 | |
22 const char kNativeFilePickerUrl[] = "chrome-intents-native://file-picker"; | |
23 | |
24 NativeServiceRegistry::NativeServiceRegistry() {} | |
25 NativeServiceRegistry::~NativeServiceRegistry() {} | |
26 | |
27 void NativeServiceRegistry::GetSupportedServices( | |
28 const string16& action, | |
29 IntentServiceList* services) { | |
30 if (!CommandLine::ForCurrentProcess()->HasSwitch( | |
31 switches::kWebIntentsNativeServicesEnabled)) | |
32 return; | |
33 | |
34 #if !defined(ANDROID) | |
35 if (EqualsASCII(action, kActionPick)) { | |
36 // File picker registrations. | |
37 webkit_glue::WebIntentServiceData service( | |
38 ASCIIToUTF16(kActionPick), | |
39 ASCIIToUTF16("*/*"), // Handle any MIME-type. | |
40 // This is an action/type based service, so we supply an empty scheme. | |
41 string16(), | |
42 GURL(kNativeFilePickerUrl), | |
43 FilePickerFactory::GetServiceTitle()); | |
44 service.disposition = webkit_glue::WebIntentServiceData::DISPOSITION_NATIVE; | |
45 | |
46 services->push_back(service); | |
47 } | |
48 #endif | |
49 } | |
50 | |
51 NativeServiceFactory::NativeServiceFactory() {} | |
52 NativeServiceFactory::~NativeServiceFactory() {} | |
53 | |
54 IntentServiceHost* NativeServiceFactory::CreateServiceInstance( | |
55 const GURL& service_url, | |
56 const webkit_glue::WebIntentData& intent, | |
57 content::WebContents* web_contents) { | |
58 | |
59 #if !defined(ANDROID) | |
60 if (service_url.spec() == kNativeFilePickerUrl) { | |
61 return FilePickerFactory::CreateServiceInstance(intent, web_contents); | |
62 } | |
63 #endif | |
64 | |
65 return NULL; // Couldn't create an instance. | |
66 } | |
67 | |
68 } // namespace web_intents | |
OLD | NEW |