Chromium Code Reviews| 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); |