| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 namespace blink { | 74 namespace blink { |
| 75 | 75 |
| 76 using protocol::Response; | 76 using protocol::Response; |
| 77 | 77 |
| 78 namespace PageAgentState { | 78 namespace PageAgentState { |
| 79 static const char kPageAgentEnabled[] = "pageAgentEnabled"; | 79 static const char kPageAgentEnabled[] = "pageAgentEnabled"; |
| 80 static const char kPageAgentScriptsToEvaluateOnLoad[] = | 80 static const char kPageAgentScriptsToEvaluateOnLoad[] = |
| 81 "pageAgentScriptsToEvaluateOnLoad"; | 81 "pageAgentScriptsToEvaluateOnLoad"; |
| 82 static const char kScreencastEnabled[] = "screencastEnabled"; | 82 static const char kScreencastEnabled[] = "screencastEnabled"; |
| 83 static const char kAutoAttachToCreatedPages[] = "autoAttachToCreatedPages"; | 83 static const char kAutoAttachToCreatedPages[] = "autoAttachToCreatedPages"; |
| 84 static const char kOverlaySuspended[] = "overlaySuspended"; | |
| 85 static const char kOverlayMessage[] = "overlayMessage"; | |
| 86 } | 84 } |
| 87 | 85 |
| 88 namespace { | 86 namespace { |
| 89 | 87 |
| 90 KURL UrlWithoutFragment(const KURL& url) { | 88 KURL UrlWithoutFragment(const KURL& url) { |
| 91 KURL result = url; | 89 KURL result = url; |
| 92 result.RemoveFragmentIdentifier(); | 90 result.RemoveFragmentIdentifier(); |
| 93 return result; | 91 return result; |
| 94 } | 92 } |
| 95 | 93 |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 last_script_identifier_(0), | 367 last_script_identifier_(0), |
| 370 enabled_(false), | 368 enabled_(false), |
| 371 reloading_(false), | 369 reloading_(false), |
| 372 inspector_resource_content_loader_(resource_content_loader), | 370 inspector_resource_content_loader_(resource_content_loader), |
| 373 resource_content_loader_client_id_( | 371 resource_content_loader_client_id_( |
| 374 resource_content_loader->CreateClientId()) {} | 372 resource_content_loader->CreateClientId()) {} |
| 375 | 373 |
| 376 void InspectorPageAgent::Restore() { | 374 void InspectorPageAgent::Restore() { |
| 377 if (state_->booleanProperty(PageAgentState::kPageAgentEnabled, false)) | 375 if (state_->booleanProperty(PageAgentState::kPageAgentEnabled, false)) |
| 378 enable(); | 376 enable(); |
| 379 if (client_) { | |
| 380 String overlay_message; | |
| 381 state_->getString(PageAgentState::kOverlayMessage, &overlay_message); | |
| 382 client_->ConfigureOverlay( | |
| 383 state_->booleanProperty(PageAgentState::kOverlaySuspended, false), | |
| 384 overlay_message); | |
| 385 } | |
| 386 } | 377 } |
| 387 | 378 |
| 388 Response InspectorPageAgent::enable() { | 379 Response InspectorPageAgent::enable() { |
| 389 enabled_ = true; | 380 enabled_ = true; |
| 390 state_->setBoolean(PageAgentState::kPageAgentEnabled, true); | 381 state_->setBoolean(PageAgentState::kPageAgentEnabled, true); |
| 391 instrumenting_agents_->addInspectorPageAgent(this); | 382 instrumenting_agents_->addInspectorPageAgent(this); |
| 392 return Response::OK(); | 383 return Response::OK(); |
| 393 } | 384 } |
| 394 | 385 |
| 395 Response InspectorPageAgent::disable() { | 386 Response InspectorPageAgent::disable() { |
| 396 enabled_ = false; | 387 enabled_ = false; |
| 397 state_->setBoolean(PageAgentState::kPageAgentEnabled, false); | 388 state_->setBoolean(PageAgentState::kPageAgentEnabled, false); |
| 398 state_->remove(PageAgentState::kPageAgentScriptsToEvaluateOnLoad); | 389 state_->remove(PageAgentState::kPageAgentScriptsToEvaluateOnLoad); |
| 399 script_to_evaluate_on_load_once_ = String(); | 390 script_to_evaluate_on_load_once_ = String(); |
| 400 pending_script_to_evaluate_on_load_once_ = String(); | 391 pending_script_to_evaluate_on_load_once_ = String(); |
| 401 instrumenting_agents_->removeInspectorPageAgent(this); | 392 instrumenting_agents_->removeInspectorPageAgent(this); |
| 402 inspector_resource_content_loader_->Cancel( | 393 inspector_resource_content_loader_->Cancel( |
| 403 resource_content_loader_client_id_); | 394 resource_content_loader_client_id_); |
| 404 | 395 |
| 405 stopScreencast(); | 396 stopScreencast(); |
| 406 configureOverlay(false, String()); | |
| 407 | 397 |
| 408 FinishReload(); | 398 FinishReload(); |
| 409 return Response::OK(); | 399 return Response::OK(); |
| 410 } | 400 } |
| 411 | 401 |
| 412 Response InspectorPageAgent::addScriptToEvaluateOnLoad(const String& source, | 402 Response InspectorPageAgent::addScriptToEvaluateOnLoad(const String& source, |
| 413 String* identifier) { | 403 String* identifier) { |
| 414 protocol::DictionaryValue* scripts = | 404 protocol::DictionaryValue* scripts = |
| 415 state_->getObject(PageAgentState::kPageAgentScriptsToEvaluateOnLoad); | 405 state_->getObject(PageAgentState::kPageAgentScriptsToEvaluateOnLoad); |
| 416 if (!scripts) { | 406 if (!scripts) { |
| (...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 857 Maybe<int> every_nth_frame) { | 847 Maybe<int> every_nth_frame) { |
| 858 state_->setBoolean(PageAgentState::kScreencastEnabled, true); | 848 state_->setBoolean(PageAgentState::kScreencastEnabled, true); |
| 859 return Response::OK(); | 849 return Response::OK(); |
| 860 } | 850 } |
| 861 | 851 |
| 862 Response InspectorPageAgent::stopScreencast() { | 852 Response InspectorPageAgent::stopScreencast() { |
| 863 state_->setBoolean(PageAgentState::kScreencastEnabled, false); | 853 state_->setBoolean(PageAgentState::kScreencastEnabled, false); |
| 864 return Response::OK(); | 854 return Response::OK(); |
| 865 } | 855 } |
| 866 | 856 |
| 867 Response InspectorPageAgent::configureOverlay(Maybe<bool> suspended, | |
| 868 Maybe<String> message) { | |
| 869 state_->setBoolean(PageAgentState::kOverlaySuspended, | |
| 870 suspended.fromMaybe(false)); | |
| 871 state_->setString(PageAgentState::kOverlaySuspended, | |
| 872 message.fromMaybe(String())); | |
| 873 if (client_) | |
| 874 client_->ConfigureOverlay(suspended.fromMaybe(false), | |
| 875 message.fromMaybe(String())); | |
| 876 return Response::OK(); | |
| 877 } | |
| 878 | |
| 879 Response InspectorPageAgent::getLayoutMetrics( | 857 Response InspectorPageAgent::getLayoutMetrics( |
| 880 std::unique_ptr<protocol::Page::LayoutViewport>* out_layout_viewport, | 858 std::unique_ptr<protocol::Page::LayoutViewport>* out_layout_viewport, |
| 881 std::unique_ptr<protocol::Page::VisualViewport>* out_visual_viewport, | 859 std::unique_ptr<protocol::Page::VisualViewport>* out_visual_viewport, |
| 882 std::unique_ptr<protocol::DOM::Rect>* out_content_size) { | 860 std::unique_ptr<protocol::DOM::Rect>* out_content_size) { |
| 883 LocalFrame* main_frame = inspected_frames_->Root(); | 861 LocalFrame* main_frame = inspected_frames_->Root(); |
| 884 VisualViewport& visual_viewport = main_frame->GetPage()->GetVisualViewport(); | 862 VisualViewport& visual_viewport = main_frame->GetPage()->GetVisualViewport(); |
| 885 | 863 |
| 886 main_frame->GetDocument()->UpdateStyleAndLayoutIgnorePendingStylesheets(); | 864 main_frame->GetDocument()->UpdateStyleAndLayoutIgnorePendingStylesheets(); |
| 887 | 865 |
| 888 IntRect visible_contents = main_frame->View()->VisibleContentRect(); | 866 IntRect visible_contents = main_frame->View()->VisibleContentRect(); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 923 return Response::OK(); | 901 return Response::OK(); |
| 924 } | 902 } |
| 925 | 903 |
| 926 DEFINE_TRACE(InspectorPageAgent) { | 904 DEFINE_TRACE(InspectorPageAgent) { |
| 927 visitor->Trace(inspected_frames_); | 905 visitor->Trace(inspected_frames_); |
| 928 visitor->Trace(inspector_resource_content_loader_); | 906 visitor->Trace(inspector_resource_content_loader_); |
| 929 InspectorBaseAgent::Trace(visitor); | 907 InspectorBaseAgent::Trace(visitor); |
| 930 } | 908 } |
| 931 | 909 |
| 932 } // namespace blink | 910 } // namespace blink |
| OLD | NEW |