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/extensions/extension_window_controller.h

Issue 10407035: Extension/Platform App window isolation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix tests 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 | 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 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_WINDOW_CONTROLLER_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_WINDOW_CONTROLLER_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_WINDOW_CONTROLLER_H_ 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_WINDOW_CONTROLLER_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 13
14 class BaseWindow; 14 class BaseWindow;
15 class Browser; // TODO(stevenjb) eliminate this dependency. 15 class Browser; // TODO(stevenjb) eliminate this dependency.
16 class Extension;
16 class GURL; 17 class GURL;
17 class Profile; 18 class Profile;
18 class SessionID; 19 class SessionID;
20 class UIThreadExtensionFunction;
19 21
20 namespace base { 22 namespace base {
21 class DictionaryValue; 23 class DictionaryValue;
22 } 24 }
23 25
24 namespace gfx { 26 namespace gfx {
25 class Rect; 27 class Rect;
26 } 28 }
27 29
28 // This API needs to be implemented by any window that might be accessed 30 // This API needs to be implemented by any window that might be accessed
29 // through chrome.windows or chrome.tabs (e.g. browser windows and panels). 31 // through chrome.windows or chrome.tabs (e.g. browser windows and panels).
30 class ExtensionWindowController { 32 class ExtensionWindowController {
31 public: 33 public:
32 enum Reason { 34 enum Reason {
33 REASON_NONE, 35 REASON_NONE,
34 REASON_NOT_EDITABLE, 36 REASON_NOT_EDITABLE,
35 }; 37 };
36 38
37 enum ProfileMatchType {
38 MATCH_NORMAL_ONLY,
39 MATCH_INCOGNITO
40 };
41
42 ExtensionWindowController(BaseWindow* window, Profile* profile); 39 ExtensionWindowController(BaseWindow* window, Profile* profile);
43 virtual ~ExtensionWindowController(); 40 virtual ~ExtensionWindowController();
44 41
45 BaseWindow* window() const { return window_; } 42 BaseWindow* window() const { return window_; }
46 43
47 Profile* profile() const { return profile_; } 44 Profile* profile() const { return profile_; }
48 45
49 // Returns true if the window matches the profile. 46 // Returns true if the function (and the profile and extension that it was
50 bool MatchesProfile(Profile* profile, ProfileMatchType match_type) const; 47 // invoked from) can operate on this window.
48 bool IsVisibleToFunction(UIThreadExtensionFunction* function) const;
51 49
52 // Return an id uniquely identifying the window. 50 // Return an id uniquely identifying the window.
53 virtual int GetWindowId() const = 0; 51 virtual int GetWindowId() const = 0;
54 52
55 // Return the type name for the window. 53 // Return the type name for the window.
56 virtual std::string GetWindowTypeText() const = 0; 54 virtual std::string GetWindowTypeText() const = 0;
57 55
58 // Populates a dictionary for the Window object. Override this to set 56 // Populates a dictionary for the Window object. Override this to set
59 // implementation specific properties (call the base implementation first to 57 // implementation specific properties (call the base implementation first to
60 // set common properties). 58 // set common properties).
61 virtual base::DictionaryValue* CreateWindowValue() const; 59 virtual base::DictionaryValue* CreateWindowValue() const;
62 60
63 // Populates a dictionary for the Window object, including a list of tabs. 61 // Populates a dictionary for the Window object, including a list of tabs.
64 virtual base::DictionaryValue* CreateWindowValueWithTabs() const = 0; 62 virtual base::DictionaryValue* CreateWindowValueWithTabs() const = 0;
65 63
66 // Returns false if the window is in a state where closing the window is not 64 // Returns false if the window is in a state where closing the window is not
67 // permitted and sets |reason| if not NULL. 65 // permitted and sets |reason| if not NULL.
68 virtual bool CanClose(Reason* reason) const = 0; 66 virtual bool CanClose(Reason* reason) const = 0;
69 67
70 // Set the window's fullscreen state. |extension_url| provides the url 68 // Set the window's fullscreen state. |extension_url| provides the url
71 // associated with the extension (used by FullscreenController). 69 // associated with the extension (used by FullscreenController).
72 virtual void SetFullscreenMode(bool is_fullscreen, 70 virtual void SetFullscreenMode(bool is_fullscreen,
73 const GURL& extension_url) const = 0; 71 const GURL& extension_url) const = 0;
74 72
75 // Returns a Browser if available. Defaults to returning NULL. 73 // Returns a Browser if available. Defaults to returning NULL.
76 // TODO(stevenjb): Temporary workaround. Eliminate this. 74 // TODO(stevenjb): Temporary workaround. Eliminate this.
77 virtual Browser* GetBrowser() const; 75 virtual Browser* GetBrowser() const;
78 76
77 protected:
78 virtual bool IsVisibleToExtension(const Extension* extension) const = 0;
79
79 private: 80 private:
80 BaseWindow* window_; 81 BaseWindow* window_;
81 Profile* profile_; 82 Profile* profile_;
82 83
83 DISALLOW_COPY_AND_ASSIGN(ExtensionWindowController); 84 DISALLOW_COPY_AND_ASSIGN(ExtensionWindowController);
84 }; 85 };
85 86
86 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_WINDOW_CONTROLLER_H_ 87 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_WINDOW_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698