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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/extension_window_wrapper.h
diff --git a/chrome/browser/extensions/extension_window_wrapper.h b/chrome/browser/extensions/extension_window_wrapper.h
new file mode 100644
index 0000000000000000000000000000000000000000..42dbbef048c032d4354dfbd111665c2cd55da35b
--- /dev/null
+++ b/chrome/browser/extensions/extension_window_wrapper.h
@@ -0,0 +1,95 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_WINDOW_WRAPPER_H_
+#define CHROME_BROWSER_EXTENSIONS_EXTENSION_WINDOW_WRAPPER_H_
+#pragma once
+
+#include <list>
+
+#include "base/compiler_specific.h"
+#include "base/memory/singleton.h"
+
+class BaseWindow;
+class Profile;
+class SessionID;
+
+namespace base {
+class DictionaryValue;
+}
+
+namespace gfx {
+class Rect;
+}
+
+// This API needs to be implemented by any window that might be accessed
+// through chrome.windows or chrome.tabs (e.g. browser windows and panels).
+class ExtensionWindowWrapper {
+ public:
+ 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.
+ enum Reason {
+ REASON_NONE,
+ REASON_TAB_STRIP_NOT_EDITABLE,
+ };
+
+ ExtensionWindowWrapper(BaseWindow* window, Profile* profile);
+
+ BaseWindow* window() const { return window_; }
+ // 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.
+ virtual bool MatchesProfile(
+ 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.
+
+ // Return a session id uniquely identifying the window.
+ virtual const SessionID& GetSessionId() const = 0;
+ // Populates a dictionary for the Window object.
+ virtual base::DictionaryValue* CreateWindowValue(
+ bool populate_tabs) const = 0;
sky 2012/02/22 21:46:25 use enum
stevenjb 2012/02/23 02:19:15 Made two functions.
+ // Returns false if the window is in a state where closing the window is not
+ // permitted and sets |reason| if not NULL.
+ virtual bool CanClose(Reason* reason) const = 0;
+
+ private:
+ BaseWindow* window_;
+ Profile* profile_;
+
+ DISALLOW_COPY_AND_ASSIGN(ExtensionWindowWrapper);
+};
+
+// Class to maintain a list of ExtensionWindowWrappers.
+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.
+ public:
+ typedef std::list<ExtensionWindowWrapper*> WindowList;
+
+ ExtensionWindowWrapperList();
+
+ void AddExtensionWindow(ExtensionWindowWrapper* window);
+ void RemoveExtensionWindow(ExtensionWindowWrapper* window);
+
+ // Returns a window matching the profile and id, or NULL.
+ 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.
+ const Profile* profile, bool include_incognito, int id) const;
+
+ // Returns the focused or last added window matching the profile, or NULL.
+ ExtensionWindowWrapper* CurrentWindow(
+ 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
+
+ // Returns the focused window matching the profile, or NULL.
+ ExtensionWindowWrapper* FocusedWindow(
+ const Profile* profile, bool include_incognito) const;
+
+ const WindowList& windows() const { return windows_; }
+
+ static ExtensionWindowWrapperList* GetInstance();
+
+ private:
+ friend struct DefaultSingletonTraits<ExtensionWindowWrapperList>;
+
+ // Entries are not owned by this class and must be removed when destroyed.
+ WindowList windows_;
+
+ DISALLOW_COPY_AND_ASSIGN(ExtensionWindowWrapperList);
+};
+
sky 2012/02/22 21:46:25 nit: just one newline.
stevenjb 2012/02/23 02:19:15 Done.
+
+#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_WINDOW_WRAPPER_H_

Powered by Google App Engine
This is Rietveld 408576698