Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(138)

Side by Side Diff: chrome/browser/intents/register_intent_handler_infobar_delegate.h

Issue 11644059: Change infobar creation to use a public static Create() method on the infobar delegate classes. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_INTENTS_REGISTER_INTENT_HANDLER_INFOBAR_DELEGATE_H_ 5 #ifndef CHROME_BROWSER_INTENTS_REGISTER_INTENT_HANDLER_INFOBAR_DELEGATE_H_
6 #define CHROME_BROWSER_INTENTS_REGISTER_INTENT_HANDLER_INFOBAR_DELEGATE_H_ 6 #define CHROME_BROWSER_INTENTS_REGISTER_INTENT_HANDLER_INFOBAR_DELEGATE_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/string16.h" 9 #include "base/string16.h"
10 #include "chrome/browser/api/infobars/confirm_infobar_delegate.h" 10 #include "chrome/browser/api/infobars/confirm_infobar_delegate.h"
11 #include "webkit/glue/web_intent_service_data.h" 11 #include "webkit/glue/web_intent_service_data.h"
12 12
13 #if defined(UNIT_TEST)
14 #include "base/memory/scoped_ptr.h"
15 #endif
16
13 class WebIntentsRegistry; 17 class WebIntentsRegistry;
14 class FaviconService; 18 class FaviconService;
15 class GURL; 19 class GURL;
20 namespace content {
21 class WebContents;
22 }
16 23
17 // The InfoBar used to request permission for a site to be registered as an 24 // The InfoBar used to request permission for a site to be registered as an
18 // Intent handler. 25 // Intent handler.
19 class RegisterIntentHandlerInfoBarDelegate : public ConfirmInfoBarDelegate { 26 class RegisterIntentHandlerInfoBarDelegate : public ConfirmInfoBarDelegate {
20 public: 27 public:
21 RegisterIntentHandlerInfoBarDelegate( 28 // Checks whether the intent service specified by |data| exists. If not, and
22 InfoBarService* infobar_service, 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(
23 WebIntentsRegistry* registry, 37 WebIntentsRegistry* registry,
24 const webkit_glue::WebIntentServiceData& service, 38 const webkit_glue::WebIntentServiceData& data) {
25 FaviconService* favicon_service, 39 return scoped_ptr<RegisterIntentHandlerInfoBarDelegate>(
26 const GURL& origin_url); 40 new RegisterIntentHandlerInfoBarDelegate(NULL, registry, data, NULL,
41 GURL()));
42 }
43 #endif
27 44
28 // ConfirmInfoBarDelegate implementation. 45 // ConfirmInfoBarDelegate implementation.
29 virtual Type GetInfoBarType() const OVERRIDE; 46 virtual Type GetInfoBarType() const OVERRIDE;
30 virtual string16 GetMessageText() const OVERRIDE; 47 virtual string16 GetMessageText() const OVERRIDE;
31 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; 48 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE;
32 virtual bool Accept() OVERRIDE; 49 virtual bool Accept() OVERRIDE;
33 virtual string16 GetLinkText() const OVERRIDE; 50 virtual string16 GetLinkText() const OVERRIDE;
34 virtual bool LinkClicked(WindowOpenDisposition disposition) OVERRIDE; 51 virtual bool LinkClicked(WindowOpenDisposition disposition) OVERRIDE;
35 52
36 // Shows the intent registration infobar if |service| has not already been 53 private:
37 // registered. 54 RegisterIntentHandlerInfoBarDelegate(
38 // |infobar_service| is the infobar controller for the tab in which the
39 // infobar may be shown. Must not be NULL.
40 // |registry| is the data source for web intents. Must not be NULL.
41 // |service| is the candidate service to show the infobar for.
42 // |favicon_service| is the favicon service to use. Must not be NULL.
43 // |origin_url| is the URL that the intent is registered from.
44 static void MaybeShowIntentInfoBar(
45 InfoBarService* infobar_service, 55 InfoBarService* infobar_service,
46 WebIntentsRegistry* registry, 56 WebIntentsRegistry* registry,
47 const webkit_glue::WebIntentServiceData& service, 57 const webkit_glue::WebIntentServiceData& service,
48 FaviconService* favicon_service, 58 FaviconService* favicon_service,
49 const GURL& origin_url); 59 const GURL& origin_url);
50 60
51 private: 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
52 // The web intents registry to use. Weak pointer. 72 // The web intents registry to use. Weak pointer.
53 WebIntentsRegistry* registry_; 73 WebIntentsRegistry* registry_;
54 74
55 // The cached intent service data bundle passed up from the renderer. 75 // The cached intent service data bundle passed up from the renderer.
56 webkit_glue::WebIntentServiceData service_; 76 webkit_glue::WebIntentServiceData service_;
57 77
58 // The favicon service to use. Weak pointer. 78 // The favicon service to use. Weak pointer.
59 FaviconService* favicon_service_; 79 FaviconService* favicon_service_;
60 80
61 // The URL of the page the service was originally registered from. 81 // The URL of the page the service was originally registered from.
62 GURL origin_url_; 82 GURL origin_url_;
63 83
64 DISALLOW_COPY_AND_ASSIGN(RegisterIntentHandlerInfoBarDelegate); 84 DISALLOW_COPY_AND_ASSIGN(RegisterIntentHandlerInfoBarDelegate);
65 }; 85 };
66 86
67 #endif // CHROME_BROWSER_INTENTS_REGISTER_INTENT_HANDLER_INFOBAR_DELEGATE_H_ 87 #endif // CHROME_BROWSER_INTENTS_REGISTER_INTENT_HANDLER_INFOBAR_DELEGATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698