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

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

Issue 10534079: Add support for managing active state of platform apps (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removed redundant GetNativeWindow() decl in BrowserWindow Created 8 years, 6 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 | 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/shell_window_registry.h" 9 #include "chrome/browser/extensions/shell_window_registry.h"
10 #include "chrome/browser/file_select_helper.h" 10 #include "chrome/browser/file_select_helper.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 ShellWindow::CreateParams::CreateParams() 42 ShellWindow::CreateParams::CreateParams()
43 : frame(ShellWindow::CreateParams::FRAME_CHROME), 43 : frame(ShellWindow::CreateParams::FRAME_CHROME),
44 bounds(10, 10, kDefaultWidth, kDefaultHeight) { 44 bounds(10, 10, kDefaultWidth, kDefaultHeight) {
45 } 45 }
46 46
47 ShellWindow* ShellWindow::Create(Profile* profile, 47 ShellWindow* ShellWindow::Create(Profile* profile,
48 const extensions::Extension* extension, 48 const extensions::Extension* extension,
49 const GURL& url, 49 const GURL& url,
50 const ShellWindow::CreateParams params) { 50 const ShellWindow::CreateParams params) {
51 // This object will delete itself when the window is closed. 51 // This object will delete itself when the window is closed.
52 return ShellWindow::CreateImpl(profile, extension, url, params); 52 ShellWindow* window =
53 ShellWindow::CreateImpl(profile, extension, url, params);
54 ShellWindowRegistry::Get(profile)->AddShellWindow(window);
55 return window;
53 } 56 }
54 57
55 ShellWindow::ShellWindow(Profile* profile, 58 ShellWindow::ShellWindow(Profile* profile,
56 const extensions::Extension* extension, 59 const extensions::Extension* extension,
57 const GURL& url) 60 const GURL& url)
58 : profile_(profile), 61 : profile_(profile),
59 extension_(extension), 62 extension_(extension),
60 ALLOW_THIS_IN_INITIALIZER_LIST( 63 ALLOW_THIS_IN_INITIALIZER_LIST(
61 extension_function_dispatcher_(profile, this)) { 64 extension_function_dispatcher_(profile, this)) {
62 // TODO(jeremya) this should all be done in an Init() method, not in the 65 // TODO(jeremya) this should all be done in an Init() method, not in the
(...skipping 18 matching lines...) Expand all
81 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, 84 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED,
82 content::Source<Profile>(profile_)); 85 content::Source<Profile>(profile_));
83 // Close when the browser is exiting. 86 // Close when the browser is exiting.
84 // TODO(mihaip): we probably don't want this in the long run (when platform 87 // TODO(mihaip): we probably don't want this in the long run (when platform
85 // apps are no longer tied to the browser process). 88 // apps are no longer tied to the browser process).
86 registrar_.Add(this, content::NOTIFICATION_APP_TERMINATING, 89 registrar_.Add(this, content::NOTIFICATION_APP_TERMINATING,
87 content::NotificationService::AllSources()); 90 content::NotificationService::AllSources());
88 91
89 // Prevent the browser process from shutting down while this window is open. 92 // Prevent the browser process from shutting down while this window is open.
90 browser::StartKeepAlive(); 93 browser::StartKeepAlive();
91
92 ShellWindowRegistry::Get(profile_)->AddShellWindow(this);
93 } 94 }
94 95
95 ShellWindow::~ShellWindow() { 96 ShellWindow::~ShellWindow() {
96 // Unregister now to prevent getting NOTIFICATION_APP_TERMINATING if we're the 97 // Unregister now to prevent getting NOTIFICATION_APP_TERMINATING if we're the
97 // last window open. 98 // last window open.
98 registrar_.RemoveAll(); 99 registrar_.RemoveAll();
99 100
100 ShellWindowRegistry::Get(profile_)->RemoveShellWindow(this);
101
102 // Remove shutdown prevention. 101 // Remove shutdown prevention.
103 browser::EndKeepAlive(); 102 browser::EndKeepAlive();
104 } 103 }
105 104
106 bool ShellWindow::IsFullscreenOrPending() const { 105 bool ShellWindow::IsFullscreenOrPending() const {
107 return false; 106 return false;
108 } 107 }
109 108
109 void ShellWindow::OnNativeClose() {
Mihai Parparita -not on Chrome 2012/06/13 20:10:13 Not sure I understand the rationale behind adding
DaveMoore 2012/06/13 20:20:28 The reason is that if you call RemoveShellWindow f
110 ShellWindowRegistry::Get(profile_)->RemoveShellWindow(this);
111 delete this;
112 }
113
110 string16 ShellWindow::GetTitle() const { 114 string16 ShellWindow::GetTitle() const {
111 // WebContents::GetTitle() will return the page's URL if there's no <title> 115 // WebContents::GetTitle() will return the page's URL if there's no <title>
112 // specified. However, we'd prefer to show the name of the extension in that 116 // specified. However, we'd prefer to show the name of the extension in that
113 // case, so we directly inspect the NavigationEntry's title. 117 // case, so we directly inspect the NavigationEntry's title.
114 if (web_contents()->GetController().GetActiveEntry()->GetTitle().empty()) 118 if (!web_contents()->GetController().GetActiveEntry() ||
119 web_contents()->GetController().GetActiveEntry()->GetTitle().empty())
115 return UTF8ToUTF16(extension()->name()); 120 return UTF8ToUTF16(extension()->name());
116 return web_contents()->GetTitle(); 121 return web_contents()->GetTitle();
117 } 122 }
118 123
119 bool ShellWindow::OnMessageReceived(const IPC::Message& message) { 124 bool ShellWindow::OnMessageReceived(const IPC::Message& message) {
120 bool handled = true; 125 bool handled = true;
121 IPC_BEGIN_MESSAGE_MAP(ShellWindow, message) 126 IPC_BEGIN_MESSAGE_MAP(ShellWindow, message)
122 IPC_MESSAGE_HANDLER(ExtensionHostMsg_Request, OnRequest) 127 IPC_MESSAGE_HANDLER(ExtensionHostMsg_Request, OnRequest)
123 IPC_MESSAGE_UNHANDLED(handled = false) 128 IPC_MESSAGE_UNHANDLED(handled = false)
124 IPC_END_MESSAGE_MAP() 129 IPC_END_MESSAGE_MAP()
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 } 206 }
202 207
203 ExtensionWindowController* ShellWindow::GetExtensionWindowController() const { 208 ExtensionWindowController* ShellWindow::GetExtensionWindowController() const {
204 return NULL; 209 return NULL;
205 } 210 }
206 211
207 void ShellWindow::OnRequest(const ExtensionHostMsg_Request_Params& params) { 212 void ShellWindow::OnRequest(const ExtensionHostMsg_Request_Params& params) {
208 extension_function_dispatcher_.Dispatch(params, 213 extension_function_dispatcher_.Dispatch(params,
209 web_contents_->GetRenderViewHost()); 214 web_contents_->GetRenderViewHost());
210 } 215 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/extensions/shell_window.h ('k') | chrome/browser/ui/gtk/extensions/shell_window_gtk.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698