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

Side by Side Diff: chrome/browser/automation/automation_provider_observers.cc

Issue 5572001: Send screenshots back to the client for debugging (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: added tests which compare against a reference md5 hash Created 9 years, 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/automation/automation_provider_observers.h" 5 #include "chrome/browser/automation/automation_provider_observers.h"
6 6
7 #include <deque> 7 #include <deque>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 1650 matching lines...) Expand 10 before | Expand all | Expand 10 after
1661 } 1661 }
1662 delete this; 1662 delete this;
1663 } else { 1663 } else {
1664 NOTREACHED(); 1664 NOTREACHED();
1665 } 1665 }
1666 } 1666 }
1667 1667
1668 PageSnapshotTaker::PageSnapshotTaker(AutomationProvider* automation, 1668 PageSnapshotTaker::PageSnapshotTaker(AutomationProvider* automation,
1669 IPC::Message* reply_message, 1669 IPC::Message* reply_message,
1670 RenderViewHost* render_view, 1670 RenderViewHost* render_view,
1671 const FilePath& path) 1671 const FilePath& path,
1672 bool use_json_interface)
1672 : automation_(automation->AsWeakPtr()), 1673 : automation_(automation->AsWeakPtr()),
1673 reply_message_(reply_message), 1674 reply_message_(reply_message),
1674 render_view_(render_view), 1675 render_view_(render_view),
1675 image_path_(path), 1676 image_path_(path),
1676 received_width_(false) {} 1677 received_width_(false),
1678 use_json_interface_(use_json_interface) {}
1677 1679
1678 PageSnapshotTaker::~PageSnapshotTaker() {} 1680 PageSnapshotTaker::~PageSnapshotTaker() {}
1679 1681
1680 void PageSnapshotTaker::Start() { 1682 void PageSnapshotTaker::Start() {
1681 ExecuteScript(L"window.domAutomationController.send(document.width);"); 1683 ExecuteScript(L"window.domAutomationController.send(document.width);");
1682 } 1684 }
1683 1685
1684 void PageSnapshotTaker::OnDomOperationCompleted(const std::string& json) { 1686 void PageSnapshotTaker::OnDomOperationCompleted(const std::string& json) {
1685 int dimension; 1687 int dimension;
1686 if (!base::StringToInt(json, &dimension)) { 1688 if (!base::StringToInt(json, &dimension)) {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1725 reply_message_->routing_id()); 1727 reply_message_->routing_id());
1726 1728
1727 render_view_->ExecuteJavascriptInWebFrame(string16(), 1729 render_view_->ExecuteJavascriptInWebFrame(string16(),
1728 WideToUTF16Hack(set_automation_id)); 1730 WideToUTF16Hack(set_automation_id));
1729 render_view_->ExecuteJavascriptInWebFrame(string16(), 1731 render_view_->ExecuteJavascriptInWebFrame(string16(),
1730 WideToUTF16Hack(javascript)); 1732 WideToUTF16Hack(javascript));
1731 } 1733 }
1732 1734
1733 void PageSnapshotTaker::SendMessage(bool success) { 1735 void PageSnapshotTaker::SendMessage(bool success) {
1734 if (automation_) { 1736 if (automation_) {
1735 AutomationMsg_CaptureEntirePageAsPNG::WriteReplyParams(reply_message_.get(), 1737 if (use_json_interface_) {
1736 success); 1738 DictionaryValue dict;
1737 automation_->Send(reply_message_.release()); 1739 dict.SetBoolean("result", success);
kkania 2011/03/17 18:35:11 change this to "success" to match what you have in
Joe 2011/03/18 00:33:32 Done.
1740 AutomationJSONReply(automation_, reply_message_.release())
1741 .SendSuccess(&dict);
1742 } else {
1743 AutomationMsg_CaptureEntirePageAsPNG::WriteReplyParams(
1744 reply_message_.get(), success);
1745 automation_->Send(reply_message_.release());
1746 }
1738 } 1747 }
1739 delete this; 1748 delete this;
1740 } 1749 }
1741 1750
1742 NTPInfoObserver::NTPInfoObserver( 1751 NTPInfoObserver::NTPInfoObserver(
1743 AutomationProvider* automation, 1752 AutomationProvider* automation,
1744 IPC::Message* reply_message, 1753 IPC::Message* reply_message,
1745 CancelableRequestConsumer* consumer) 1754 CancelableRequestConsumer* consumer)
1746 : automation_(automation->AsWeakPtr()), 1755 : automation_(automation->AsWeakPtr()),
1747 reply_message_(reply_message), 1756 reply_message_(reply_message),
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
2140 this, 2149 this,
2141 &WaitForProcessLauncherThreadToGoIdleObserver::RunOnUIThread)); 2150 &WaitForProcessLauncherThreadToGoIdleObserver::RunOnUIThread));
2142 } 2151 }
2143 2152
2144 void WaitForProcessLauncherThreadToGoIdleObserver::RunOnUIThread() { 2153 void WaitForProcessLauncherThreadToGoIdleObserver::RunOnUIThread() {
2145 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 2154 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
2146 if (automation_) 2155 if (automation_)
2147 automation_->Send(reply_message_.release()); 2156 automation_->Send(reply_message_.release());
2148 Release(); 2157 Release();
2149 } 2158 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698