| 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/managed_mode/managed_mode_interstitial.h" | 5 #include "chrome/browser/managed_mode/managed_mode_interstitial.h" |
| 6 | 6 |
| 7 #include "base/i18n/rtl.h" | 7 #include "base/i18n/rtl.h" |
| 8 #include "base/metrics/histogram.h" |
| 8 #include "chrome/browser/managed_mode/managed_mode_navigation_observer.h" | 9 #include "chrome/browser/managed_mode/managed_mode_navigation_observer.h" |
| 9 #include "chrome/browser/prefs/pref_service.h" | 10 #include "chrome/browser/prefs/pref_service.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
| 11 #include "chrome/browser/tab_contents/tab_util.h" | 12 #include "chrome/browser/tab_contents/tab_util.h" |
| 12 #include "chrome/browser/ui/webui/web_ui_util.h" | 13 #include "chrome/browser/ui/webui/web_ui_util.h" |
| 13 #include "chrome/common/jstemplate_builder.h" | 14 #include "chrome/common/jstemplate_builder.h" |
| 14 #include "chrome/common/pref_names.h" | 15 #include "chrome/common/pref_names.h" |
| 15 #include "chrome/common/url_constants.h" | 16 #include "chrome/common/url_constants.h" |
| 16 #include "content/public/browser/browser_thread.h" | 17 #include "content/public/browser/browser_thread.h" |
| 17 #include "content/public/browser/interstitial_page.h" | 18 #include "content/public/browser/interstitial_page.h" |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 | 110 |
| 110 base::StringPiece html( | 111 base::StringPiece html( |
| 111 ResourceBundle::GetSharedInstance().GetRawDataResource( | 112 ResourceBundle::GetSharedInstance().GetRawDataResource( |
| 112 IDR_MANAGED_MODE_BLOCK_INTERSTITIAL_HTML)); | 113 IDR_MANAGED_MODE_BLOCK_INTERSTITIAL_HTML)); |
| 113 | 114 |
| 114 jstemplate_builder::UseVersion2 version; | 115 jstemplate_builder::UseVersion2 version; |
| 115 return jstemplate_builder::GetI18nTemplateHtml(html, &strings); | 116 return jstemplate_builder::GetI18nTemplateHtml(html, &strings); |
| 116 } | 117 } |
| 117 | 118 |
| 118 void ManagedModeInterstitial::CommandReceived(const std::string& command) { | 119 void ManagedModeInterstitial::CommandReceived(const std::string& command) { |
| 120 // For use in histograms. |
| 121 enum Commands { |
| 122 PREVIEW, |
| 123 BACK, |
| 124 NTP, |
| 125 HISTOGRAM_BOUNDING_VALUE |
| 126 }; |
| 127 |
| 119 if (command == "\"preview\"") { | 128 if (command == "\"preview\"") { |
| 129 UMA_HISTOGRAM_ENUMERATION("ManagedMode.BlockingInterstitialCommand", |
| 130 PREVIEW, |
| 131 HISTOGRAM_BOUNDING_VALUE); |
| 120 interstitial_page_->Proceed(); | 132 interstitial_page_->Proceed(); |
| 121 return; | 133 return; |
| 122 } | 134 } |
| 123 | 135 |
| 124 if (command == "\"back\"") { | 136 if (command == "\"back\"") { |
| 137 UMA_HISTOGRAM_ENUMERATION("ManagedMode.BlockingInterstitialCommand", |
| 138 BACK, |
| 139 HISTOGRAM_BOUNDING_VALUE); |
| 125 interstitial_page_->DontProceed(); | 140 interstitial_page_->DontProceed(); |
| 126 return; | 141 return; |
| 127 } | 142 } |
| 128 | 143 |
| 129 if (command == "\"ntp\"") { | 144 if (command == "\"ntp\"") { |
| 145 UMA_HISTOGRAM_ENUMERATION("ManagedMode.BlockingInterstitialCommand", |
| 146 NTP, |
| 147 HISTOGRAM_BOUNDING_VALUE); |
| 130 GoToNewTabPage(); | 148 GoToNewTabPage(); |
| 131 return; | 149 return; |
| 132 } | 150 } |
| 133 | 151 |
| 134 NOTREACHED(); | 152 NOTREACHED(); |
| 135 } | 153 } |
| 136 | 154 |
| 137 void ManagedModeInterstitial::OnProceed() { | 155 void ManagedModeInterstitial::OnProceed() { |
| 138 DispatchContinueRequest(true); | 156 DispatchContinueRequest(true); |
| 139 } | 157 } |
| 140 | 158 |
| 141 void ManagedModeInterstitial::OnDontProceed() { | 159 void ManagedModeInterstitial::OnDontProceed() { |
| 142 DispatchContinueRequest(false); | 160 DispatchContinueRequest(false); |
| 143 } | 161 } |
| 144 | 162 |
| 145 void ManagedModeInterstitial::DispatchContinueRequest(bool continue_request) { | 163 void ManagedModeInterstitial::DispatchContinueRequest(bool continue_request) { |
| 146 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, | 164 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, |
| 147 base::Bind(callback_, continue_request)); | 165 base::Bind(callback_, continue_request)); |
| 148 } | 166 } |
| 149 | 167 |
| OLD | NEW |