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

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

Issue 9030017: Implement ShellWindow in Views. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 11 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/browser/extensions/extension_process_manager.h" 7 #include "chrome/browser/extensions/extension_process_manager.h"
8 #include "chrome/browser/profiles/profile.h" 8 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/common/chrome_notification_types.h" 9 #include "chrome/common/chrome_notification_types.h"
10 #include "content/public/browser/notification_details.h" 10 #include "content/public/browser/notification_details.h"
11 #include "content/public/browser/notification_source.h" 11 #include "content/public/browser/notification_source.h"
12 12
13 #if defined(TOOLKIT_USES_GTK) 13 #if defined(TOOLKIT_USES_GTK)
14 #include "chrome/browser/ui/gtk/extensions/shell_window_gtk.h" 14 #include "chrome/browser/ui/gtk/extensions/shell_window_gtk.h"
15 #elif defined(TOOLKIT_VIEWS)
16 #include "chrome/browser/ui/views/extensions/shell_window_views.h"
15 #endif 17 #endif
16 18
17 ShellWindow::ShellWindow(ExtensionHost* host) 19 ShellWindow::ShellWindow(ExtensionHost* host)
18 : host_(host) { 20 : host_(host) {
19 // Close the window in response to window.close() and the like. 21 // Close the window in response to window.close() and the like.
20 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE, 22 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE,
21 content::Source<Profile>(host->profile())); 23 content::Source<Profile>(host->profile()));
22 } 24 }
23 25
24 ShellWindow::~ShellWindow() { 26 ShellWindow::~ShellWindow() {
25 } 27 }
26 28
27 ShellWindow* ShellWindow::Create(Profile* profile, 29 ShellWindow* ShellWindow::Create(Profile* profile,
28 const Extension* extension, 30 const Extension* extension,
29 const GURL& url) { 31 const GURL& url) {
30 ExtensionProcessManager* manager = profile->GetExtensionProcessManager(); 32 ExtensionProcessManager* manager = profile->GetExtensionProcessManager();
31 DCHECK(manager); 33 DCHECK(manager);
32 if (!manager) 34 if (!manager)
33 return NULL; 35 return NULL;
34 36
35 ExtensionHost* host = manager->CreateShellHost(extension, url); 37 ExtensionHost* host = manager->CreateShellHost(extension, url);
36 38
37 #if defined(TOOLKIT_USES_GTK) 39 #if defined(TOOLKIT_USES_GTK)
38 // This object will delete itself when the window is closed. 40 // This object will delete itself when the window is closed.
39 return new ShellWindowGtk(host); 41 return new ShellWindowGtk(host);
42 #elif defined(TOOLKIT_VIEWS)
43 return new ShellWindowViews(host);
40 #endif 44 #endif
41 45
42 return NULL; 46 return NULL;
43 } 47 }
44 48
45 void ShellWindow::Observe(int type, 49 void ShellWindow::Observe(int type,
46 const content::NotificationSource& source, 50 const content::NotificationSource& source,
47 const content::NotificationDetails& details) { 51 const content::NotificationDetails& details) {
48 switch (type) { 52 switch (type) {
49 case chrome::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE: 53 case chrome::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE:
50 if (content::Details<ExtensionHost>(host_.get()) == details) 54 if (content::Details<ExtensionHost>(host_.get()) == details)
51 Close(); 55 Close();
52 break; 56 break;
53 default: 57 default:
54 NOTREACHED() << "Received unexpected notification"; 58 NOTREACHED() << "Received unexpected notification";
55 } 59 }
56 } 60 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698