| 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 #include "base/command_line.h" | |
| 6 #include "base/logging.h" | |
| 7 #include "base/string16.h" | |
| 8 #include "base/string_util.h" | |
| 9 #include "base/utf_string_conversions.h" | |
| 10 #include "chrome/browser/intents/native_services.h" | |
| 11 #include "chrome/browser/intents/web_intents_util.h" | |
| 12 #include "chrome/common/chrome_switches.h" | |
| 13 #include "googleurl/src/gurl.h" | |
| 14 #include "webkit/glue/web_intent_service_data.h" | |
| 15 | |
| 16 namespace web_intents { | |
| 17 | |
| 18 #define NATIVE_SCHEME "chrome-intents-native" | |
| 19 | |
| 20 const char kChromeNativeSerivceScheme[] = NATIVE_SCHEME; | |
| 21 const char kNativeFilePickerUrl[] = NATIVE_SCHEME "://file-picker"; | |
| 22 | |
| 23 NativeServiceRegistry::NativeServiceRegistry() {} | |
| 24 | |
| 25 void NativeServiceRegistry::GetSupportedServices( | |
| 26 const string16& action, | |
| 27 IntentServiceList* services) { | |
| 28 if (!CommandLine::ForCurrentProcess()->HasSwitch( | |
| 29 switches::kWebIntentsNativeServicesEnabled)) | |
| 30 return; | |
| 31 | |
| 32 #if !defined(ANDROID) | |
| 33 if (EqualsASCII(action, web_intents::kActionPick)) { | |
| 34 // File picker registrations. | |
| 35 webkit_glue::WebIntentServiceData service( | |
| 36 ASCIIToUTF16(kActionPick), | |
| 37 ASCIIToUTF16("*/*"), // handle any MIME-type | |
| 38 string16(), | |
| 39 GURL(web_intents::kNativeFilePickerUrl), | |
| 40 FilePickerFactory::GetServiceTitle()); | |
| 41 service.disposition = webkit_glue::WebIntentServiceData::DISPOSITION_NATIVE; | |
| 42 | |
| 43 services->push_back(service); | |
| 44 } | |
| 45 #endif | |
| 46 } | |
| 47 | |
| 48 NativeServiceFactory::NativeServiceFactory() {} | |
| 49 | |
| 50 IntentServiceHost* NativeServiceFactory::CreateServiceInstance( | |
| 51 const GURL& service_url, | |
| 52 const webkit_glue::WebIntentData& intent, | |
| 53 content::WebContents* web_contents) { | |
| 54 | |
| 55 #if !defined(ANDROID) | |
| 56 if (service_url.spec() == kNativeFilePickerUrl) { | |
| 57 return FilePickerFactory::CreateServiceInstance(intent, web_contents); | |
| 58 } | |
| 59 #endif | |
| 60 | |
| 61 return NULL; // couldn't create instance | |
| 62 } | |
| 63 | |
| 64 } // namespace web_intents | |
| OLD | NEW |