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

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: Comments 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
16 class Extension; 18 class Extension;
17 class ExtensionHost;
18 class ExtensionWindowController; 19 class ExtensionWindowController;
19 class GURL; 20 class GURL;
20 class Profile; 21 class Profile;
21 22
22 namespace content { 23 namespace content {
23 class WebContents; 24 class WebContents;
24 } 25 }
25 26
Evan Stade 2012/05/08 00:58:16 please add a file level comment here as I have no
26 class ShellWindow : public content::NotificationObserver, 27 class ShellWindow : public content::NotificationObserver,
28 public content::WebContentsDelegate,
29 public content::WebContentsObserver,
30 public ExtensionFunctionDispatcher::Delegate,
27 public BaseWindow { 31 public BaseWindow {
28 public: 32 public:
33 static ShellWindow* Create(Profile* profile,
34 const Extension* extension,
35 const GURL& url);
36
37 const SessionID& session_id() const { return session_id_; }
38 const ExtensionWindowController* extension_window_controller() const {
39 return extension_window_controller_.get();
40 }
41
42 protected:
29 // TODO(mihaip): Switch from hardcoded defaults to passing in the window 43 // TODO(mihaip): Switch from hardcoded defaults to passing in the window
30 // creation parameters to ShellWindow::Create. 44 // creation parameters to ShellWindow::Create.
31 static const int kDefaultWidth = 512; 45 static const int kDefaultWidth = 512;
32 static const int kDefaultHeight = 384; 46 static const int kDefaultHeight = 384;
33 47
34 content::WebContents* web_contents() const { return host_->host_contents(); } 48 ShellWindow(Profile* profile,
35 const SessionID& session_id() const { return session_id_; } 49 const Extension* extension,
36 const ExtensionWindowController* extension_window_controller() const { 50 const GURL& url);
37 return extension_window_controller_.get(); 51 virtual ~ShellWindow();
38 }
39 52
40 static ShellWindow* Create(Profile* profile, 53 const Extension* extension() const { return extension_; }
41 const Extension* extension, 54 content::WebContents* web_contents() const { return web_contents_.get(); }
42 const GURL& url); 55
56 private:
57 // PlatformAppBrowserTest needs access to web_contents()
58 friend class PlatformAppBrowserTest;
59
60 // Instantiates a platform-specific ShellWindow subclass (one implementation
61 // per platform). Public users of ShellWindow should use ShellWindow::Create.
62 static ShellWindow* CreateImpl(Profile* profile,
63 const Extension* extension,
64 const GURL& url);
65
66 // content::WebContentsObserver
67 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
68
69 // content::WebContentsDelegate
70 virtual void CloseContents(content::WebContents* contents) OVERRIDE;
71 virtual bool ShouldSuppressDialogs() OVERRIDE;
43 72
44 // content::NotificationObserver implementation. 73 // content::NotificationObserver implementation.
45 virtual void Observe(int type, 74 virtual void Observe(int type,
46 const content::NotificationSource& source, 75 const content::NotificationSource& source,
47 const content::NotificationDetails& details) OVERRIDE; 76 const content::NotificationDetails& details) OVERRIDE;
48 77
49 protected: 78 virtual ExtensionWindowController* GetExtensionWindowController() const
50 explicit ShellWindow(ExtensionHost* host_); 79 OVERRIDE;
51 virtual ~ShellWindow();
52 80
53 // Instantiates a platform-specific ShellWindow subclass (one implementation 81 // Message handlers.
54 // per platform). Public users of ShellWindow should use ShellWindow::Create. 82 void OnRequest(const ExtensionHostMsg_Request_Params& params);
55 static ShellWindow* CreateShellWindow(ExtensionHost* host); 83
84 Profile* profile_; // weak pointer - owned by ProfileManager.
85 const Extension* extension_; // weak pointer - owned by ExtensionService.
56 86
57 const SessionID session_id_; 87 const SessionID session_id_;
58 scoped_ptr<ExtensionHost> host_; 88 scoped_ptr<content::WebContents> web_contents_;
59 content::NotificationRegistrar registrar_; 89 content::NotificationRegistrar registrar_;
60 scoped_ptr<ExtensionWindowController> extension_window_controller_; 90 scoped_ptr<ExtensionWindowController> extension_window_controller_;
91 ExtensionFunctionDispatcher extension_function_dispatcher_;
61 92
62 private:
63 DISALLOW_COPY_AND_ASSIGN(ShellWindow); 93 DISALLOW_COPY_AND_ASSIGN(ShellWindow);
64 }; 94 };
65 95
66 #endif // CHROME_BROWSER_UI_EXTENSIONS_SHELL_WINDOW_H_ 96 #endif // CHROME_BROWSER_UI_EXTENSIONS_SHELL_WINDOW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698