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/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 #include "content/public/common/renderer_preferences.h" | 25 #include "content/public/common/renderer_preferences.h" |
26 #include "content/shell/common/shell_messages.h" | 26 #include "content/shell/common/shell_messages.h" |
27 #include "content/shell/common/shell_switches.h" | 27 #include "content/shell/common/shell_switches.h" |
28 #include "content/shell/notify_done_forwarder.h" | 28 #include "content/shell/notify_done_forwarder.h" |
29 #include "content/shell/shell_browser_main_parts.h" | 29 #include "content/shell/shell_browser_main_parts.h" |
30 #include "content/shell/shell_content_browser_client.h" | 30 #include "content/shell/shell_content_browser_client.h" |
31 #include "content/shell/shell_devtools_frontend.h" | 31 #include "content/shell/shell_devtools_frontend.h" |
32 #include "content/shell/shell_javascript_dialog_manager.h" | 32 #include "content/shell/shell_javascript_dialog_manager.h" |
33 #include "content/shell/webkit_test_controller.h" | 33 #include "content/shell/webkit_test_controller.h" |
34 | 34 |
35 // Content area size for newly created windows. | 35 namespace content { |
36 static const int kTestWindowWidth = 800; | |
37 static const int kTestWindowHeight = 600; | |
38 | 36 |
39 namespace content { | 37 const int Shell::kDefaultTestWindowWidthDip = 800; |
| 38 const int Shell::kDefaultTestWindowHeightDip = 600; |
40 | 39 |
41 std::vector<Shell*> Shell::windows_; | 40 std::vector<Shell*> Shell::windows_; |
42 base::Callback<void(Shell*)> Shell::shell_created_callback_; | 41 base::Callback<void(Shell*)> Shell::shell_created_callback_; |
43 | 42 |
44 bool Shell::quit_message_loop_ = true; | 43 bool Shell::quit_message_loop_ = true; |
45 | 44 |
46 class Shell::DevToolsWebContentsObserver : public WebContentsObserver { | 45 class Shell::DevToolsWebContentsObserver : public WebContentsObserver { |
47 public: | 46 public: |
48 DevToolsWebContentsObserver(Shell* shell, WebContents* web_contents) | 47 DevToolsWebContentsObserver(Shell* shell, WebContents* web_contents) |
49 : WebContentsObserver(web_contents), | 48 : WebContentsObserver(web_contents), |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 if (windows_[i]->web_contents() && | 139 if (windows_[i]->web_contents() && |
141 windows_[i]->web_contents()->GetRenderViewHost() == rvh) { | 140 windows_[i]->web_contents()->GetRenderViewHost() == rvh) { |
142 return windows_[i]; | 141 return windows_[i]; |
143 } | 142 } |
144 } | 143 } |
145 return NULL; | 144 return NULL; |
146 } | 145 } |
147 | 146 |
148 // static | 147 // static |
149 void Shell::Initialize() { | 148 void Shell::Initialize() { |
150 PlatformInitialize(gfx::Size(kTestWindowWidth, kTestWindowHeight)); | 149 PlatformInitialize( |
| 150 gfx::Size(kDefaultTestWindowWidthDip, kDefaultTestWindowHeightDip)); |
151 } | 151 } |
152 | 152 |
153 Shell* Shell::CreateNewWindow(BrowserContext* browser_context, | 153 Shell* Shell::CreateNewWindow(BrowserContext* browser_context, |
154 const GURL& url, | 154 const GURL& url, |
155 SiteInstance* site_instance, | 155 SiteInstance* site_instance, |
156 int routing_id, | 156 int routing_id, |
157 const gfx::Size& initial_size) { | 157 const gfx::Size& initial_size) { |
158 WebContents::CreateParams create_params(browser_context, site_instance); | 158 WebContents::CreateParams create_params(browser_context, site_instance); |
159 create_params.routing_id = routing_id; | 159 create_params.routing_id = routing_id; |
160 if (!initial_size.IsEmpty()) | 160 if (!initial_size.IsEmpty()) |
161 create_params.initial_size = initial_size; | 161 create_params.initial_size = initial_size; |
162 else | 162 else |
163 create_params.initial_size = gfx::Size(kTestWindowWidth, kTestWindowHeight); | 163 create_params.initial_size = |
| 164 gfx::Size(kDefaultTestWindowWidthDip, kDefaultTestWindowHeightDip); |
164 WebContents* web_contents = WebContents::Create(create_params); | 165 WebContents* web_contents = WebContents::Create(create_params); |
165 Shell* shell = CreateShell(web_contents, create_params.initial_size); | 166 Shell* shell = CreateShell(web_contents, create_params.initial_size); |
166 if (!url.is_empty()) | 167 if (!url.is_empty()) |
167 shell->LoadURL(url); | 168 shell->LoadURL(url); |
168 return shell; | 169 return shell; |
169 } | 170 } |
170 | 171 |
171 void Shell::LoadURL(const GURL& url) { | 172 void Shell::LoadURL(const GURL& url) { |
172 LoadURLForFrame(url, std::string()); | 173 LoadURLForFrame(url, std::string()); |
173 } | 174 } |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 NOTREACHED(); | 340 NOTREACHED(); |
340 } | 341 } |
341 } | 342 } |
342 | 343 |
343 void Shell::OnDevToolsWebContentsDestroyed() { | 344 void Shell::OnDevToolsWebContentsDestroyed() { |
344 devtools_observer_.reset(); | 345 devtools_observer_.reset(); |
345 devtools_frontend_ = NULL; | 346 devtools_frontend_ = NULL; |
346 } | 347 } |
347 | 348 |
348 } // namespace content | 349 } // namespace content |
OLD | NEW |