OLD | NEW |
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/shell/shell_messages.h" |
| 15 #include "content/shell/shell_switches.h" |
12 #include "ui/gfx/size.h" | 16 #include "ui/gfx/size.h" |
13 | 17 |
14 // Content area size for newly created windows. | 18 // Content area size for newly created windows. |
15 static const int kTestWindowWidth = 800; | 19 static const int kTestWindowWidth = 800; |
16 static const int kTestWindowHeight = 600; | 20 static const int kTestWindowHeight = 600; |
17 | 21 |
18 namespace content { | 22 namespace content { |
19 | 23 |
20 std::vector<Shell*> Shell::windows_; | 24 std::vector<Shell*> Shell::windows_; |
21 | 25 |
22 Shell::Shell() | 26 Shell::Shell(TabContents* tab_contents) |
23 : window_(NULL), | 27 : WebContentsObserver(tab_contents), |
| 28 window_(NULL), |
24 url_edit_view_(NULL) | 29 url_edit_view_(NULL) |
25 #if defined(OS_WIN) | 30 #if defined(OS_WIN) |
26 , default_edit_wnd_proc_(0) | 31 , default_edit_wnd_proc_(0) |
27 #endif | 32 #endif |
28 { | 33 { |
29 windows_.push_back(this); | 34 windows_.push_back(this); |
30 } | 35 } |
31 | 36 |
32 Shell::~Shell() { | 37 Shell::~Shell() { |
33 PlatformCleanUp(); | 38 PlatformCleanUp(); |
34 | 39 |
35 for (size_t i = 0; i < windows_.size(); ++i) { | 40 for (size_t i = 0; i < windows_.size(); ++i) { |
36 if (windows_[i] == this) { | 41 if (windows_[i] == this) { |
37 windows_.erase(windows_.begin() + i); | 42 windows_.erase(windows_.begin() + i); |
38 break; | 43 break; |
39 } | 44 } |
40 } | 45 } |
41 } | 46 } |
42 | 47 |
43 Shell* Shell::CreateShell(TabContents* tab_contents) { | 48 Shell* Shell::CreateShell(TabContents* tab_contents) { |
44 Shell* shell = new Shell(); | 49 Shell* shell = new Shell(tab_contents); |
45 shell->PlatformCreateWindow(kTestWindowWidth, kTestWindowHeight); | 50 shell->PlatformCreateWindow(kTestWindowWidth, kTestWindowHeight); |
46 | 51 |
47 shell->tab_contents_.reset(tab_contents); | 52 shell->tab_contents_.reset(tab_contents); |
48 tab_contents->SetDelegate(shell); | 53 tab_contents->SetDelegate(shell); |
49 | 54 |
50 shell->PlatformSetContents(); | 55 shell->PlatformSetContents(); |
51 | 56 |
52 shell->PlatformResizeSubViews(); | 57 shell->PlatformResizeSubViews(); |
53 return shell; | 58 return shell; |
54 } | 59 } |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 | 128 |
124 void Shell::DidNavigateMainFramePostCommit(WebContents* tab) { | 129 void Shell::DidNavigateMainFramePostCommit(WebContents* tab) { |
125 PlatformSetAddressBarURL(tab->GetURL()); | 130 PlatformSetAddressBarURL(tab->GetURL()); |
126 } | 131 } |
127 | 132 |
128 void Shell::UpdatePreferredSize(WebContents* source, | 133 void Shell::UpdatePreferredSize(WebContents* source, |
129 const gfx::Size& pref_size) { | 134 const gfx::Size& pref_size) { |
130 PlatformSizeTo(pref_size.width(), pref_size.height()); | 135 PlatformSizeTo(pref_size.width(), pref_size.height()); |
131 } | 136 } |
132 | 137 |
| 138 void Shell::DidFinishLoad(int64 frame_id, |
| 139 const GURL& validated_url, |
| 140 bool is_main_frame) { |
| 141 if (!is_main_frame) |
| 142 return; |
| 143 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) |
| 144 return; |
| 145 RenderViewHost* render_view_host = tab_contents_->GetRenderViewHost(); |
| 146 render_view_host->Send( |
| 147 new ShellViewMsg_CaptureTextDump(render_view_host->routing_id(), false)); |
| 148 } |
| 149 |
133 } // namespace content | 150 } // namespace content |
OLD | NEW |