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

Side by Side Diff: chrome/browser/three_d_api_observer.cc

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) 2012 The Chromium Authors. All rights reserved. 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 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 #include "chrome/browser/three_d_api_observer.h" 5 #include "chrome/browser/three_d_api_observer.h"
6 6
7 #include "base/metrics/histogram.h" 7 #include "base/metrics/histogram.h"
8 #include "chrome/browser/api/infobars/confirm_infobar_delegate.h" 8 #include "chrome/browser/api/infobars/confirm_infobar_delegate.h"
9 #include "chrome/browser/api/infobars/infobar_service.h" 9 #include "chrome/browser/api/infobars/infobar_service.h"
10 #include "content/public/browser/gpu_data_manager.h" 10 #include "content/public/browser/gpu_data_manager.h"
(...skipping 11 matching lines...) Expand all
22 THREE_D_INFOBAR_CLOSED_WITHOUT_ACTION, 22 THREE_D_INFOBAR_CLOSED_WITHOUT_ACTION,
23 THREE_D_INFOBAR_DISMISSAL_MAX 23 THREE_D_INFOBAR_DISMISSAL_MAX
24 }; 24 };
25 25
26 } // namespace 26 } // namespace
27 27
28 // ThreeDAPIInfoBarDelegate --------------------------------------------- 28 // ThreeDAPIInfoBarDelegate ---------------------------------------------
29 29
30 class ThreeDAPIInfoBarDelegate : public ConfirmInfoBarDelegate { 30 class ThreeDAPIInfoBarDelegate : public ConfirmInfoBarDelegate {
31 public: 31 public:
32 // Creates a 3D API delegate and adds it to |infobar_service|.
33 static void Create(InfoBarService* infobar_service,
34 const GURL& url,
35 content::ThreeDAPIType requester);
36
37 private:
32 ThreeDAPIInfoBarDelegate( 38 ThreeDAPIInfoBarDelegate(
33 InfoBarService* owner, 39 InfoBarService* owner,
34 const GURL& url, 40 const GURL& url,
35 content::ThreeDAPIType requester); 41 content::ThreeDAPIType requester);
36
37 private:
38 virtual ~ThreeDAPIInfoBarDelegate(); 42 virtual ~ThreeDAPIInfoBarDelegate();
39 43
40 // ConfirmInfoBarDelegate: 44 // ConfirmInfoBarDelegate:
41 virtual bool EqualsDelegate(InfoBarDelegate* delegate) const OVERRIDE; 45 virtual bool EqualsDelegate(InfoBarDelegate* delegate) const OVERRIDE;
42 virtual ThreeDAPIInfoBarDelegate* AsThreeDAPIInfoBarDelegate() OVERRIDE; 46 virtual ThreeDAPIInfoBarDelegate* AsThreeDAPIInfoBarDelegate() OVERRIDE;
43 virtual string16 GetMessageText() const OVERRIDE; 47 virtual string16 GetMessageText() const OVERRIDE;
44 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; 48 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE;
45 virtual bool Accept() OVERRIDE; 49 virtual bool Accept() OVERRIDE;
46 virtual bool Cancel() OVERRIDE; 50 virtual bool Cancel() OVERRIDE;
47 virtual string16 GetLinkText() const OVERRIDE; 51 virtual string16 GetLinkText() const OVERRIDE;
48 virtual bool LinkClicked(WindowOpenDisposition disposition) OVERRIDE; 52 virtual bool LinkClicked(WindowOpenDisposition disposition) OVERRIDE;
49 53
50 GURL url_; 54 GURL url_;
51 content::ThreeDAPIType requester_; 55 content::ThreeDAPIType requester_;
52 // Basically indicates whether the infobar was displayed at all, or 56 // Basically indicates whether the infobar was displayed at all, or
53 // was a temporary instance thrown away by the InfobarService. 57 // was a temporary instance thrown away by the InfobarService.
54 mutable bool message_text_queried_; 58 mutable bool message_text_queried_;
55 bool action_taken_; 59 bool action_taken_;
56 60
57 DISALLOW_COPY_AND_ASSIGN(ThreeDAPIInfoBarDelegate); 61 DISALLOW_COPY_AND_ASSIGN(ThreeDAPIInfoBarDelegate);
58 }; 62 };
59 63
64 // static
65 void ThreeDAPIInfoBarDelegate::Create(InfoBarService* infobar_service,
66 const GURL& url,
67 content::ThreeDAPIType requester) {
68 infobar_service->AddInfoBar(scoped_ptr<InfoBarDelegate>(
69 new ThreeDAPIInfoBarDelegate(infobar_service, url, requester)));
70 }
71
60 ThreeDAPIInfoBarDelegate::ThreeDAPIInfoBarDelegate( 72 ThreeDAPIInfoBarDelegate::ThreeDAPIInfoBarDelegate(
61 InfoBarService* owner, 73 InfoBarService* owner,
62 const GURL& url, 74 const GURL& url,
63 content::ThreeDAPIType requester) 75 content::ThreeDAPIType requester)
64 : ConfirmInfoBarDelegate(owner), 76 : ConfirmInfoBarDelegate(owner),
65 url_(url), 77 url_(url),
66 requester_(requester), 78 requester_(requester),
67 message_text_queried_(false), 79 message_text_queried_(false),
68 action_taken_(false) { 80 action_taken_(false) {
69 } 81 }
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 162
151 // ThreeDAPIObserver ---------------------------------------------------- 163 // ThreeDAPIObserver ----------------------------------------------------
152 164
153 ThreeDAPIObserver::ThreeDAPIObserver(content::WebContents* web_contents) 165 ThreeDAPIObserver::ThreeDAPIObserver(content::WebContents* web_contents)
154 : WebContentsObserver(web_contents) {} 166 : WebContentsObserver(web_contents) {}
155 167
156 ThreeDAPIObserver::~ThreeDAPIObserver() {} 168 ThreeDAPIObserver::~ThreeDAPIObserver() {}
157 169
158 void ThreeDAPIObserver::DidBlock3DAPIs(const GURL& url, 170 void ThreeDAPIObserver::DidBlock3DAPIs(const GURL& url,
159 content::ThreeDAPIType requester) { 171 content::ThreeDAPIType requester) {
160 InfoBarService* service = InfoBarService::FromWebContents(web_contents()); 172 ThreeDAPIInfoBarDelegate::Create(
161 service->AddInfoBar(new ThreeDAPIInfoBarDelegate(service, url, requester)); 173 InfoBarService::FromWebContents(web_contents()), url, requester);
162 } 174 }
OLDNEW
« no previous file with comments | « chrome/browser/ssl/ssl_tab_helper.cc ('k') | chrome/browser/translate/translate_infobar_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698