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

Unified Diff: content/shell/shell.cc

Issue 9289045: Add option --dump-render-tree to content_shell to dump the render tree as text. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: updates Created 8 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/content_shell.gypi ('k') | content/shell/shell_content_browser_client.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/shell/shell.cc
diff --git a/content/shell/shell.cc b/content/shell/shell.cc
index fcf684ce5e5d825b054f0f8a805e6decb3c1fb10..0162c5af2c87ff22b642224e5f4175e2b88564f6 100644
--- a/content/shell/shell.cc
+++ b/content/shell/shell.cc
@@ -4,11 +4,16 @@
#include "content/shell/shell.h"
+#include "base/command_line.h"
#include "base/message_loop.h"
#include "base/path_service.h"
#include "base/string_util.h"
+#include "content/browser/renderer_host/render_view_host.h"
#include "content/browser/tab_contents/navigation_controller_impl.h"
#include "content/browser/tab_contents/tab_contents.h"
+#include "content/public/browser/web_contents_observer.h"
+#include "content/shell/shell_messages.h"
+#include "content/shell/shell_switches.h"
#include "ui/gfx/size.h"
// Content area size for newly created windows.
@@ -17,6 +22,48 @@ static const int kTestWindowHeight = 600;
namespace content {
+namespace {
+
+class ShellObserver : public WebContentsObserver {
+ public:
+ explicit ShellObserver(WebContents* web_contents);
+ virtual ~ShellObserver();
+
+ private:
+ // WebContentsObserver overrides.
+ virtual void DidFinishLoad(int64 frame_id,
+ const GURL& validated_url,
+ bool is_main_frame) OVERRIDE;
+ virtual void WebContentsDestroyed(WebContents* web_contents) OVERRIDE;
+
+ DISALLOW_COPY_AND_ASSIGN(ShellObserver);
+};
+
+ShellObserver::ShellObserver(WebContents* web_contents)
+ : WebContentsObserver(web_contents) {
+}
+
+ShellObserver::~ShellObserver() {
+}
+
+void ShellObserver::DidFinishLoad(int64 frame_id,
jam 2012/01/27 18:22:30 nit: up to you, but if a class is declared and def
+ const GURL& validated_url,
+ bool is_main_frame) {
+ if (!is_main_frame)
+ return;
+ if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree))
+ return;
+ RenderViewHost* render_view_host = web_contents()->GetRenderViewHost();
+ render_view_host->Send(
+ new ShellViewMsg_CaptureTextDump(render_view_host->routing_id(), false));
+}
+
+void ShellObserver::WebContentsDestroyed(WebContents* web_contents) {
+ delete this;
+}
+
+} // namespace
+
std::vector<Shell*> Shell::windows_;
Shell::Shell()
@@ -64,6 +111,7 @@ Shell* Shell::CreateNewWindow(content::BrowserContext* browser_context,
routing_id,
base_tab_contents,
NULL);
+ new ShellObserver(tab_contents);
jam 2012/01/27 18:22:30 actually, do you need a new WebContentsObserver or
Shell* shell = CreateShell(tab_contents);
if (!url.is_empty())
shell->LoadURL(url);
« no previous file with comments | « content/content_shell.gypi ('k') | content/shell/shell_content_browser_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698