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

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

Issue 11363250: Allow Chrome apps to create Ash Panels (apps v2) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Multi-icon support Created 8 years, 1 month 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
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/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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 DCHECK(rvh); 66 DCHECK(rvh);
67 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, 67 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
68 base::Bind(&ResourceDispatcherHost::BlockRequestsForRoute, 68 base::Bind(&ResourceDispatcherHost::BlockRequestsForRoute,
69 base::Unretained(ResourceDispatcherHost::Get()), 69 base::Unretained(ResourceDispatcherHost::Get()),
70 rvh->GetProcess()->GetID(), rvh->GetRoutingID())); 70 rvh->GetProcess()->GetID(), rvh->GetRoutingID()));
71 } 71 }
72 72
73 } // namespace 73 } // namespace
74 74
75 ShellWindow::CreateParams::CreateParams() 75 ShellWindow::CreateParams::CreateParams()
76 : frame(ShellWindow::CreateParams::FRAME_CHROME), 76 : window_type(ShellWindow::WINDOW_TYPE_DEFAULT),
77 frame(ShellWindow::FRAME_CHROME),
77 bounds(INT_MIN, INT_MIN, INT_MIN, INT_MIN), 78 bounds(INT_MIN, INT_MIN, INT_MIN, INT_MIN),
78 creator_process_id(0), hidden(false) { 79 creator_process_id(0), hidden(false) {
79 } 80 }
80 81
81 ShellWindow::CreateParams::~CreateParams() { 82 ShellWindow::CreateParams::~CreateParams() {
82 } 83 }
83 84
84 ShellWindow* ShellWindow::Create(Profile* profile, 85 ShellWindow* ShellWindow::Create(Profile* profile,
85 const extensions::Extension* extension, 86 const extensions::Extension* extension,
86 const GURL& url, 87 const GURL& url,
87 const ShellWindow::CreateParams& params) { 88 const CreateParams& params) {
88 // This object will delete itself when the window is closed. 89 // This object will delete itself when the window is closed.
89 ShellWindow* window = new ShellWindow(profile, extension); 90 ShellWindow* window = new ShellWindow(params.window_type, profile, extension);
90 window->Init(url, params); 91 window->Init(url, params);
91 extensions::ShellWindowRegistry::Get(profile)->AddShellWindow(window); 92 extensions::ShellWindowRegistry::Get(profile)->AddShellWindow(window);
92 return window; 93 return window;
93 } 94 }
94 95
95 ShellWindow::ShellWindow(Profile* profile, 96 ShellWindow::ShellWindow(WindowType window_type,
97 Profile* profile,
96 const extensions::Extension* extension) 98 const extensions::Extension* extension)
97 : profile_(profile), 99 : profile_(profile),
98 extension_(extension), 100 extension_(extension),
99 web_contents_(NULL), 101 web_contents_(NULL),
102 window_type_(window_type),
100 ALLOW_THIS_IN_INITIALIZER_LIST( 103 ALLOW_THIS_IN_INITIALIZER_LIST(
101 extension_function_dispatcher_(profile, this)) { 104 extension_function_dispatcher_(profile, this)) {
102 } 105 }
103 106
104 void ShellWindow::Init(const GURL& url, 107 void ShellWindow::Init(const GURL& url,
105 const ShellWindow::CreateParams& params) { 108 const ShellWindow::CreateParams& params) {
106 web_contents_.reset(WebContents::Create( 109 web_contents_.reset(WebContents::Create(
107 profile(), SiteInstance::CreateForURL(profile(), url), MSG_ROUTING_NONE, 110 profile(), SiteInstance::CreateForURL(profile(), url), MSG_ROUTING_NONE,
108 NULL)); 111 NULL));
109 ConstrainedWindowTabHelper::CreateForWebContents(web_contents_.get()); 112 ConstrainedWindowTabHelper::CreateForWebContents(web_contents_.get());
(...skipping 28 matching lines...) Expand all
138 &cached_bounds)) 141 &cached_bounds))
139 bounds = cached_bounds; 142 bounds = cached_bounds;
140 } 143 }
141 144
142 ShellWindow::CreateParams new_params = params; 145 ShellWindow::CreateParams new_params = params;
143 new_params.bounds = bounds; 146 new_params.bounds = bounds;
144 147
145 native_window_.reset(NativeShellWindow::Create(this, new_params)); 148 native_window_.reset(NativeShellWindow::Create(this, new_params));
146 SaveWindowPosition(); 149 SaveWindowPosition();
147 150
148 if (!params.hidden) 151 if (!params.hidden) {
149 GetBaseWindow()->Show(); 152 if (params.window_type == WINDOW_TYPE_PANEL)
153 GetBaseWindow()->ShowInactive(); // Panels are not activated by default.
154 else
155 GetBaseWindow()->Show();
156 }
150 157
151 // If the new view is in the same process as the creator, block the created 158 // If the new view is in the same process as the creator, block the created
152 // RVH from loading anything until the background page has had a chance to do 159 // RVH from loading anything until the background page has had a chance to do
153 // any initialization it wants. If it's a different process, the new RVH 160 // any initialization it wants. If it's a different process, the new RVH
154 // shouldn't communicate with the background page anyway (e.g. sandboxed). 161 // shouldn't communicate with the background page anyway (e.g. sandboxed).
155 if (web_contents_->GetRenderViewHost()->GetProcess()->GetID() == 162 if (web_contents_->GetRenderViewHost()->GetProcess()->GetID() ==
156 params.creator_process_id) { 163 params.creator_process_id) {
157 SuspendRenderViewHost(web_contents_->GetRenderViewHost()); 164 SuspendRenderViewHost(web_contents_->GetRenderViewHost());
158 } else { 165 } else {
159 VLOG(1) << "ShellWindow created in new process (" 166 VLOG(1) << "ShellWindow created in new process ("
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 } 295 }
289 296
290 BaseWindow* ShellWindow::GetBaseWindow() { 297 BaseWindow* ShellWindow::GetBaseWindow() {
291 return native_window_.get(); 298 return native_window_.get();
292 } 299 }
293 300
294 string16 ShellWindow::GetTitle() const { 301 string16 ShellWindow::GetTitle() const {
295 // WebContents::GetTitle() will return the page's URL if there's no <title> 302 // WebContents::GetTitle() will return the page's URL if there's no <title>
296 // specified. However, we'd prefer to show the name of the extension in that 303 // specified. However, we'd prefer to show the name of the extension in that
297 // case, so we directly inspect the NavigationEntry's title. 304 // case, so we directly inspect the NavigationEntry's title.
298 if (!web_contents()->GetController().GetActiveEntry() || 305 if (!web_contents() ||
306 !web_contents()->GetController().GetActiveEntry() ||
299 web_contents()->GetController().GetActiveEntry()->GetTitle().empty()) 307 web_contents()->GetController().GetActiveEntry()->GetTitle().empty())
300 return UTF8ToUTF16(extension()->name()); 308 return UTF8ToUTF16(extension()->name());
301 string16 title = web_contents()->GetTitle(); 309 string16 title = web_contents()->GetTitle();
302 Browser::FormatTitleForDisplay(&title); 310 Browser::FormatTitleForDisplay(&title);
303 return title; 311 return title;
304 } 312 }
305 313
306 bool ShellWindow::OnMessageReceived(const IPC::Message& message) { 314 bool ShellWindow::OnMessageReceived(const IPC::Message& message) {
307 bool handled = true; 315 bool handled = true;
308 IPC_BEGIN_MESSAGE_MAP(ShellWindow, message) 316 IPC_BEGIN_MESSAGE_MAP(ShellWindow, message)
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 const extensions::DraggableRegion& region = *iter; 513 const extensions::DraggableRegion& region = *iter;
506 sk_region->op( 514 sk_region->op(
507 region.bounds.x(), 515 region.bounds.x(),
508 region.bounds.y(), 516 region.bounds.y(),
509 region.bounds.right(), 517 region.bounds.right(),
510 region.bounds.bottom(), 518 region.bounds.bottom(),
511 region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op); 519 region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op);
512 } 520 }
513 return sk_region; 521 return sk_region;
514 } 522 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698