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

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

Issue 10119003: Pull shell window stuff out of ExtensionHost and put in ShellWindow (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Try jobs Created 8 years, 7 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) 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 #ifndef CHROME_BROWSER_UI_EXTENSIONS_SHELL_WINDOW_H_ 5 #ifndef CHROME_BROWSER_UI_EXTENSIONS_SHELL_WINDOW_H_
6 #define CHROME_BROWSER_UI_EXTENSIONS_SHELL_WINDOW_H_ 6 #define CHROME_BROWSER_UI_EXTENSIONS_SHELL_WINDOW_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "chrome/browser/extensions/extension_function_dispatcher.h"
10 #include "chrome/browser/sessions/session_id.h" 11 #include "chrome/browser/sessions/session_id.h"
11 #include "chrome/browser/extensions/extension_host.h"
12 #include "chrome/browser/ui/base_window.h" 12 #include "chrome/browser/ui/base_window.h"
13 #include "content/public/browser/notification_observer.h" 13 #include "content/public/browser/notification_observer.h"
14 #include "content/public/browser/notification_registrar.h" 14 #include "content/public/browser/notification_registrar.h"
15 #include "content/public/browser/web_contents_delegate.h"
16 #include "content/public/browser/web_contents_observer.h"
15 17
18 class Browser;
jeremya 2012/05/07 00:54:38 This doesn't seem to be used.
benwells 2012/05/07 08:46:15 Done.
16 class Extension; 19 class Extension;
17 class ExtensionHost;
18 class ExtensionWindowController; 20 class ExtensionWindowController;
19 class GURL; 21 class GURL;
20 class Profile; 22 class Profile;
21 23
22 namespace content { 24 namespace content {
23 class WebContents; 25 class WebContents;
24 } 26 }
25 27
26 class ShellWindow : public content::NotificationObserver, 28 class ShellWindow : public content::NotificationObserver,
29 public content::WebContentsDelegate,
30 public content::WebContentsObserver,
31 public ExtensionFunctionDispatcher::Delegate,
27 public BaseWindow { 32 public BaseWindow {
28 public: 33 public:
34 static ShellWindow* Create(Profile* profile,
35 const Extension* extension,
36 const GURL& url);
37
38 const SessionID& session_id() const { return session_id_; }
39 const ExtensionWindowController* extension_window_controller() const {
40 return extension_window_controller_.get();
41 }
42
43 protected:
29 // TODO(mihaip): Switch from hardcoded defaults to passing in the window 44 // TODO(mihaip): Switch from hardcoded defaults to passing in the window
30 // creation parameters to ShellWindow::Create. 45 // creation parameters to ShellWindow::Create.
31 static const int kDefaultWidth = 512; 46 static const int kDefaultWidth = 512;
32 static const int kDefaultHeight = 384; 47 static const int kDefaultHeight = 384;
33 48
34 content::WebContents* web_contents() const { return host_->host_contents(); } 49 ShellWindow(Profile* profile,
35 const SessionID& session_id() const { return session_id_; } 50 const Extension* extension,
36 const ExtensionWindowController* extension_window_controller() const { 51 const GURL& url);
37 return extension_window_controller_.get(); 52 virtual ~ShellWindow();
38 }
39 53
40 static ShellWindow* Create(Profile* profile, 54 const Extension* extension() const { return extension_; }
41 const Extension* extension, 55 content::WebContents* web_contents() const { return web_contents_.get(); }
42 const GURL& url); 56
57 private:
58 // PlatformAppBrowserTest needs access to web_contents()
59 friend class PlatformAppBrowserTest;
60
61 // Instantiates a platform-specific ShellWindow subclass (one implementation
62 // per platform). Public users of ShellWindow should use ShellWindow::Create.
63 static ShellWindow* CreateImpl(Profile* profile,
64 const Extension* extension,
65 const GURL& url);
66
67 // content::WebContentsObserver
68 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
69
70 // content::WebContentsDelegate
71 virtual void CloseContents(content::WebContents* contents) OVERRIDE;
72 virtual bool ShouldSuppressDialogs() OVERRIDE;
43 73
44 // content::NotificationObserver implementation. 74 // content::NotificationObserver implementation.
45 virtual void Observe(int type, 75 virtual void Observe(int type,
46 const content::NotificationSource& source, 76 const content::NotificationSource& source,
47 const content::NotificationDetails& details) OVERRIDE; 77 const content::NotificationDetails& details) OVERRIDE;
48 78
49 protected: 79 // Message handlers.
50 explicit ShellWindow(ExtensionHost* host_); 80 void OnRequest(const ExtensionHostMsg_Request_Params& params);
51 virtual ~ShellWindow();
52 81
53 // Instantiates a platform-specific ShellWindow subclass (one implementation 82 Profile* profile_; // weak pointer - owned by ProfileManager.
54 // per platform). Public users of ShellWindow should use ShellWindow::Create. 83 const Extension* extension_; // weak pointer - owned by ExtensionService.
55 static ShellWindow* CreateShellWindow(ExtensionHost* host);
56 84
57 const SessionID session_id_; 85 const SessionID session_id_;
58 scoped_ptr<ExtensionHost> host_; 86 scoped_ptr<content::WebContents> web_contents_;
59 content::NotificationRegistrar registrar_; 87 content::NotificationRegistrar registrar_;
60 scoped_ptr<ExtensionWindowController> extension_window_controller_; 88 scoped_ptr<ExtensionWindowController> extension_window_controller_;
89 ExtensionFunctionDispatcher extension_function_dispatcher_;
61 90
62 private:
63 DISALLOW_COPY_AND_ASSIGN(ShellWindow); 91 DISALLOW_COPY_AND_ASSIGN(ShellWindow);
64 }; 92 };
65 93
66 #endif // CHROME_BROWSER_UI_EXTENSIONS_SHELL_WINDOW_H_ 94 #endif // CHROME_BROWSER_UI_EXTENSIONS_SHELL_WINDOW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698