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

Side by Side Diff: chrome/browser/ui/extensions/shell_window.cc

Issue 11048045: Allow settings dialog to be opened via the app launcher, as a packaged app. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: license stanza Created 8 years, 2 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
« no previous file with comments | « chrome/browser/ui/extensions/shell_window.h ('k') | chrome/common/chrome_switches.h » ('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 "chrome/browser/ui/extensions/shell_window.h" 5 #include "chrome/browser/ui/extensions/shell_window.h"
6 6
7 #include "base/memory/singleton.h" 7 #include "base/memory/singleton.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/extensions/extension_process_manager.h" 9 #include "chrome/browser/extensions/extension_process_manager.h"
10 #include "chrome/browser/extensions/extension_system.h" 10 #include "chrome/browser/extensions/extension_system.h"
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 FROM_HERE, 109 FROM_HERE,
110 base::Bind(&platform_util::OpenExternal, params.url)); 110 base::Bind(&platform_util::OpenExternal, params.url));
111 #endif 111 #endif
112 112
113 return NULL; 113 return NULL;
114 } 114 }
115 115
116 ShellWindow::CreateParams::CreateParams() 116 ShellWindow::CreateParams::CreateParams()
117 : frame(ShellWindow::CreateParams::FRAME_CHROME), 117 : frame(ShellWindow::CreateParams::FRAME_CHROME),
118 bounds(-1, -1, kDefaultWidth, kDefaultHeight), 118 bounds(-1, -1, kDefaultWidth, kDefaultHeight),
119 restore_position(true), restore_size(true) { 119 restore_position(true), restore_size(true),
120 creator_process_id(0) {
120 } 121 }
121 122
122 ShellWindow::CreateParams::~CreateParams() { 123 ShellWindow::CreateParams::~CreateParams() {
123 } 124 }
124 125
125 ShellWindow* ShellWindow::Create(Profile* profile, 126 ShellWindow* ShellWindow::Create(Profile* profile,
126 const extensions::Extension* extension, 127 const extensions::Extension* extension,
127 const GURL& url, 128 const GURL& url,
128 const ShellWindow::CreateParams& params) { 129 const ShellWindow::CreateParams& params) {
129 // This object will delete itself when the window is closed. 130 // This object will delete itself when the window is closed.
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 if (params.restore_position) 173 if (params.restore_position)
173 bounds.set_origin(cached_bounds.origin()); 174 bounds.set_origin(cached_bounds.origin());
174 if (params.restore_size) 175 if (params.restore_size)
175 bounds.set_size(cached_bounds.size()); 176 bounds.set_size(cached_bounds.size());
176 177
177 native_window_->SetBounds(bounds); 178 native_window_->SetBounds(bounds);
178 } 179 }
179 } 180 }
180 } 181 }
181 182
182 183 // If the new view is in the same process as the creator, block the created
183 // Block the created RVH from loading anything until the background page 184 // RVH from loading anything until the background page has had a chance to do
184 // has had a chance to do any initialization it wants. 185 // any initialization it wants. If it's a different process, the new RVH
185 SuspendRenderViewHost(web_contents_->GetRenderViewHost()); 186 // shouldn't communicate with the background page anyway (e.g. sandboxed).
187 if (web_contents_->GetRenderViewHost()->GetProcess()->GetID() ==
188 params.creator_process_id) {
189 SuspendRenderViewHost(web_contents_->GetRenderViewHost());
190 } else {
191 VLOG(1) << "ShellWindow created in new process ("
192 << web_contents_->GetRenderViewHost()->GetProcess()->GetID()
193 << ") != creator (" << params.creator_process_id
194 << "). Routing disabled.";
195 }
186 196
187 // TODO(jeremya): there's a bug where navigating a web contents to an 197 // TODO(jeremya): there's a bug where navigating a web contents to an
188 // extension URL causes it to create a new RVH and discard the old (perfectly 198 // extension URL causes it to create a new RVH and discard the old (perfectly
189 // usable) one. To work around this, we watch for a RVH_CHANGED message from 199 // usable) one. To work around this, we watch for a RVH_CHANGED message from
190 // the web contents (which will be sent during LoadURL) and suspend resource 200 // the web contents (which will be sent during LoadURL) and suspend resource
191 // requests on the new RVH to ensure that we block the new RVH from loading 201 // requests on the new RVH to ensure that we block the new RVH from loading
192 // anything. It should be okay to remove the NOTIFICATION_RVH_CHANGED 202 // anything. It should be okay to remove the NOTIFICATION_RVH_CHANGED
193 // registration once http://crbug.com/123007 is fixed. 203 // registration once http://crbug.com/123007 is fixed.
194 registrar_.Add(this, content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED, 204 registrar_.Add(this, content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED,
195 content::Source<content::NavigationController>( 205 content::Source<content::NavigationController>(
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 shell_window_geometry_cache(); 543 shell_window_geometry_cache();
534 544
535 gfx::Rect bounds = native_window_->GetBounds(); 545 gfx::Rect bounds = native_window_->GetBounds();
536 cache->SaveGeometry(extension()->id(), window_key_, bounds); 546 cache->SaveGeometry(extension()->id(), window_key_, bounds);
537 } 547 }
538 548
539 void ShellWindow::SetExternalUrlControllerForTesting( 549 void ShellWindow::SetExternalUrlControllerForTesting(
540 content::WebContentsDelegate* controller) { 550 content::WebContentsDelegate* controller) {
541 url_controller_for_test_ = controller; 551 url_controller_for_test_ = controller;
542 } 552 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/extensions/shell_window.h ('k') | chrome/common/chrome_switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698