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

Side by Side Diff: pdf/out_of_process_instance.cc

Issue 1332273003: Change the print preview UI to use the material design style buttons for zoom (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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 | « chrome/browser/resources/pdf/toolbar_manager.js ('k') | no next file » | 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 46
47 const char kChromePrint[] = "chrome://print/"; 47 const char kChromePrint[] = "chrome://print/";
48 const char kChromeExtension[] = 48 const char kChromeExtension[] =
49 "chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai"; 49 "chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai";
50 50
51 // Dictionary Value key names for the document accessibility info 51 // Dictionary Value key names for the document accessibility info
52 const char kAccessibleNumberOfPages[] = "numberOfPages"; 52 const char kAccessibleNumberOfPages[] = "numberOfPages";
53 const char kAccessibleLoaded[] = "loaded"; 53 const char kAccessibleLoaded[] = "loaded";
54 const char kAccessibleCopyable[] = "copyable"; 54 const char kAccessibleCopyable[] = "copyable";
55 55
56 // PDF background colors.
57 const uint32 kBackgroundColor = 0xFFCCCCCC;
58 const uint32 kBackgroundColorMaterial = 0xFF525659;
59
60 // Constants used in handling postMessage() messages. 56 // Constants used in handling postMessage() messages.
61 const char kType[] = "type"; 57 const char kType[] = "type";
62 // Viewport message arguments. (Page -> Plugin). 58 // Viewport message arguments. (Page -> Plugin).
63 const char kJSViewportType[] = "viewport"; 59 const char kJSViewportType[] = "viewport";
64 const char kJSXOffset[] = "xOffset"; 60 const char kJSXOffset[] = "xOffset";
65 const char kJSYOffset[] = "yOffset"; 61 const char kJSYOffset[] = "yOffset";
66 const char kJSZoom[] = "zoom"; 62 const char kJSZoom[] = "zoom";
67 // Stop scrolling message (Page -> Plugin) 63 // Stop scrolling message (Page -> Plugin)
68 const char kJSStopScrollingType[] = "stopScrolling"; 64 const char kJSStopScrollingType[] = "stopScrolling";
69 // Document dimension arguments (Plugin -> Page). 65 // Document dimension arguments (Plugin -> Page).
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 document_load_state_(LOAD_STATE_LOADING), 270 document_load_state_(LOAD_STATE_LOADING),
275 preview_document_load_state_(LOAD_STATE_COMPLETE), 271 preview_document_load_state_(LOAD_STATE_COMPLETE),
276 uma_(this), 272 uma_(this),
277 told_browser_about_unsupported_feature_(false), 273 told_browser_about_unsupported_feature_(false),
278 print_preview_page_count_(0), 274 print_preview_page_count_(0),
279 last_progress_sent_(0), 275 last_progress_sent_(0),
280 recently_sent_find_update_(false), 276 recently_sent_find_update_(false),
281 received_viewport_message_(false), 277 received_viewport_message_(false),
282 did_call_start_loading_(false), 278 did_call_start_loading_(false),
283 stop_scrolling_(false), 279 stop_scrolling_(false),
284 background_color_(kBackgroundColor), 280 background_color_(0),
285 top_toolbar_height_(0) { 281 top_toolbar_height_(0) {
286 loader_factory_.Initialize(this); 282 loader_factory_.Initialize(this);
287 timer_factory_.Initialize(this); 283 timer_factory_.Initialize(this);
288 form_factory_.Initialize(this); 284 form_factory_.Initialize(this);
289 print_callback_factory_.Initialize(this); 285 print_callback_factory_.Initialize(this);
290 engine_.reset(PDFEngine::Create(this)); 286 engine_.reset(PDFEngine::Create(this));
291 pp::Module::Get()->AddPluginInterface(kPPPPdfInterface, &ppp_private); 287 pp::Module::Get()->AddPluginInterface(kPPPPdfInterface, &ppp_private);
292 AddPerInstanceObject(kPPPPdfInterface, this); 288 AddPerInstanceObject(kPPPPdfInterface, this);
293 289
294 RequestFilteringInputEvents(PP_INPUTEVENT_CLASS_MOUSE); 290 RequestFilteringInputEvents(PP_INPUTEVENT_CLASS_MOUSE);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 GetLocalizedString(PP_RESOURCESTRING_PDFLOADING)); 339 GetLocalizedString(PP_RESOURCESTRING_PDFLOADING));
344 translated_strings.Set(kJSLoadFailedString, 340 translated_strings.Set(kJSLoadFailedString,
345 GetLocalizedString(PP_RESOURCESTRING_PDFLOAD_FAILED)); 341 GetLocalizedString(PP_RESOURCESTRING_PDFLOAD_FAILED));
346 PostMessage(translated_strings); 342 PostMessage(translated_strings);
347 343
348 text_input_.reset(new pp::TextInput_Dev(this)); 344 text_input_.reset(new pp::TextInput_Dev(this));
349 345
350 const char* stream_url = nullptr; 346 const char* stream_url = nullptr;
351 const char* original_url = nullptr; 347 const char* original_url = nullptr;
352 const char* headers = nullptr; 348 const char* headers = nullptr;
353 bool is_material = false;
354 for (uint32_t i = 0; i < argc; ++i) { 349 for (uint32_t i = 0; i < argc; ++i) {
350 bool success = true;
355 if (strcmp(argn[i], "src") == 0) 351 if (strcmp(argn[i], "src") == 0)
356 original_url = argv[i]; 352 original_url = argv[i];
357 else if (strcmp(argn[i], "stream-url") == 0) 353 else if (strcmp(argn[i], "stream-url") == 0)
358 stream_url = argv[i]; 354 stream_url = argv[i];
359 else if (strcmp(argn[i], "headers") == 0) 355 else if (strcmp(argn[i], "headers") == 0)
360 headers = argv[i]; 356 headers = argv[i];
361 else if (strcmp(argn[i], "is-material") == 0) 357 else if (strcmp(argn[i], "background-color") == 0)
362 is_material = true; 358 success = base::HexStringToUInt(argv[i], &background_color_);
363 else if (strcmp(argn[i], "top-toolbar-height") == 0) 359 else if (strcmp(argn[i], "top-toolbar-height") == 0)
364 base::StringToInt(argv[i], &top_toolbar_height_); 360 success = base::StringToInt(argv[i], &top_toolbar_height_);
361
362 if (!success)
363 return false;
365 } 364 }
366 365
367 if (is_material)
368 background_color_ = kBackgroundColorMaterial;
369 else
370 background_color_ = kBackgroundColor;
371
372 if (!original_url) 366 if (!original_url)
373 return false; 367 return false;
374 368
375 if (!stream_url) 369 if (!stream_url)
376 stream_url = original_url; 370 stream_url = original_url;
377 371
378 // If we're in print preview mode we don't need to load the document yet. 372 // If we're in print preview mode we don't need to load the document yet.
379 // A |kJSResetPrintPreviewModeType| message will be sent to the plugin letting 373 // A |kJSResetPrintPreviewModeType| message will be sent to the plugin letting
380 // it know the url to load. By not loading here we avoid loading the same 374 // it know the url to load. By not loading here we avoid loading the same
381 // document twice. 375 // document twice.
(...skipping 1056 matching lines...) Expand 10 before | Expand all | Expand 10 after
1438 const pp::FloatPoint& scroll_offset) { 1432 const pp::FloatPoint& scroll_offset) {
1439 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); 1433 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width();
1440 float x = std::max(std::min(scroll_offset.x(), max_x), 0.0f); 1434 float x = std::max(std::min(scroll_offset.x(), max_x), 0.0f);
1441 float min_y = -top_toolbar_height_; 1435 float min_y = -top_toolbar_height_;
1442 float max_y = document_size_.height() * zoom_ - plugin_dip_size_.height(); 1436 float max_y = document_size_.height() * zoom_ - plugin_dip_size_.height();
1443 float y = std::max(std::min(scroll_offset.y(), max_y), min_y); 1437 float y = std::max(std::min(scroll_offset.y(), max_y), min_y);
1444 return pp::FloatPoint(x, y); 1438 return pp::FloatPoint(x, y);
1445 } 1439 }
1446 1440
1447 } // namespace chrome_pdf 1441 } // namespace chrome_pdf
OLDNEW
« no previous file with comments | « chrome/browser/resources/pdf/toolbar_manager.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698