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 #ifndef CHROME_BROWSER_INTENTS_NATIVE_SERVICES_H_ | |
6 #define CHROME_BROWSER_INTENTS_NATIVE_SERVICES_H_ | |
7 | |
8 #include <string> | |
9 #include <vector> | |
10 #include "base/basictypes.h" | |
11 #include "base/string16.h" | |
12 | |
13 class GURL; | |
14 | |
15 namespace content { | |
16 class WebContents; | |
17 class WebIntentsDispatcher; | |
18 } | |
19 | |
20 namespace webkit_glue { | |
21 struct WebIntentData; | |
22 struct WebIntentServiceData; | |
23 } | |
24 | |
25 namespace web_intents { | |
26 | |
27 class IntentServiceHost; | |
28 | |
29 // Service URL for the file picker hosted by the Chrome browser. | |
30 extern const char kNativeFilePickerUrl[]; | |
31 | |
32 #if !defined(ANDROID) | |
33 // Factory capable of producing a native file picker IntentServiceHost, | |
34 // as well as producing registration information about the service. Instances | |
35 // of this class can be obtained via NativeServiceFactory and should not | |
36 // otherwise be instantiated directly. | |
37 class FilePickerFactory { | |
38 public: | |
39 // Returns a localized title for the file picker. | |
40 static string16 GetServiceTitle(); | |
41 | |
42 // Returns a new IntentServiceHost for processing the given intent data in the | |
43 // context of the given web contents. The intent must be of action type | |
44 // "pick". | |
45 static IntentServiceHost* CreateServiceInstance( | |
46 const webkit_glue::WebIntentData& intent, | |
47 content::WebContents* web_contents); | |
48 | |
49 private: | |
50 DISALLOW_IMPLICIT_CONSTRUCTORS(FilePickerFactory); | |
51 }; | |
52 #endif | |
53 | |
54 // Supplier of information about services hosted by Chrome itself | |
55 // (as opposed to web services). Each service registration produced | |
56 // by this class will have a WebIntentServiceData::DISPOSITION_NATIVE | |
57 // disposition. This value can be used at runtime to determine when a service | |
58 // can be instantiated by our sibling class NativeServiceFactory. | |
59 // Instances of this class are currently stateless and fairly light weight. | |
60 // Any two instances can be assumed to have the same information. | |
61 class NativeServiceRegistry { | |
62 public: | |
63 typedef std::vector<webkit_glue::WebIntentServiceData> IntentServiceList; | |
64 NativeServiceRegistry(); | |
65 ~NativeServiceRegistry(); | |
66 | |
67 // Populates |services| with all supported IntentServiceHosts | |
68 // capable of handling |action|. | |
69 void GetSupportedServices( | |
70 const string16& action, | |
71 IntentServiceList* services); | |
72 | |
73 private: | |
74 DISALLOW_COPY_AND_ASSIGN(NativeServiceRegistry); | |
75 }; | |
76 | |
77 // Factory for services hosted by Chrome itself (as opposed to web services). | |
78 // When implementing a new native service this is where you add support | |
79 // for creating an instance. | |
80 // Only services reported by NativeServiceRegistry.GetSupportedServices, | |
81 // specifically those having a WebIntentServiceData::DISPOSITION_NATIVE | |
82 // disposition, are instantiatable via this class. | |
83 // Instances of this class are currently stateless and fairly light weight. | |
84 // Any two instances can be assumed to have the same capabilities. | |
85 class NativeServiceFactory { | |
86 public: | |
87 NativeServiceFactory(); | |
88 ~NativeServiceFactory(); | |
89 | |
90 // Returns a new IntentServiceHost for processing the given intent data in the | |
91 // context of the given web contents. Callers assume ownership of the | |
92 // instance. | |
93 IntentServiceHost* CreateServiceInstance( | |
94 const GURL& url, | |
95 const webkit_glue::WebIntentData& intent, | |
96 content::WebContents* web_contents); | |
97 | |
98 private: | |
99 DISALLOW_COPY_AND_ASSIGN(NativeServiceFactory); | |
100 }; | |
101 | |
102 } // namespace web_intents | |
103 | |
104 #endif // CHROME_BROWSER_INTENTS_NATIVE_SERVICES_H_ | |
OLD | NEW |