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