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

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

Issue 102163002: Revert 238283 "Infobar system refactor." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years 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/infobars/confirm_infobar_delegate.h" 8 #include "chrome/browser/infobars/confirm_infobar_delegate.h"
9 #include "chrome/browser/infobars/infobar.h"
10 #include "chrome/browser/infobars/infobar_service.h" 9 #include "chrome/browser/infobars/infobar_service.h"
11 #include "chrome/browser/tab_contents/tab_util.h" 10 #include "chrome/browser/tab_contents/tab_util.h"
12 #include "content/public/browser/gpu_data_manager.h" 11 #include "content/public/browser/gpu_data_manager.h"
13 #include "grit/generated_resources.h" 12 #include "grit/generated_resources.h"
14 #include "ui/base/l10n/l10n_util.h" 13 #include "ui/base/l10n/l10n_util.h"
15 14
16 15
17 // ThreeDAPIInfoBarDelegate --------------------------------------------------- 16 // ThreeDAPIInfoBarDelegate ---------------------------------------------------
18 17
19 class ThreeDAPIInfoBarDelegate : public ConfirmInfoBarDelegate { 18 class ThreeDAPIInfoBarDelegate : public ConfirmInfoBarDelegate {
20 public: 19 public:
21 // Creates a 3D API infobar and delegate and adds the infobar to 20 // Creates a 3D API infobar delegate and adds it to |infobar_service|.
22 // |infobar_service|.
23 static void Create(InfoBarService* infobar_service, 21 static void Create(InfoBarService* infobar_service,
24 const GURL& url, 22 const GURL& url,
25 content::ThreeDAPIType requester); 23 content::ThreeDAPIType requester);
26 24
27 private: 25 private:
28 enum DismissalHistogram { 26 enum DismissalHistogram {
29 IGNORED, 27 IGNORED,
30 RELOADED, 28 RELOADED,
31 CLOSED_WITHOUT_ACTION, 29 CLOSED_WITHOUT_ACTION,
32 DISMISSAL_MAX 30 DISMISSAL_MAX
33 }; 31 };
34 32
35 ThreeDAPIInfoBarDelegate(const GURL& url, content::ThreeDAPIType requester); 33 ThreeDAPIInfoBarDelegate(InfoBarService* owner,
34 const GURL& url,
35 content::ThreeDAPIType requester);
36 virtual ~ThreeDAPIInfoBarDelegate(); 36 virtual ~ThreeDAPIInfoBarDelegate();
37 37
38 // ConfirmInfoBarDelegate: 38 // ConfirmInfoBarDelegate:
39 virtual bool EqualsDelegate(InfoBarDelegate* delegate) const OVERRIDE; 39 virtual bool EqualsDelegate(InfoBarDelegate* delegate) const OVERRIDE;
40 virtual ThreeDAPIInfoBarDelegate* AsThreeDAPIInfoBarDelegate() OVERRIDE; 40 virtual ThreeDAPIInfoBarDelegate* AsThreeDAPIInfoBarDelegate() OVERRIDE;
41 virtual string16 GetMessageText() const OVERRIDE; 41 virtual string16 GetMessageText() const OVERRIDE;
42 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; 42 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE;
43 virtual bool Accept() OVERRIDE; 43 virtual bool Accept() OVERRIDE;
44 virtual bool Cancel() OVERRIDE; 44 virtual bool Cancel() OVERRIDE;
45 virtual string16 GetLinkText() const OVERRIDE; 45 virtual string16 GetLinkText() const OVERRIDE;
46 virtual bool LinkClicked(WindowOpenDisposition disposition) OVERRIDE; 46 virtual bool LinkClicked(WindowOpenDisposition disposition) OVERRIDE;
47 47
48 GURL url_; 48 GURL url_;
49 content::ThreeDAPIType requester_; 49 content::ThreeDAPIType requester_;
50 // Basically indicates whether the infobar was displayed at all, or 50 // Basically indicates whether the infobar was displayed at all, or
51 // was a temporary instance thrown away by the InfobarService. 51 // was a temporary instance thrown away by the InfobarService.
52 mutable bool message_text_queried_; 52 mutable bool message_text_queried_;
53 bool action_taken_; 53 bool action_taken_;
54 54
55 DISALLOW_COPY_AND_ASSIGN(ThreeDAPIInfoBarDelegate); 55 DISALLOW_COPY_AND_ASSIGN(ThreeDAPIInfoBarDelegate);
56 }; 56 };
57 57
58 // static 58 // static
59 void ThreeDAPIInfoBarDelegate::Create(InfoBarService* infobar_service, 59 void ThreeDAPIInfoBarDelegate::Create(InfoBarService* infobar_service,
60 const GURL& url, 60 const GURL& url,
61 content::ThreeDAPIType requester) { 61 content::ThreeDAPIType requester) {
62 if (!infobar_service) 62 if (!infobar_service)
63 return; // NULL for apps. 63 return; // NULL for apps.
64 infobar_service->AddInfoBar(ConfirmInfoBarDelegate::CreateInfoBar( 64 infobar_service->AddInfoBar(scoped_ptr<InfoBarDelegate>(
65 scoped_ptr<ConfirmInfoBarDelegate>( 65 new ThreeDAPIInfoBarDelegate(infobar_service, url, requester)));
66 new ThreeDAPIInfoBarDelegate(url, requester))));
67 } 66 }
68 67
69 ThreeDAPIInfoBarDelegate::ThreeDAPIInfoBarDelegate( 68 ThreeDAPIInfoBarDelegate::ThreeDAPIInfoBarDelegate(
69 InfoBarService* owner,
70 const GURL& url, 70 const GURL& url,
71 content::ThreeDAPIType requester) 71 content::ThreeDAPIType requester)
72 : ConfirmInfoBarDelegate(), 72 : ConfirmInfoBarDelegate(owner),
73 url_(url), 73 url_(url),
74 requester_(requester), 74 requester_(requester),
75 message_text_queried_(false), 75 message_text_queried_(false),
76 action_taken_(false) { 76 action_taken_(false) {
77 } 77 }
78 78
79 ThreeDAPIInfoBarDelegate::~ThreeDAPIInfoBarDelegate() { 79 ThreeDAPIInfoBarDelegate::~ThreeDAPIInfoBarDelegate() {
80 if (message_text_queried_ && !action_taken_) { 80 if (message_text_queried_ && !action_taken_) {
81 UMA_HISTOGRAM_ENUMERATION("GPU.ThreeDAPIInfoBarDismissal", 81 UMA_HISTOGRAM_ENUMERATION("GPU.ThreeDAPIInfoBarDismissal",
82 CLOSED_WITHOUT_ACTION, DISMISSAL_MAX); 82 CLOSED_WITHOUT_ACTION, DISMISSAL_MAX);
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 163
164 void ThreeDAPIObserver::DidBlock3DAPIs(const GURL& url, 164 void ThreeDAPIObserver::DidBlock3DAPIs(const GURL& url,
165 int render_process_id, 165 int render_process_id,
166 int render_view_id, 166 int render_view_id,
167 content::ThreeDAPIType requester) { 167 content::ThreeDAPIType requester) {
168 content::WebContents* web_contents = tab_util::GetWebContentsByID( 168 content::WebContents* web_contents = tab_util::GetWebContentsByID(
169 render_process_id, render_view_id); 169 render_process_id, render_view_id);
170 ThreeDAPIInfoBarDelegate::Create( 170 ThreeDAPIInfoBarDelegate::Create(
171 InfoBarService::FromWebContents(web_contents), url, requester); 171 InfoBarService::FromWebContents(web_contents), url, requester);
172 } 172 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698