| 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/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/metrics/histogram_macros.h" | 8 #include "base/metrics/histogram_macros.h" |
| 9 #include "chrome/browser/infobars/infobar_service.h" | 9 #include "chrome/browser/infobars/infobar_service.h" |
| 10 #include "chrome/browser/tab_contents/tab_util.h" | 10 #include "chrome/browser/tab_contents/tab_util.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 | 40 |
| 41 // ConfirmInfoBarDelegate: | 41 // ConfirmInfoBarDelegate: |
| 42 infobars::InfoBarDelegate::InfoBarIdentifier GetIdentifier() const override; | 42 infobars::InfoBarDelegate::InfoBarIdentifier GetIdentifier() const override; |
| 43 int GetIconId() const override; | 43 int GetIconId() const override; |
| 44 bool EqualsDelegate(infobars::InfoBarDelegate* delegate) const override; | 44 bool EqualsDelegate(infobars::InfoBarDelegate* delegate) const override; |
| 45 ThreeDAPIInfoBarDelegate* AsThreeDAPIInfoBarDelegate() override; | 45 ThreeDAPIInfoBarDelegate* AsThreeDAPIInfoBarDelegate() override; |
| 46 base::string16 GetMessageText() const override; | 46 base::string16 GetMessageText() const override; |
| 47 base::string16 GetButtonLabel(InfoBarButton button) const override; | 47 base::string16 GetButtonLabel(InfoBarButton button) const override; |
| 48 bool Accept() override; | 48 bool Accept() override; |
| 49 bool Cancel() override; | 49 bool Cancel() override; |
| 50 base::string16 GetLinkText() const override; | |
| 51 GURL GetLinkURL() const override; | |
| 52 | 50 |
| 53 GURL url_; | 51 GURL url_; |
| 54 content::ThreeDAPIType requester_; | 52 content::ThreeDAPIType requester_; |
| 55 // Basically indicates whether the infobar was displayed at all, or | 53 // Basically indicates whether the infobar was displayed at all, or |
| 56 // was a temporary instance thrown away by the InfobarService. | 54 // was a temporary instance thrown away by the InfobarService. |
| 57 mutable bool message_text_queried_; | 55 mutable bool message_text_queried_; |
| 58 bool action_taken_; | 56 bool action_taken_; |
| 59 | 57 |
| 60 DISALLOW_COPY_AND_ASSIGN(ThreeDAPIInfoBarDelegate); | 58 DISALLOW_COPY_AND_ASSIGN(ThreeDAPIInfoBarDelegate); |
| 61 }; | 59 }; |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 bool ThreeDAPIInfoBarDelegate::Cancel() { | 143 bool ThreeDAPIInfoBarDelegate::Cancel() { |
| 146 action_taken_ = true; | 144 action_taken_ = true; |
| 147 UMA_HISTOGRAM_ENUMERATION("GPU.ThreeDAPIInfoBarDismissal", RELOADED, | 145 UMA_HISTOGRAM_ENUMERATION("GPU.ThreeDAPIInfoBarDismissal", RELOADED, |
| 148 DISMISSAL_MAX); | 146 DISMISSAL_MAX); |
| 149 content::GpuDataManager::GetInstance()->UnblockDomainFrom3DAPIs(url_); | 147 content::GpuDataManager::GetInstance()->UnblockDomainFrom3DAPIs(url_); |
| 150 InfoBarService::WebContentsFromInfoBar(infobar())->GetController().Reload( | 148 InfoBarService::WebContentsFromInfoBar(infobar())->GetController().Reload( |
| 151 true); | 149 true); |
| 152 return true; | 150 return true; |
| 153 } | 151 } |
| 154 | 152 |
| 155 base::string16 ThreeDAPIInfoBarDelegate::GetLinkText() const { | |
| 156 return l10n_util::GetStringUTF16(IDS_LEARN_MORE); | |
| 157 } | |
| 158 | |
| 159 GURL ThreeDAPIInfoBarDelegate::GetLinkURL() const { | |
| 160 return GURL("https://support.google.com/chrome/?p=ib_webgl"); | |
| 161 } | |
| 162 | |
| 163 | |
| 164 // ThreeDAPIObserver ---------------------------------------------------------- | 153 // ThreeDAPIObserver ---------------------------------------------------------- |
| 165 | 154 |
| 166 ThreeDAPIObserver::ThreeDAPIObserver() { | 155 ThreeDAPIObserver::ThreeDAPIObserver() { |
| 167 content::GpuDataManager::GetInstance()->AddObserver(this); | 156 content::GpuDataManager::GetInstance()->AddObserver(this); |
| 168 } | 157 } |
| 169 | 158 |
| 170 ThreeDAPIObserver::~ThreeDAPIObserver() { | 159 ThreeDAPIObserver::~ThreeDAPIObserver() { |
| 171 content::GpuDataManager::GetInstance()->RemoveObserver(this); | 160 content::GpuDataManager::GetInstance()->RemoveObserver(this); |
| 172 } | 161 } |
| 173 | 162 |
| 174 void ThreeDAPIObserver::DidBlock3DAPIs(const GURL& top_origin_url, | 163 void ThreeDAPIObserver::DidBlock3DAPIs(const GURL& top_origin_url, |
| 175 int render_process_id, | 164 int render_process_id, |
| 176 int render_frame_id, | 165 int render_frame_id, |
| 177 content::ThreeDAPIType requester) { | 166 content::ThreeDAPIType requester) { |
| 178 content::WebContents* web_contents = tab_util::GetWebContentsByFrameID( | 167 content::WebContents* web_contents = tab_util::GetWebContentsByFrameID( |
| 179 render_process_id, render_frame_id); | 168 render_process_id, render_frame_id); |
| 180 if (!web_contents) | 169 if (!web_contents) |
| 181 return; | 170 return; |
| 182 ThreeDAPIInfoBarDelegate::Create( | 171 ThreeDAPIInfoBarDelegate::Create( |
| 183 InfoBarService::FromWebContents(web_contents), top_origin_url, requester); | 172 InfoBarService::FromWebContents(web_contents), top_origin_url, requester); |
| 184 } | 173 } |
| OLD | NEW |