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

Side by Side Diff: components/dom_distiller/content/browser/dom_distiller_viewer_source.cc

Issue 1225183002: Font size in DomDistiller prefs syncs with local scaling (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix for rebasing Created 5 years, 4 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
OLDNEW
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 "components/dom_distiller/content/browser/dom_distiller_viewer_source.h " 5 #include "components/dom_distiller/content/browser/dom_distiller_viewer_source.h "
6 6
7 #include <sstream>
8 #include <string> 7 #include <string>
9 #include <vector> 8 #include <vector>
10 9
11 #include "base/memory/ref_counted_memory.h" 10 #include "base/memory/ref_counted_memory.h"
12 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
13 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
14 #include "base/metrics/user_metrics.h" 13 #include "base/metrics/user_metrics.h"
14 #include "base/strings/string_number_conversions.h"
15 #include "base/strings/string_util.h"
15 #include "base/strings/utf_string_conversions.h" 16 #include "base/strings/utf_string_conversions.h"
16 #include "components/dom_distiller/content/browser/distiller_javascript_utils.h" 17 #include "components/dom_distiller/content/browser/distiller_javascript_utils.h"
17 #include "components/dom_distiller/content/browser/external_feedback_reporter.h" 18 #include "components/dom_distiller/content/browser/external_feedback_reporter.h"
18 #include "components/dom_distiller/core/distilled_page_prefs.h" 19 #include "components/dom_distiller/core/distilled_page_prefs.h"
19 #include "components/dom_distiller/core/dom_distiller_request_view_base.h" 20 #include "components/dom_distiller/core/dom_distiller_request_view_base.h"
20 #include "components/dom_distiller/core/dom_distiller_service.h" 21 #include "components/dom_distiller/core/dom_distiller_service.h"
21 #include "components/dom_distiller/core/experiments.h" 22 #include "components/dom_distiller/core/experiments.h"
22 #include "components/dom_distiller/core/feedback_reporter.h" 23 #include "components/dom_distiller/core/feedback_reporter.h"
23 #include "components/dom_distiller/core/task_tracker.h" 24 #include "components/dom_distiller/core/task_tracker.h"
24 #include "components/dom_distiller/core/url_constants.h" 25 #include "components/dom_distiller/core/url_constants.h"
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 SendJavaScript(viewer::GetShowFeedbackFormJs()); 161 SendJavaScript(viewer::GetShowFeedbackFormJs());
161 } 162 }
162 Cancel(); // This will cause the object to clean itself up. 163 Cancel(); // This will cause the object to clean itself up.
163 return; 164 return;
164 } 165 }
165 166
166 if (render_frame_host->GetParent()) { 167 if (render_frame_host->GetParent()) {
167 return; 168 return;
168 } 169 }
169 waiting_for_page_ready_ = false; 170 waiting_for_page_ready_ = false;
171 SendJavaScript(viewer::GetDistilledPageFontScalingJs(
172 distilled_page_prefs_->GetFontScaling()));
170 if (buffer_.empty()) { 173 if (buffer_.empty()) {
171 return; 174 return;
172 } 175 }
173 RunIsolatedJavaScript(web_contents()->GetMainFrame(), buffer_); 176 RunIsolatedJavaScript(web_contents()->GetMainFrame(), buffer_);
174 buffer_.clear(); 177 buffer_.clear();
175 } 178 }
176 179
177 DomDistillerViewerSource::DomDistillerViewerSource( 180 DomDistillerViewerSource::DomDistillerViewerSource(
178 DomDistillerServiceInterface* dom_distiller_service, 181 DomDistillerServiceInterface* dom_distiller_service,
179 const std::string& scheme, 182 const std::string& scheme,
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 return; 221 return;
219 content::WebContents* contents = 222 content::WebContents* contents =
220 content::WebContents::FromRenderFrameHost(render_frame_host); 223 content::WebContents::FromRenderFrameHost(render_frame_host);
221 external_feedback_reporter_->ReportExternalFeedback( 224 external_feedback_reporter_->ReportExternalFeedback(
222 contents, contents->GetURL(), false); 225 contents, contents->GetURL(), false);
223 return; 226 return;
224 } else if (kFeedbackGood == path) { 227 } else if (kFeedbackGood == path) {
225 FeedbackReporter::ReportQuality(true); 228 FeedbackReporter::ReportQuality(true);
226 callback.Run(NULL); 229 callback.Run(NULL);
227 return; 230 return;
231 } else if (base::StartsWith(path, kViewerSaveFontScalingPath,
232 base::CompareCase::SENSITIVE)) {
233 double scale = 1.0;
234 base::StringToDouble(
nyquist 2015/08/11 06:27:56 Should we do something if base::StringToDouble ret
wychen 2015/08/31 21:47:39 Done.
235 path.substr(strlen(kViewerSaveFontScalingPath)), &scale);
236 dom_distiller_service_->GetDistilledPagePrefs()->SetFontScaling(scale);
237 callback.Run(NULL);
238 return;
228 } 239 }
229 content::WebContents* web_contents = 240 content::WebContents* web_contents =
230 content::WebContents::FromRenderFrameHost(render_frame_host); 241 content::WebContents::FromRenderFrameHost(render_frame_host);
231 DCHECK(web_contents); 242 DCHECK(web_contents);
232 // An empty |path| is invalid, but guard against it. If not empty, assume 243 // An empty |path| is invalid, but guard against it. If not empty, assume
233 // |path| starts with '?', which is stripped away. 244 // |path| starts with '?', which is stripped away.
234 const std::string path_after_query_separator = 245 const std::string path_after_query_separator =
235 path.size() > 0 ? path.substr(1) : ""; 246 path.size() > 0 ? path.substr(1) : "";
236 RequestViewerHandle* request_viewer_handle = 247 RequestViewerHandle* request_viewer_handle =
237 new RequestViewerHandle(web_contents, scheme_, path_after_query_separator, 248 new RequestViewerHandle(web_contents, scheme_, path_after_query_separator,
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 std::string DomDistillerViewerSource::GetContentSecurityPolicyObjectSrc() 296 std::string DomDistillerViewerSource::GetContentSecurityPolicyObjectSrc()
286 const { 297 const {
287 return "object-src 'none'; style-src 'self' https://fonts.googleapis.com;"; 298 return "object-src 'none'; style-src 'self' https://fonts.googleapis.com;";
288 } 299 }
289 300
290 std::string DomDistillerViewerSource::GetContentSecurityPolicyFrameSrc() const { 301 std::string DomDistillerViewerSource::GetContentSecurityPolicyFrameSrc() const {
291 return "frame-src *;"; 302 return "frame-src *;";
292 } 303 }
293 304
294 } // namespace dom_distiller 305 } // namespace dom_distiller
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698