summaryrefslogtreecommitdiffstats
path: root/chrome/browser/intents/native_services.h
blob: 7a9ddf81dd83dd6daf3ff8fc54e81f8a68e19abd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_INTENTS_NATIVE_SERVICES_H_
#define CHROME_BROWSER_INTENTS_NATIVE_SERVICES_H_

#include <string>
#include <vector>
#include "base/basictypes.h"
#include "base/string16.h"

class GURL;

namespace content {
class WebContents;
class WebIntentsDispatcher;
}

namespace webkit_glue {
struct WebIntentData;
struct WebIntentServiceData;
}

namespace web_intents {

class IntentServiceHost;

extern const char kChromeNativeSerivceScheme[];
extern const char kNativeFilePickerUrl[];

typedef std::vector<webkit_glue::WebIntentServiceData> IntentServiceList;

#if !defined(ANDROID)
// Factory capable of producing a native file picker IntentServiceHost,
// as well as producing registration information about the service.
class FilePickerFactory {
 public:
  // Returns a localized title for the file picker.
  static string16 GetServiceTitle();

  // Returns a new IntentServiceHost. The instance is owned by the caller.
  // |intent| is the intent data. |web_contents| is the context in which
  // the intent was invoked.
  static IntentServiceHost* CreateServiceInstance(
      const webkit_glue::WebIntentData& intent,
      content::WebContents* web_contents);

 private:
  DISALLOW_COPY_AND_ASSIGN(FilePickerFactory);
};
#endif

class NativeServiceRegistry {
 public:
  NativeServiceRegistry();
  // Populates |services| with all supported IntentServiceHosts
  // capable of handling |action|.
  void GetSupportedServices(
      const string16& action,
      IntentServiceList* services);

 private:
  DISALLOW_COPY_AND_ASSIGN(NativeServiceRegistry);
};

class NativeServiceFactory {
 public:
  NativeServiceFactory();
  // Returns an IntentServiceHost instance suitable to handle |intent|.
  // |url| identifies the service to be instantiated, |web_contents| is
  // the web_contents of the client that invoked this intent. The
  // IntentServiceHost is owned by the caller.
  IntentServiceHost* CreateServiceInstance(
      const GURL& url,
      const webkit_glue::WebIntentData& intent,
      content::WebContents* web_contents);

 private:
  DISALLOW_COPY_AND_ASSIGN(NativeServiceFactory);
};

}  // namespace web_intents

#endif  // CHROME_BROWSER_INTENTS_NATIVE_SERVICES_H_