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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/content_shell.gypi ('k') | content/shell/shell_content_browser_client.cc » ('j') | 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 "content/shell/shell.h" 5 #include "content/shell/shell.h"
6 6
7 #include "base/command_line.h"
7 #include "base/message_loop.h" 8 #include "base/message_loop.h"
8 #include "base/path_service.h" 9 #include "base/path_service.h"
9 #include "base/string_util.h" 10 #include "base/string_util.h"
11 #include "content/browser/renderer_host/render_view_host.h"
10 #include "content/browser/tab_contents/navigation_controller_impl.h" 12 #include "content/browser/tab_contents/navigation_controller_impl.h"
11 #include "content/browser/tab_contents/tab_contents.h" 13 #include "content/browser/tab_contents/tab_contents.h"
14 #include "content/public/browser/web_contents_observer.h"
15 #include "content/shell/shell_messages.h"
16 #include "content/shell/shell_switches.h"
12 #include "ui/gfx/size.h" 17 #include "ui/gfx/size.h"
13 18
14 // Content area size for newly created windows. 19 // Content area size for newly created windows.
15 static const int kTestWindowWidth = 800; 20 static const int kTestWindowWidth = 800;
16 static const int kTestWindowHeight = 600; 21 static const int kTestWindowHeight = 600;
17 22
18 namespace content { 23 namespace content {
19 24
25 namespace {
26
27 class ShellObserver : public WebContentsObserver {
28 public:
29 explicit ShellObserver(WebContents* web_contents);
30 virtual ~ShellObserver();
31
32 private:
33 // WebContentsObserver overrides.
34 virtual void DidFinishLoad(int64 frame_id,
35 const GURL& validated_url,
36 bool is_main_frame) OVERRIDE;
37 virtual void WebContentsDestroyed(WebContents* web_contents) OVERRIDE;
38
39 DISALLOW_COPY_AND_ASSIGN(ShellObserver);
40 };
41
42 ShellObserver::ShellObserver(WebContents* web_contents)
43 : WebContentsObserver(web_contents) {
44 }
45
46 ShellObserver::~ShellObserver() {
47 }
48
49 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
50 const GURL& validated_url,
51 bool is_main_frame) {
52 if (!is_main_frame)
53 return;
54 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree))
55 return;
56 RenderViewHost* render_view_host = web_contents()->GetRenderViewHost();
57 render_view_host->Send(
58 new ShellViewMsg_CaptureTextDump(render_view_host->routing_id(), false));
59 }
60
61 void ShellObserver::WebContentsDestroyed(WebContents* web_contents) {
62 delete this;
63 }
64
65 } // namespace
66
20 std::vector<Shell*> Shell::windows_; 67 std::vector<Shell*> Shell::windows_;
21 68
22 Shell::Shell() 69 Shell::Shell()
23 : window_(NULL), 70 : window_(NULL),
24 url_edit_view_(NULL) 71 url_edit_view_(NULL)
25 #if defined(OS_WIN) 72 #if defined(OS_WIN)
26 , default_edit_wnd_proc_(0) 73 , default_edit_wnd_proc_(0)
27 #endif 74 #endif
28 { 75 {
29 windows_.push_back(this); 76 windows_.push_back(this);
(...skipping 27 matching lines...) Expand all
57 const GURL& url, 104 const GURL& url,
58 SiteInstance* site_instance, 105 SiteInstance* site_instance,
59 int routing_id, 106 int routing_id,
60 TabContents* base_tab_contents) { 107 TabContents* base_tab_contents) {
61 TabContents* tab_contents = new TabContents( 108 TabContents* tab_contents = new TabContents(
62 browser_context, 109 browser_context,
63 site_instance, 110 site_instance,
64 routing_id, 111 routing_id,
65 base_tab_contents, 112 base_tab_contents,
66 NULL); 113 NULL);
114 new ShellObserver(tab_contents);
jam 2012/01/27 18:22:30 actually, do you need a new WebContentsObserver or
67 Shell* shell = CreateShell(tab_contents); 115 Shell* shell = CreateShell(tab_contents);
68 if (!url.is_empty()) 116 if (!url.is_empty())
69 shell->LoadURL(url); 117 shell->LoadURL(url);
70 return shell; 118 return shell;
71 } 119 }
72 120
73 void Shell::LoadURL(const GURL& url) { 121 void Shell::LoadURL(const GURL& url) {
74 tab_contents_->GetController().LoadURL( 122 tab_contents_->GetController().LoadURL(
75 url, 123 url,
76 content::Referrer(), 124 content::Referrer(),
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 void Shell::DidNavigateMainFramePostCommit(WebContents* tab) { 172 void Shell::DidNavigateMainFramePostCommit(WebContents* tab) {
125 PlatformSetAddressBarURL(tab->GetURL()); 173 PlatformSetAddressBarURL(tab->GetURL());
126 } 174 }
127 175
128 void Shell::UpdatePreferredSize(WebContents* source, 176 void Shell::UpdatePreferredSize(WebContents* source,
129 const gfx::Size& pref_size) { 177 const gfx::Size& pref_size) {
130 PlatformSizeTo(pref_size.width(), pref_size.height()); 178 PlatformSizeTo(pref_size.width(), pref_size.height());
131 } 179 }
132 180
133 } // namespace content 181 } // namespace content
OLDNEW
« 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