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

Side by Side Diff: chrome/browser/extensions/extension_window_wrapper.h

Issue 9428018: Create BaseWindow and ExtensionWindowWrapper for extension API access to Panels (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 10 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_WINDOW_WRAPPER_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_WINDOW_WRAPPER_H_
7 #pragma once
8
9 #include <list>
10
11 #include "base/compiler_specific.h"
12 #include "base/memory/singleton.h"
13
14 class BaseWindow;
15 class Profile;
16 class SessionID;
17
18 namespace base {
19 class DictionaryValue;
20 }
21
22 namespace gfx {
23 class Rect;
24 }
25
26 // This API needs to be implemented by any window that might be accessed
27 // through chrome.windows or chrome.tabs (e.g. browser windows and panels).
28 class ExtensionWindowWrapper {
29 public:
30 typedef std::list<ExtensionWindowWrapper*> WindowList;
sky 2012/02/22 21:46:25 Does this need to be in both classes?
stevenjb 2012/02/23 02:19:15 Done.
31 enum Reason {
32 REASON_NONE,
33 REASON_TAB_STRIP_NOT_EDITABLE,
34 };
35
36 ExtensionWindowWrapper(BaseWindow* window, Profile* profile);
37
38 BaseWindow* window() const { return window_; }
39 // Returns true if the window matches the profile.
sky 2012/02/22 21:46:25 Newline between methods.
stevenjb 2012/02/23 02:19:15 Done.
40 virtual bool MatchesProfile(
41 const Profile* profile, bool allow_incognito) const;
sky 2012/02/22 21:46:25 nit: each param on its own line. Does this method
stevenjb 2012/02/23 02:19:15 Done.
42
43 // Return a session id uniquely identifying the window.
44 virtual const SessionID& GetSessionId() const = 0;
45 // Populates a dictionary for the Window object.
46 virtual base::DictionaryValue* CreateWindowValue(
47 bool populate_tabs) const = 0;
sky 2012/02/22 21:46:25 use enum
stevenjb 2012/02/23 02:19:15 Made two functions.
48 // Returns false if the window is in a state where closing the window is not
49 // permitted and sets |reason| if not NULL.
50 virtual bool CanClose(Reason* reason) const = 0;
51
52 private:
53 BaseWindow* window_;
54 Profile* profile_;
55
56 DISALLOW_COPY_AND_ASSIGN(ExtensionWindowWrapper);
57 };
58
59 // Class to maintain a list of ExtensionWindowWrappers.
60 class ExtensionWindowWrapperList {
sky 2012/02/22 21:46:25 How come this is in the same file as ExtensionWind
stevenjb 2012/02/23 02:19:15 Planning to move once renamed.
61 public:
62 typedef std::list<ExtensionWindowWrapper*> WindowList;
63
64 ExtensionWindowWrapperList();
65
66 void AddExtensionWindow(ExtensionWindowWrapper* window);
67 void RemoveExtensionWindow(ExtensionWindowWrapper* window);
68
69 // Returns a window matching the profile and id, or NULL.
70 ExtensionWindowWrapper* FindWindowById(
sky 2012/02/22 21:46:25 nit: when you wrap, each param on its own line. He
stevenjb 2012/02/23 02:19:15 Done.
71 const Profile* profile, bool include_incognito, int id) const;
72
73 // Returns the focused or last added window matching the profile, or NULL.
74 ExtensionWindowWrapper* CurrentWindow(
75 const Profile* profile, bool include_incognito) const;
sky 2012/02/22 21:46:25 bool -> enum
stevenjb 2012/02/23 02:19:15 We pass include_incognito as a bool pretty much ev
76
77 // Returns the focused window matching the profile, or NULL.
78 ExtensionWindowWrapper* FocusedWindow(
79 const Profile* profile, bool include_incognito) const;
80
81 const WindowList& windows() const { return windows_; }
82
83 static ExtensionWindowWrapperList* GetInstance();
84
85 private:
86 friend struct DefaultSingletonTraits<ExtensionWindowWrapperList>;
87
88 // Entries are not owned by this class and must be removed when destroyed.
89 WindowList windows_;
90
91 DISALLOW_COPY_AND_ASSIGN(ExtensionWindowWrapperList);
92 };
93
sky 2012/02/22 21:46:25 nit: just one newline.
stevenjb 2012/02/23 02:19:15 Done.
94
95 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_WINDOW_WRAPPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698