OLD | NEW |
| (Empty) |
1 // Copyright (c) 2011 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_REGISTER_INTENT_HANDLER_INFOBAR_DELEGATE_H_ | |
6 #define CHROME_BROWSER_INTENTS_REGISTER_INTENT_HANDLER_INFOBAR_DELEGATE_H_ | |
7 | |
8 #include "base/basictypes.h" | |
9 #include "base/string16.h" | |
10 #include "chrome/browser/api/infobars/confirm_infobar_delegate.h" | |
11 #include "webkit/glue/web_intent_service_data.h" | |
12 | |
13 #if defined(UNIT_TEST) | |
14 #include "base/memory/scoped_ptr.h" | |
15 #endif | |
16 | |
17 class WebIntentsRegistry; | |
18 class FaviconService; | |
19 class GURL; | |
20 namespace content { | |
21 class WebContents; | |
22 } | |
23 | |
24 // The InfoBar used to request permission for a site to be registered as an | |
25 // Intent handler. | |
26 class RegisterIntentHandlerInfoBarDelegate : public ConfirmInfoBarDelegate { | |
27 public: | |
28 // Checks whether the intent service specified by |data| exists. If not, and | |
29 // |web_contents| is in a non-incognito, web-intents-enabled profile, creates | |
30 // a register intent handler delegate and adds it to the InfoBarService for | |
31 // |web_contents|. | |
32 static void Create(content::WebContents* web_contents, | |
33 const webkit_glue::WebIntentServiceData& data); | |
34 | |
35 #if defined(UNIT_TEST) | |
36 static scoped_ptr<RegisterIntentHandlerInfoBarDelegate> Create( | |
37 WebIntentsRegistry* registry, | |
38 const webkit_glue::WebIntentServiceData& data) { | |
39 return scoped_ptr<RegisterIntentHandlerInfoBarDelegate>( | |
40 new RegisterIntentHandlerInfoBarDelegate(NULL, registry, data, NULL, | |
41 GURL())); | |
42 } | |
43 #endif | |
44 | |
45 // ConfirmInfoBarDelegate implementation. | |
46 virtual Type GetInfoBarType() const OVERRIDE; | |
47 virtual string16 GetMessageText() const OVERRIDE; | |
48 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; | |
49 virtual bool Accept() OVERRIDE; | |
50 virtual string16 GetLinkText() const OVERRIDE; | |
51 virtual bool LinkClicked(WindowOpenDisposition disposition) OVERRIDE; | |
52 | |
53 private: | |
54 RegisterIntentHandlerInfoBarDelegate( | |
55 InfoBarService* infobar_service, | |
56 WebIntentsRegistry* registry, | |
57 const webkit_glue::WebIntentServiceData& service, | |
58 FaviconService* favicon_service, | |
59 const GURL& origin_url); | |
60 | |
61 // Finishes the work of Create(). This is called back from the | |
62 // WebIntentsRegistry once it determines whether the requested intent service | |
63 // exists. | |
64 static void CreateContinuation( | |
65 InfoBarService* infobar_service, | |
66 WebIntentsRegistry* registry, | |
67 const webkit_glue::WebIntentServiceData& service, | |
68 FaviconService* favicon_service, | |
69 const GURL& origin_url, | |
70 bool provider_exists); | |
71 | |
72 // The web intents registry to use. Weak pointer. | |
73 WebIntentsRegistry* registry_; | |
74 | |
75 // The cached intent service data bundle passed up from the renderer. | |
76 webkit_glue::WebIntentServiceData service_; | |
77 | |
78 // The favicon service to use. Weak pointer. | |
79 FaviconService* favicon_service_; | |
80 | |
81 // The URL of the page the service was originally registered from. | |
82 GURL origin_url_; | |
83 | |
84 DISALLOW_COPY_AND_ASSIGN(RegisterIntentHandlerInfoBarDelegate); | |
85 }; | |
86 | |
87 #endif // CHROME_BROWSER_INTENTS_REGISTER_INTENT_HANDLER_INFOBAR_DELEGATE_H_ | |
OLD | NEW |