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

Unified 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: Fix PanelLayoutManager 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/extensions/shell_window.cc
diff --git a/chrome/browser/ui/extensions/shell_window.cc b/chrome/browser/ui/extensions/shell_window.cc
index 46e709f5dbe6304691a37f31920e8cd4107b8eba..ff7ef767f39d4ede08c226136eb7fd0f79ef2e8a 100644
--- a/chrome/browser/ui/extensions/shell_window.cc
+++ b/chrome/browser/ui/extensions/shell_window.cc
@@ -50,6 +50,10 @@
namespace app_window = extensions::api::app_window;
+#if defined(USE_ASH)
+#include "chrome/browser/ui/ash/shell_utility_window_ash.h"
+#endif
+
using content::BrowserThread;
using content::ConsoleMessageLevel;
using content::RenderViewHost;
@@ -74,7 +78,8 @@ void SuspendRenderViewHost(RenderViewHost* rvh) {
} // namespace
ShellWindow::CreateParams::CreateParams()
- : frame(ShellWindow::CreateParams::FRAME_CHROME),
+ : window_type(ShellWindow::WINDOW_TYPE_DEFAULT),
+ frame(ShellWindow::FRAME_CHROME),
bounds(INT_MIN, INT_MIN, INT_MIN, INT_MIN),
creator_process_id(0), hidden(false) {
}
@@ -85,19 +90,21 @@ ShellWindow::CreateParams::~CreateParams() {
ShellWindow* ShellWindow::Create(Profile* profile,
const extensions::Extension* extension,
const GURL& url,
- const ShellWindow::CreateParams& params) {
+ const CreateParams& params) {
// This object will delete itself when the window is closed.
- ShellWindow* window = new ShellWindow(profile, extension);
+ ShellWindow* window = new ShellWindow(params.window_type, profile, extension);
window->Init(url, params);
extensions::ShellWindowRegistry::Get(profile)->AddShellWindow(window);
return window;
}
-ShellWindow::ShellWindow(Profile* profile,
+ShellWindow::ShellWindow(WindowType window_type,
+ Profile* profile,
const extensions::Extension* extension)
: profile_(profile),
extension_(extension),
web_contents_(NULL),
+ window_type_(window_type),
ALLOW_THIS_IN_INITIALIZER_LIST(
extension_function_dispatcher_(profile, this)) {
}
@@ -144,11 +151,22 @@ void ShellWindow::Init(const GURL& url,
ShellWindow::CreateParams new_params = params;
new_params.bounds = bounds;
- native_window_.reset(NativeShellWindow::Create(this, new_params));
+ DCHECK(!native_window_.get());
+#if defined(USE_ASH)
+ if (params.window_type == WINDOW_TYPE_PANEL)
+ native_window_.reset(new ShellUtilityWindowAsh(this, params));
+#endif
+ if (!native_window_.get())
+ native_window_.reset(NativeShellWindow::Create(this, new_params));
+
SaveWindowPosition();
- if (!params.hidden)
- GetBaseWindow()->Show();
+ if (!params.hidden) {
+ if (params.window_type == WINDOW_TYPE_PANEL)
jeremya 2012/11/19 00:04:24 #if defined(USE_ASH) here too. Perhaps on non-ash
stevenjb 2012/11/19 21:38:44 This logic is actually valid on any platform; pane
+ GetBaseWindow()->ShowInactive(); // Panels are not activated by default.
+ else
+ GetBaseWindow()->Show();
+ }
// If the new view is in the same process as the creator, block the created
// RVH from loading anything until the background page has had a chance to do
@@ -297,7 +315,8 @@ string16 ShellWindow::GetTitle() const {
// WebContents::GetTitle() will return the page's URL if there's no <title>
// specified. However, we'd prefer to show the name of the extension in that
// case, so we directly inspect the NavigationEntry's title.
- if (!web_contents()->GetController().GetActiveEntry() ||
+ if (!web_contents() ||
+ !web_contents()->GetController().GetActiveEntry() ||
web_contents()->GetController().GetActiveEntry()->GetTitle().empty())
return UTF8ToUTF16(extension()->name());
string16 title = web_contents()->GetTitle();

Powered by Google App Engine
This is Rietveld 408576698