diff options
author | thakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-16 00:59:04 +0000 |
---|---|---|
committer | thakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-16 00:59:04 +0000 |
commit | 10eaf87fb4e1f7677001d16c1296b7305143f633 (patch) | |
tree | ca3cd34d91a302174a43561a37340ec7227a2ac5 /chrome/browser/cocoa/extension_view_mac.mm | |
parent | 9b9c9b5cf3693654c4fec4a058dfaa62fee9737b (diff) | |
download | chromium_src-10eaf87fb4e1f7677001d16c1296b7305143f633.zip chromium_src-10eaf87fb4e1f7677001d16c1296b7305143f633.tar.gz chromium_src-10eaf87fb4e1f7677001d16c1296b7305143f633.tar.bz2 |
Add a bare-bones extension shelf that displays extension items on OS X.
This brings our extension support to about the level it has on linux.
One issue is that the toolstrips are webpages with a background image that just happens to look like the shelf they are on. But the background images are not updated on key->nonkey window changes, so the toolstrip backgrounds look slightly off in one of the two cases. If we decide to keep the shelf, we should fix this, but see the bug for erikkay's stance on this.
Also, the NTP is only loaded after all toolstrips have been loaded for some reason. That's what happens on the other platforms too, I believe.
The extension shelf uses the DownloadShelfView as background view for now.
Screenie: http://imgur.com/wSHgU.png
BUG=19073
TEST=Extensions that live in the shelf should show up. They should be clickable, resize correctly (e.g. the build status extension), and the shelf should interact in a sane way with the status bubble.
Review URL: http://codereview.chromium.org/175025
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@26311 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa/extension_view_mac.mm')
-rw-r--r-- | chrome/browser/cocoa/extension_view_mac.mm | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/chrome/browser/cocoa/extension_view_mac.mm b/chrome/browser/cocoa/extension_view_mac.mm new file mode 100644 index 0000000..a64eee8 --- /dev/null +++ b/chrome/browser/cocoa/extension_view_mac.mm @@ -0,0 +1,68 @@ +// Copyright (c) 2009 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. + +#include "chrome/browser/cocoa/extension_view_mac.h" + +#include "chrome/browser/extensions/extension_host.h" +#include "chrome/browser/renderer_host/render_view_host.h" +#include "chrome/browser/renderer_host/render_widget_host_view_mac.h" + +ExtensionViewMac::ExtensionViewMac(ExtensionHost* extension_host, + Browser* browser) + : is_toolstrip_(true), + browser_(browser), + extension_host_(extension_host), + render_widget_host_view_(NULL) { + DCHECK(extension_host_); +} + +ExtensionViewMac::~ExtensionViewMac() { + if (render_widget_host_view_) + [render_widget_host_view_->native_view() release]; +} + +void ExtensionViewMac::Init() { + CreateWidgetHostView(); +} + +gfx::NativeView ExtensionViewMac::native_view() { + DCHECK(render_widget_host_view_); + return render_widget_host_view_->native_view(); +} + +RenderViewHost* ExtensionViewMac::render_view_host() const { + return extension_host_->render_view_host(); +} + +void ExtensionViewMac::SetBackground(const SkBitmap& background) { + DCHECK(render_widget_host_view_); + render_widget_host_view_->SetBackground(background); +} + +void ExtensionViewMac::UpdatePreferredWidth(int pref_width) { + // TODO(thakis, erikkay): Windows does some tricks to resize the extension + // view not before it's visible. Do something similar here. + + // No need to use CA here, our caller calls us repeatedly to animate the + // resizing. + NSView* view = native_view(); + NSRect frame = [view frame]; + frame.size.width = pref_width; + + // RenderWidgetHostViewCocoa overrides setFrame but not setFrameSize. + [view setFrame:frame]; + [view setNeedsDisplay:YES]; +} + +void ExtensionViewMac::CreateWidgetHostView() { + DCHECK(!render_widget_host_view_); + render_widget_host_view_ = new RenderWidgetHostViewMac(render_view_host()); + + // The RenderWidgetHostViewMac is owned by its native view, which is created + // in an autoreleased state. retain it, so that it doesn't immediately + // disappear. + [render_widget_host_view_->native_view() retain]; + + extension_host_->CreateRenderView(render_widget_host_view_); +} |