OLD | NEW |
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" |
| 11 #include "components/infobars/core/infobar.h" |
12 #include "content/public/browser/gpu_data_manager.h" | 12 #include "content/public/browser/gpu_data_manager.h" |
13 #include "grit/generated_resources.h" | 13 #include "grit/generated_resources.h" |
14 #include "grit/theme_resources.h" | 14 #include "grit/theme_resources.h" |
15 #include "ui/base/l10n/l10n_util.h" | 15 #include "ui/base/l10n/l10n_util.h" |
16 | 16 |
17 | 17 |
18 // ThreeDAPIInfoBarDelegate --------------------------------------------------- | 18 // ThreeDAPIInfoBarDelegate --------------------------------------------------- |
19 | 19 |
20 class ThreeDAPIInfoBarDelegate : public ConfirmInfoBarDelegate { | 20 class ThreeDAPIInfoBarDelegate : public ConfirmInfoBarDelegate { |
21 public: | 21 public: |
22 // Creates a 3D API infobar and delegate and adds the infobar to | 22 // Creates a 3D API infobar and delegate and adds the infobar to |
23 // |infobar_service|. | 23 // |infobar_service|. |
24 static void Create(InfoBarService* infobar_service, | 24 static void Create(InfoBarService* infobar_service, |
25 const GURL& url, | 25 const GURL& url, |
26 content::ThreeDAPIType requester); | 26 content::ThreeDAPIType requester); |
27 | 27 |
28 private: | 28 private: |
29 enum DismissalHistogram { | 29 enum DismissalHistogram { |
30 IGNORED, | 30 IGNORED, |
31 RELOADED, | 31 RELOADED, |
32 CLOSED_WITHOUT_ACTION, | 32 CLOSED_WITHOUT_ACTION, |
33 DISMISSAL_MAX | 33 DISMISSAL_MAX |
34 }; | 34 }; |
35 | 35 |
36 ThreeDAPIInfoBarDelegate(const GURL& url, content::ThreeDAPIType requester); | 36 ThreeDAPIInfoBarDelegate(const GURL& url, content::ThreeDAPIType requester); |
37 virtual ~ThreeDAPIInfoBarDelegate(); | 37 virtual ~ThreeDAPIInfoBarDelegate(); |
38 | 38 |
39 // ConfirmInfoBarDelegate: | 39 // ConfirmInfoBarDelegate: |
40 virtual bool EqualsDelegate(InfoBarDelegate* delegate) const OVERRIDE; | 40 virtual bool EqualsDelegate( |
| 41 infobars::InfoBarDelegate* delegate) const OVERRIDE; |
41 virtual int GetIconID() const OVERRIDE; | 42 virtual int GetIconID() const OVERRIDE; |
42 virtual base::string16 GetMessageText() const OVERRIDE; | 43 virtual base::string16 GetMessageText() const OVERRIDE; |
43 virtual base::string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; | 44 virtual base::string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; |
44 virtual bool Accept() OVERRIDE; | 45 virtual bool Accept() OVERRIDE; |
45 virtual bool Cancel() OVERRIDE; | 46 virtual bool Cancel() OVERRIDE; |
46 virtual base::string16 GetLinkText() const OVERRIDE; | 47 virtual base::string16 GetLinkText() const OVERRIDE; |
47 virtual bool LinkClicked(WindowOpenDisposition disposition) OVERRIDE; | 48 virtual bool LinkClicked(WindowOpenDisposition disposition) OVERRIDE; |
48 | 49 |
49 GURL url_; | 50 GURL url_; |
50 content::ThreeDAPIType requester_; | 51 content::ThreeDAPIType requester_; |
(...skipping 26 matching lines...) Expand all Loading... |
77 action_taken_(false) { | 78 action_taken_(false) { |
78 } | 79 } |
79 | 80 |
80 ThreeDAPIInfoBarDelegate::~ThreeDAPIInfoBarDelegate() { | 81 ThreeDAPIInfoBarDelegate::~ThreeDAPIInfoBarDelegate() { |
81 if (message_text_queried_ && !action_taken_) { | 82 if (message_text_queried_ && !action_taken_) { |
82 UMA_HISTOGRAM_ENUMERATION("GPU.ThreeDAPIInfoBarDismissal", | 83 UMA_HISTOGRAM_ENUMERATION("GPU.ThreeDAPIInfoBarDismissal", |
83 CLOSED_WITHOUT_ACTION, DISMISSAL_MAX); | 84 CLOSED_WITHOUT_ACTION, DISMISSAL_MAX); |
84 } | 85 } |
85 } | 86 } |
86 | 87 |
87 bool ThreeDAPIInfoBarDelegate::EqualsDelegate(InfoBarDelegate* delegate) const { | 88 bool ThreeDAPIInfoBarDelegate::EqualsDelegate( |
| 89 infobars::InfoBarDelegate* delegate) const { |
88 // For the time being, if a given web page is actually using both | 90 // For the time being, if a given web page is actually using both |
89 // WebGL and Pepper 3D and both APIs are blocked, just leave the | 91 // WebGL and Pepper 3D and both APIs are blocked, just leave the |
90 // first infobar up. If the user selects "try again", both APIs will | 92 // first infobar up. If the user selects "try again", both APIs will |
91 // be unblocked and the web page reload will succeed. | 93 // be unblocked and the web page reload will succeed. |
92 return delegate->GetIconID() == GetIconID(); | 94 return delegate->GetIconID() == GetIconID(); |
93 } | 95 } |
94 | 96 |
95 int ThreeDAPIInfoBarDelegate::GetIconID() const { | 97 int ThreeDAPIInfoBarDelegate::GetIconID() const { |
96 return IDR_INFOBAR_3D_BLOCKED; | 98 return IDR_INFOBAR_3D_BLOCKED; |
97 } | 99 } |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 int render_process_id, | 168 int render_process_id, |
167 int render_view_id, | 169 int render_view_id, |
168 content::ThreeDAPIType requester) { | 170 content::ThreeDAPIType requester) { |
169 content::WebContents* web_contents = tab_util::GetWebContentsByID( | 171 content::WebContents* web_contents = tab_util::GetWebContentsByID( |
170 render_process_id, render_view_id); | 172 render_process_id, render_view_id); |
171 if (!web_contents) | 173 if (!web_contents) |
172 return; | 174 return; |
173 ThreeDAPIInfoBarDelegate::Create( | 175 ThreeDAPIInfoBarDelegate::Create( |
174 InfoBarService::FromWebContents(web_contents), url, requester); | 176 InfoBarService::FromWebContents(web_contents), url, requester); |
175 } | 177 } |
OLD | NEW |