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

Unified Diff: chrome/browser/ui/views/aura/panel_view_aura.cc

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: Address comments. 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/ui/views/aura/panel_view_aura.cc
diff --git a/chrome/browser/ui/views/aura/panel_view_aura.cc b/chrome/browser/ui/views/aura/panel_view_aura.cc
index 9b058dd02a4e7437d64e208eea9ea9239c5bd2e4..9891964e9f17ac535e76bb88d5d2bff38fcd9104 100644
--- a/chrome/browser/ui/views/aura/panel_view_aura.cc
+++ b/chrome/browser/ui/views/aura/panel_view_aura.cc
@@ -7,6 +7,10 @@
#include "ash/wm/panel_frame_view.h"
#include "base/utf_string_conversions.h"
#include "chrome/browser/extensions/extension_function_dispatcher.h"
+#include "chrome/browser/extensions/extension_tab_util.h"
+#include "chrome/browser/extensions/extension_tabs_module_constants.h"
+#include "chrome/browser/extensions/extension_window_controller.h"
+#include "chrome/browser/extensions/extension_window_list.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_list.h"
@@ -29,21 +33,22 @@ const int kDefaultWidth = 200;
const int kDefaultHeight = 300;
}
+namespace internal {
+
////////////////////////////////////////////////////////////////////////////////
// PanelHost
-namespace internal {
-
class PanelHost : public content::WebContentsDelegate,
public content::WebContentsObserver,
public ExtensionFunctionDispatcher::Delegate {
public:
- explicit PanelHost(PanelViewAura* panel_view, Profile* profile);
+ PanelHost(PanelViewAura* panel_view, Profile* profile);
virtual ~PanelHost();
void Init(const GURL& url);
content::WebContents* web_contents() const { return web_contents_.get(); }
+ Profile* profile() const { return profile_; }
// ExtensionFunctionDispatcher::Delegate overrides.
virtual Browser* GetBrowser() OVERRIDE;
@@ -161,6 +166,81 @@ void PanelHost::OnRequest(const ExtensionHostMsg_Request_Params& params) {
web_contents_->GetRenderViewHost());
}
+////////////////////////////////////////////////////////////////////////////////
+// PanelExtensionWindowController
+
+class PanelExtensionWindowController : public ExtensionWindowController {
+ public:
+ PanelExtensionWindowController(PanelViewAura* panel_view,
+ PanelHost* panel_host);
+
+ // Overriden from ExtensionWindowController:
+ virtual const SessionID& GetSessionId() const OVERRIDE;
+ virtual base::DictionaryValue* CreateWindowValue() const OVERRIDE;
+ virtual base::DictionaryValue* CreateWindowValueWithTabs() const OVERRIDE;
+ virtual bool CanClose(
+ ExtensionWindowController::Reason* reason) const OVERRIDE;
+ virtual void SetFullscreenMode(bool is_fullscreen,
+ const GURL& extension_url) const OVERRIDE;
+
+ private:
+ PanelViewAura* panel_view_;
+ PanelHost* panel_host_;
+
+ DISALLOW_COPY_AND_ASSIGN(PanelExtensionWindowController);
+};
+
+PanelExtensionWindowController::PanelExtensionWindowController(
+ PanelViewAura* panel_view,
+ PanelHost* panel_host)
+ : ExtensionWindowController(panel_view, panel_host->profile()),
+ panel_view_(panel_view),
+ panel_host_(panel_host) {
+}
+
+const SessionID& PanelExtensionWindowController::GetSessionId() const {
+ return panel_view_->session_id();
+}
+
+namespace keys = extension_tabs_module_constants;
+
+base::DictionaryValue*
+PanelExtensionWindowController::CreateWindowValue() const {
+ DictionaryValue* result = new DictionaryValue();
+ result->SetInteger(keys::kIdKey, panel_view_->session_id().id());
sky 2012/02/24 04:38:24 Seems like you could share more code between the t
stevenjb 2012/02/24 19:25:06 Done.
+ result->SetBoolean(keys::kIncognitoKey,
+ panel_host_->profile()->IsOffTheRecord());
+ result->SetBoolean(keys::kFocusedKey, false);
sky 2012/02/24 04:38:24 Why is this always false?
stevenjb 2012/02/24 19:25:06 Oversight. Fixed.
+
+ SetWindowValueBounds(panel_view_->GetRestoredBounds(), result);
+
+ result->SetString(keys::kWindowTypeKey, keys::kWindowTypeValuePanel);
+ result->SetString(keys::kShowStateKey, keys::kShowStateValueNormal);
+
+ return result;
+}
+
+base::DictionaryValue*
+PanelExtensionWindowController::CreateWindowValueWithTabs() const {
+ DictionaryValue* result = CreateWindowValue();
+
+ // Currently there is no mechanism to get a tab id without an associated
+ // TabContentsWrapper. If we need access to tabs for non-browser windows
+ // we will need to either add a TabContentsWrapper for panels, or add another
+ // mechanism for tracking tabs.
+
+ return result;
+}
+
+bool PanelExtensionWindowController::CanClose(
+ ExtensionWindowController::Reason* reason) const {
+ return true;
+}
+
+void PanelExtensionWindowController::SetFullscreenMode(
+ bool is_fullscreen, const GURL& extension_url) const {
+}
+
} // namespace internal
////////////////////////////////////////////////////////////////////////////////
@@ -201,7 +281,12 @@ views::Widget* PanelViewAura::Init(Profile* profile,
Attach(host_->web_contents()->GetNativeView());
- widget_->Show();
+ // Add the browser to the list of windows available to the extension API.
+ extension_window_controller_.reset(
+ new internal::PanelExtensionWindowController(this, host_.get()));
+
+ // Show the window, but don't activate it by default.
+ widget_->ShowInactive();
return widget_;
}
@@ -261,3 +346,68 @@ const views::Widget* PanelViewAura::GetWidget() const {
views::NonClientFrameView* PanelViewAura::CreateNonClientFrameView() {
return new ash::PanelFrameView();
}
+
+// BaseWindow implementation:
+
+bool PanelViewAura::IsActive() const {
+ return GetWidget()->IsActive();
+}
+
+bool PanelViewAura::IsMaximized() const {
+ return GetWidget()->IsMaximized();
+}
+
+bool PanelViewAura::IsMinimized() const {
+ return GetWidget()->IsMinimized();
+}
+
+gfx::Rect PanelViewAura::GetRestoredBounds() const {
+ return GetWidget()->GetRestoredBounds();
+}
+
+gfx::Rect PanelViewAura::GetBounds() const {
+ return GetWidget()->GetWindowScreenBounds();
+}
+
+void PanelViewAura::Show() {
+ GetWidget()->Show();
+}
+
+void PanelViewAura::ShowInactive() {
+ GetWidget()->ShowInactive();
+}
+
+void PanelViewAura::Close() {
+ GetWidget()->Close();
+}
+
+void PanelViewAura::Activate() {
+ GetWidget()->Activate();
+}
+
+void PanelViewAura::Deactivate() {
+ GetWidget()->Deactivate();
+}
+
+void PanelViewAura::Maximize() {
+ NOTIMPLEMENTED();
+}
+
+void PanelViewAura::Minimize() {
+ // TODO(stevenjb): Implement
+ NOTIMPLEMENTED();
+}
+
+void PanelViewAura::Restore() {
+ // TODO(stevenjb): Implement
+ NOTIMPLEMENTED();
+}
+
+void PanelViewAura::SetBounds(const gfx::Rect& bounds) {
+ GetWidget()->SetBounds(bounds);
+}
+
+void PanelViewAura::FlashFrame(bool flash) {
+ // TODO(stevenjb): Implement
+ NOTIMPLEMENTED();
+}

Powered by Google App Engine
This is Rietveld 408576698