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" | 9 #include "chrome/browser/infobars/infobar.h" |
10 #include "chrome/browser/infobars/infobar_service.h" | 10 #include "chrome/browser/infobars/infobar_service.h" |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 UMA_HISTOGRAM_ENUMERATION("GPU.ThreeDAPIInfoBarDismissal", IGNORED, | 125 UMA_HISTOGRAM_ENUMERATION("GPU.ThreeDAPIInfoBarDismissal", IGNORED, |
126 DISMISSAL_MAX); | 126 DISMISSAL_MAX); |
127 return true; | 127 return true; |
128 } | 128 } |
129 | 129 |
130 bool ThreeDAPIInfoBarDelegate::Cancel() { | 130 bool ThreeDAPIInfoBarDelegate::Cancel() { |
131 action_taken_ = true; | 131 action_taken_ = true; |
132 UMA_HISTOGRAM_ENUMERATION("GPU.ThreeDAPIInfoBarDismissal", RELOADED, | 132 UMA_HISTOGRAM_ENUMERATION("GPU.ThreeDAPIInfoBarDismissal", RELOADED, |
133 DISMISSAL_MAX); | 133 DISMISSAL_MAX); |
134 content::GpuDataManager::GetInstance()->UnblockDomainFrom3DAPIs(url_); | 134 content::GpuDataManager::GetInstance()->UnblockDomainFrom3DAPIs(url_); |
135 web_contents()->GetController().Reload(true); | 135 InfoBarService::WebContentsFromInfoBar(infobar())->GetController().Reload( |
| 136 true); |
136 return true; | 137 return true; |
137 } | 138 } |
138 | 139 |
139 base::string16 ThreeDAPIInfoBarDelegate::GetLinkText() const { | 140 base::string16 ThreeDAPIInfoBarDelegate::GetLinkText() const { |
140 return l10n_util::GetStringUTF16(IDS_LEARN_MORE); | 141 return l10n_util::GetStringUTF16(IDS_LEARN_MORE); |
141 } | 142 } |
142 | 143 |
143 bool ThreeDAPIInfoBarDelegate::LinkClicked(WindowOpenDisposition disposition) { | 144 bool ThreeDAPIInfoBarDelegate::LinkClicked(WindowOpenDisposition disposition) { |
144 web_contents()->OpenURL(content::OpenURLParams( | 145 InfoBarService::WebContentsFromInfoBar(infobar())->OpenURL( |
145 GURL("https://support.google.com/chrome/?p=ib_webgl"), | 146 content::OpenURLParams( |
146 content::Referrer(), | 147 GURL("https://support.google.com/chrome/?p=ib_webgl"), |
147 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, | 148 content::Referrer(), |
148 content::PAGE_TRANSITION_LINK, | 149 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, |
149 false)); | 150 content::PAGE_TRANSITION_LINK, false)); |
150 return false; | 151 return false; |
151 } | 152 } |
152 | 153 |
153 | 154 |
154 // ThreeDAPIObserver ---------------------------------------------------------- | 155 // ThreeDAPIObserver ---------------------------------------------------------- |
155 | 156 |
156 ThreeDAPIObserver::ThreeDAPIObserver() { | 157 ThreeDAPIObserver::ThreeDAPIObserver() { |
157 content::GpuDataManager::GetInstance()->AddObserver(this); | 158 content::GpuDataManager::GetInstance()->AddObserver(this); |
158 } | 159 } |
159 | 160 |
160 ThreeDAPIObserver::~ThreeDAPIObserver() { | 161 ThreeDAPIObserver::~ThreeDAPIObserver() { |
161 content::GpuDataManager::GetInstance()->RemoveObserver(this); | 162 content::GpuDataManager::GetInstance()->RemoveObserver(this); |
162 } | 163 } |
163 | 164 |
164 void ThreeDAPIObserver::DidBlock3DAPIs(const GURL& url, | 165 void ThreeDAPIObserver::DidBlock3DAPIs(const GURL& url, |
165 int render_process_id, | 166 int render_process_id, |
166 int render_view_id, | 167 int render_view_id, |
167 content::ThreeDAPIType requester) { | 168 content::ThreeDAPIType requester) { |
168 content::WebContents* web_contents = tab_util::GetWebContentsByID( | 169 content::WebContents* web_contents = tab_util::GetWebContentsByID( |
169 render_process_id, render_view_id); | 170 render_process_id, render_view_id); |
170 if (!web_contents) | 171 if (!web_contents) |
171 return; | 172 return; |
172 ThreeDAPIInfoBarDelegate::Create( | 173 ThreeDAPIInfoBarDelegate::Create( |
173 InfoBarService::FromWebContents(web_contents), url, requester); | 174 InfoBarService::FromWebContents(web_contents), url, requester); |
174 } | 175 } |
OLD | NEW |