OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/gpu/three_d_api_observer.h" | 5 #include "chrome/browser/gpu/three_d_api_observer.h" |
6 | 6 |
7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
8 #include "chrome/browser/infobars/infobar_service.h" | 8 #include "chrome/browser/infobars/infobar_service.h" |
9 #include "chrome/browser/tab_contents/tab_util.h" | 9 #include "chrome/browser/tab_contents/tab_util.h" |
10 #include "chrome/grit/generated_resources.h" | 10 #include "chrome/grit/generated_resources.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 RELOADED, | 32 RELOADED, |
33 CLOSED_WITHOUT_ACTION, | 33 CLOSED_WITHOUT_ACTION, |
34 DISMISSAL_MAX | 34 DISMISSAL_MAX |
35 }; | 35 }; |
36 | 36 |
37 ThreeDAPIInfoBarDelegate(const GURL& url, content::ThreeDAPIType requester); | 37 ThreeDAPIInfoBarDelegate(const GURL& url, content::ThreeDAPIType requester); |
38 ~ThreeDAPIInfoBarDelegate() override; | 38 ~ThreeDAPIInfoBarDelegate() override; |
39 | 39 |
40 // ConfirmInfoBarDelegate: | 40 // ConfirmInfoBarDelegate: |
41 bool EqualsDelegate(infobars::InfoBarDelegate* delegate) const override; | 41 bool EqualsDelegate(infobars::InfoBarDelegate* delegate) const override; |
| 42 ThreeDAPIInfoBarDelegate* AsThreeDAPIInfoBarDelegate() override; |
42 int GetIconID() const override; | 43 int GetIconID() const override; |
43 base::string16 GetMessageText() const override; | 44 base::string16 GetMessageText() const override; |
44 base::string16 GetButtonLabel(InfoBarButton button) const override; | 45 base::string16 GetButtonLabel(InfoBarButton button) const override; |
45 bool Accept() override; | 46 bool Accept() override; |
46 bool Cancel() override; | 47 bool Cancel() override; |
47 base::string16 GetLinkText() const override; | 48 base::string16 GetLinkText() const override; |
48 bool LinkClicked(WindowOpenDisposition disposition) override; | 49 bool LinkClicked(WindowOpenDisposition disposition) override; |
49 | 50 |
50 GURL url_; | 51 GURL url_; |
51 content::ThreeDAPIType requester_; | 52 content::ThreeDAPIType requester_; |
(...skipping 26 matching lines...) Expand all Loading... |
78 action_taken_(false) { | 79 action_taken_(false) { |
79 } | 80 } |
80 | 81 |
81 ThreeDAPIInfoBarDelegate::~ThreeDAPIInfoBarDelegate() { | 82 ThreeDAPIInfoBarDelegate::~ThreeDAPIInfoBarDelegate() { |
82 if (message_text_queried_ && !action_taken_) { | 83 if (message_text_queried_ && !action_taken_) { |
83 UMA_HISTOGRAM_ENUMERATION("GPU.ThreeDAPIInfoBarDismissal", | 84 UMA_HISTOGRAM_ENUMERATION("GPU.ThreeDAPIInfoBarDismissal", |
84 CLOSED_WITHOUT_ACTION, DISMISSAL_MAX); | 85 CLOSED_WITHOUT_ACTION, DISMISSAL_MAX); |
85 } | 86 } |
86 } | 87 } |
87 | 88 |
| 89 ThreeDAPIInfoBarDelegate* |
| 90 ThreeDAPIInfoBarDelegate::AsThreeDAPIInfoBarDelegate() { |
| 91 return this; |
| 92 } |
| 93 |
88 bool ThreeDAPIInfoBarDelegate::EqualsDelegate( | 94 bool ThreeDAPIInfoBarDelegate::EqualsDelegate( |
89 infobars::InfoBarDelegate* delegate) const { | 95 infobars::InfoBarDelegate* delegate) const { |
90 // For the time being, if a given web page is actually using both | 96 // For the time being, if a given web page is actually using both |
91 // WebGL and Pepper 3D and both APIs are blocked, just leave the | 97 // WebGL and Pepper 3D and both APIs are blocked, just leave the |
92 // first infobar up. If the user selects "try again", both APIs will | 98 // first infobar up. If the user selects "try again", both APIs will |
93 // be unblocked and the web page reload will succeed. | 99 // be unblocked and the web page reload will succeed. |
94 return delegate->GetIconID() == GetIconID(); | 100 return !!delegate->AsThreeDAPIInfoBarDelegate(); |
95 } | 101 } |
96 | 102 |
97 int ThreeDAPIInfoBarDelegate::GetIconID() const { | 103 int ThreeDAPIInfoBarDelegate::GetIconID() const { |
98 return IDR_INFOBAR_3D_BLOCKED; | 104 return IDR_INFOBAR_3D_BLOCKED; |
99 } | 105 } |
100 | 106 |
101 base::string16 ThreeDAPIInfoBarDelegate::GetMessageText() const { | 107 base::string16 ThreeDAPIInfoBarDelegate::GetMessageText() const { |
102 message_text_queried_ = true; | 108 message_text_queried_ = true; |
103 | 109 |
104 base::string16 api_name; | 110 base::string16 api_name; |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 int render_process_id, | 174 int render_process_id, |
169 int render_view_id, | 175 int render_view_id, |
170 content::ThreeDAPIType requester) { | 176 content::ThreeDAPIType requester) { |
171 content::WebContents* web_contents = tab_util::GetWebContentsByID( | 177 content::WebContents* web_contents = tab_util::GetWebContentsByID( |
172 render_process_id, render_view_id); | 178 render_process_id, render_view_id); |
173 if (!web_contents) | 179 if (!web_contents) |
174 return; | 180 return; |
175 ThreeDAPIInfoBarDelegate::Create( | 181 ThreeDAPIInfoBarDelegate::Create( |
176 InfoBarService::FromWebContents(web_contents), url, requester); | 182 InfoBarService::FromWebContents(web_contents), url, requester); |
177 } | 183 } |
OLD | NEW |