Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(499)

Side by Side Diff: pdf/out_of_process_instance.cc

Issue 1403833002: Material PDF: Add metrics to count usage of PDF title and bookmarks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use a single histogram Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | tools/metrics/actions/extract_actions.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "pdf/out_of_process_instance.h" 5 #include "pdf/out_of_process_instance.h"
6 6
7 #include <algorithm> // for min/max() 7 #include <algorithm> // for min/max()
8 #define _USE_MATH_DEFINES // for M_PI 8 #define _USE_MATH_DEFINES // for M_PI
9 #include <cmath> // for log() and pow() 9 #include <cmath> // for log() and pow()
10 #include <math.h> 10 #include <math.h>
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 const char kJSFieldFocus[] = "focused"; 149 const char kJSFieldFocus[] = "focused";
150 150
151 const int kFindResultCooldownMs = 100; 151 const int kFindResultCooldownMs = 100;
152 152
153 const double kMinZoom = 0.01; 153 const double kMinZoom = 0.01;
154 154
155 namespace { 155 namespace {
156 156
157 static const char kPPPPdfInterface[] = PPP_PDF_INTERFACE_1; 157 static const char kPPPPdfInterface[] = PPP_PDF_INTERFACE_1;
158 158
159 // Used for UMA. Do not delete entries, and keep in sync with histograms.xml.
160 enum PDFFeatures {
161 LOADED_DOCUMENT = 0,
162 HAS_TITLE = 1,
163 HAS_BOOKMARKS = 2,
164 FEATURES_COUNT
165 };
166
159 PP_Var GetLinkAtPosition(PP_Instance instance, PP_Point point) { 167 PP_Var GetLinkAtPosition(PP_Instance instance, PP_Point point) {
160 pp::Var var; 168 pp::Var var;
161 void* object = pp::Instance::GetPerInstanceObject(instance, kPPPPdfInterface); 169 void* object = pp::Instance::GetPerInstanceObject(instance, kPPPPdfInterface);
162 if (object) { 170 if (object) {
163 var = static_cast<OutOfProcessInstance*>(object)->GetLinkAtPosition( 171 var = static_cast<OutOfProcessInstance*>(object)->GetLinkAtPosition(
164 pp::Point(point)); 172 pp::Point(point));
165 } 173 }
166 return var.Detach(); 174 return var.Detach();
167 } 175 }
168 176
(...skipping 924 matching lines...) Expand 10 before | Expand all | Expand 10 after
1093 1101
1094 void OutOfProcessInstance::DocumentPaintOccurred() { 1102 void OutOfProcessInstance::DocumentPaintOccurred() {
1095 } 1103 }
1096 1104
1097 void OutOfProcessInstance::DocumentLoadComplete(int page_count) { 1105 void OutOfProcessInstance::DocumentLoadComplete(int page_count) {
1098 // Clear focus state for OSK. 1106 // Clear focus state for OSK.
1099 FormTextFieldFocusChange(false); 1107 FormTextFieldFocusChange(false);
1100 1108
1101 DCHECK(document_load_state_ == LOAD_STATE_LOADING); 1109 DCHECK(document_load_state_ == LOAD_STATE_LOADING);
1102 document_load_state_ = LOAD_STATE_COMPLETE; 1110 document_load_state_ = LOAD_STATE_COMPLETE;
1103 UserMetricsRecordAction("PDF.LoadSuccess"); 1111 UserMetricsRecordAction("PDF.LoadSuccess");
tsergeant 2015/10/15 03:00:37 This action is now obsolete, but I'll follow up wi
1112 uma_.HistogramEnumeration("PDF.DocumentFeature", LOADED_DOCUMENT,
1113 FEATURES_COUNT);
1104 1114
1105 // Note: If we are in print preview mode the scroll location is retained 1115 // Note: If we are in print preview mode the scroll location is retained
1106 // across document loads so we don't want to scroll again and override it. 1116 // across document loads so we don't want to scroll again and override it.
1107 if (IsPrintPreview()) { 1117 if (IsPrintPreview()) {
1108 AppendBlankPrintPreviewPages(); 1118 AppendBlankPrintPreviewPages();
1109 OnGeometryChanged(0, 0); 1119 OnGeometryChanged(0, 0);
1110 } 1120 }
1111 1121
1112 pp::VarDictionary metadata_message; 1122 pp::VarDictionary metadata_message;
1113 metadata_message.Set(pp::Var(kType), pp::Var(kJSMetadataType)); 1123 metadata_message.Set(pp::Var(kType), pp::Var(kJSMetadataType));
1114 std::string title = engine_->GetMetadata("Title"); 1124 std::string title = engine_->GetMetadata("Title");
1115 if (!base::TrimWhitespace(base::UTF8ToUTF16(title), base::TRIM_ALL).empty()) 1125 if (!base::TrimWhitespace(base::UTF8ToUTF16(title), base::TRIM_ALL).empty()) {
1116 metadata_message.Set(pp::Var(kJSTitle), pp::Var(title)); 1126 metadata_message.Set(pp::Var(kJSTitle), pp::Var(title));
1127 uma_.HistogramEnumeration("PDF.DocumentFeature", HAS_TITLE, FEATURES_COUNT);
1128 }
1117 1129
1118 metadata_message.Set(pp::Var(kJSBookmarks), engine_->GetBookmarks()); 1130 pp::VarArray bookmarks = engine_->GetBookmarks();
1131 metadata_message.Set(pp::Var(kJSBookmarks), bookmarks);
1132 if (bookmarks.GetLength() > 0) {
1133 uma_.HistogramEnumeration("PDF.DocumentFeature", HAS_BOOKMARKS,
1134 FEATURES_COUNT);
1135 }
1119 PostMessage(metadata_message); 1136 PostMessage(metadata_message);
1120 1137
1121 pp::VarDictionary progress_message; 1138 pp::VarDictionary progress_message;
1122 progress_message.Set(pp::Var(kType), pp::Var(kJSLoadProgressType)); 1139 progress_message.Set(pp::Var(kType), pp::Var(kJSLoadProgressType));
1123 progress_message.Set(pp::Var(kJSProgressPercentage), pp::Var(100)); 1140 progress_message.Set(pp::Var(kJSProgressPercentage), pp::Var(100));
1124 PostMessage(progress_message); 1141 PostMessage(progress_message);
1125 1142
1126 if (!full_) 1143 if (!full_)
1127 return; 1144 return;
1128 1145
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
1416 const pp::FloatPoint& scroll_offset) { 1433 const pp::FloatPoint& scroll_offset) {
1417 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); 1434 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width();
1418 float x = std::max(std::min(scroll_offset.x(), max_x), 0.0f); 1435 float x = std::max(std::min(scroll_offset.x(), max_x), 0.0f);
1419 float min_y = -top_toolbar_height_; 1436 float min_y = -top_toolbar_height_;
1420 float max_y = document_size_.height() * zoom_ - plugin_dip_size_.height(); 1437 float max_y = document_size_.height() * zoom_ - plugin_dip_size_.height();
1421 float y = std::max(std::min(scroll_offset.y(), max_y), min_y); 1438 float y = std::max(std::min(scroll_offset.y(), max_y), min_y);
1422 return pp::FloatPoint(x, y); 1439 return pp::FloatPoint(x, y);
1423 } 1440 }
1424 1441
1425 } // namespace chrome_pdf 1442 } // namespace chrome_pdf
OLDNEW
« no previous file with comments | « no previous file | tools/metrics/actions/extract_actions.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698