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 "chrome/browser/ui/extensions/shell_window.h" | 5 #include "chrome/browser/ui/extensions/shell_window.h" |
6 | 6 |
7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
8 #include "chrome/browser/extensions/extension_process_manager.h" | 8 #include "chrome/browser/extensions/extension_process_manager.h" |
9 #include "chrome/browser/extensions/extension_system.h" | 9 #include "chrome/browser/extensions/extension_system.h" |
10 #include "chrome/browser/extensions/shell_window_geometry_cache.h" | 10 #include "chrome/browser/extensions/shell_window_geometry_cache.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
61 base::Bind(&ResourceDispatcherHost::BlockRequestsForRoute, | 61 base::Bind(&ResourceDispatcherHost::BlockRequestsForRoute, |
62 base::Unretained(ResourceDispatcherHost::Get()), | 62 base::Unretained(ResourceDispatcherHost::Get()), |
63 rvh->GetProcess()->GetID(), rvh->GetRoutingID())); | 63 rvh->GetProcess()->GetID(), rvh->GetRoutingID())); |
64 } | 64 } |
65 | 65 |
66 } // namespace | 66 } // namespace |
67 | 67 |
68 ShellWindow::CreateParams::CreateParams() | 68 ShellWindow::CreateParams::CreateParams() |
69 : frame(ShellWindow::CreateParams::FRAME_CHROME), | 69 : frame(ShellWindow::CreateParams::FRAME_CHROME), |
70 bounds(-1, -1, kDefaultWidth, kDefaultHeight), | 70 bounds(-1, -1, kDefaultWidth, kDefaultHeight), |
71 restore_position(true), restore_size(true) { | 71 restore_position(true), restore_size(true), |
72 creator_process_id(0) { | |
72 } | 73 } |
73 | 74 |
74 ShellWindow::CreateParams::~CreateParams() { | 75 ShellWindow::CreateParams::~CreateParams() { |
75 } | 76 } |
76 | 77 |
77 ShellWindow* ShellWindow::Create(Profile* profile, | 78 ShellWindow* ShellWindow::Create(Profile* profile, |
78 const extensions::Extension* extension, | 79 const extensions::Extension* extension, |
79 const GURL& url, | 80 const GURL& url, |
80 const ShellWindow::CreateParams& params) { | 81 const ShellWindow::CreateParams& params) { |
81 // This object will delete itself when the window is closed. | 82 // This object will delete itself when the window is closed. |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
124 if (params.restore_position) | 125 if (params.restore_position) |
125 bounds.set_origin(cached_bounds.origin()); | 126 bounds.set_origin(cached_bounds.origin()); |
126 if (params.restore_size) | 127 if (params.restore_size) |
127 bounds.set_size(cached_bounds.size()); | 128 bounds.set_size(cached_bounds.size()); |
128 | 129 |
129 native_window_->SetBounds(bounds); | 130 native_window_->SetBounds(bounds); |
130 } | 131 } |
131 } | 132 } |
132 } | 133 } |
133 | 134 |
134 | 135 // If the new view is in the same process as the creator, block the created |
135 // Block the created RVH from loading anything until the background page | 136 // RVH from loading anything until the background page has had a chance to do |
136 // has had a chance to do any initialization it wants. | 137 // any initialization it wants. If it's a different process, the new RVH |
137 SuspendRenderViewHost(web_contents_->GetRenderViewHost()); | 138 // shouldn't communicate with the background page anyway (e.g. sandboxed). |
139 if (web_contents_->GetRenderViewHost()->GetProcess()->GetID() | |
140 == params.creator_process_id) { | |
sky
2012/10/12 16:30:21
== on previous line.
tapted
2012/10/15 02:32:39
Done.
| |
141 SuspendRenderViewHost(web_contents_->GetRenderViewHost()); | |
142 } else { | |
143 DLOG(INFO) << "ShellWindow created in new process (" | |
sky
2012/10/12 16:30:21
VLOG
tapted
2012/10/15 02:32:39
Done.
| |
144 << web_contents_->GetRenderViewHost()->GetProcess()->GetID() | |
145 << ") != creator (" << params.creator_process_id | |
146 << "). Routing disabled."; | |
147 } | |
138 | 148 |
139 // TODO(jeremya): there's a bug where navigating a web contents to an | 149 // TODO(jeremya): there's a bug where navigating a web contents to an |
140 // extension URL causes it to create a new RVH and discard the old (perfectly | 150 // extension URL causes it to create a new RVH and discard the old (perfectly |
141 // usable) one. To work around this, we watch for a RVH_CHANGED message from | 151 // usable) one. To work around this, we watch for a RVH_CHANGED message from |
142 // the web contents (which will be sent during LoadURL) and suspend resource | 152 // the web contents (which will be sent during LoadURL) and suspend resource |
143 // requests on the new RVH to ensure that we block the new RVH from loading | 153 // requests on the new RVH to ensure that we block the new RVH from loading |
144 // anything. It should be okay to remove the NOTIFICATION_RVH_CHANGED | 154 // anything. It should be okay to remove the NOTIFICATION_RVH_CHANGED |
145 // registration once http://crbug.com/123007 is fixed. | 155 // registration once http://crbug.com/123007 is fixed. |
146 registrar_.Add(this, content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED, | 156 registrar_.Add(this, content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED, |
147 content::Source<content::NavigationController>( | 157 content::Source<content::NavigationController>( |
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
472 if (window_key_.empty()) | 482 if (window_key_.empty()) |
473 return; | 483 return; |
474 | 484 |
475 extensions::ShellWindowGeometryCache* cache = | 485 extensions::ShellWindowGeometryCache* cache = |
476 extensions::ExtensionSystem::Get(profile())-> | 486 extensions::ExtensionSystem::Get(profile())-> |
477 shell_window_geometry_cache(); | 487 shell_window_geometry_cache(); |
478 | 488 |
479 gfx::Rect bounds = native_window_->GetBounds(); | 489 gfx::Rect bounds = native_window_->GetBounds(); |
480 cache->SaveGeometry(extension()->id(), window_key_, bounds); | 490 cache->SaveGeometry(extension()->id(), window_key_, bounds); |
481 } | 491 } |
OLD | NEW |