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

Side by Side Diff: chrome/browser/cocoa/extension_view_mac.mm

Issue 175025: Add a bare-bones extension shelf that displays extension items on OS X. (Closed)
Patch Set: Merge ToT, address more comments Created 11 years, 3 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
« no previous file with comments | « chrome/browser/cocoa/extension_view_mac.h ('k') | chrome/browser/cocoa/status_bubble_mac.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2009 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 #include "chrome/browser/cocoa/extension_view_mac.h"
6
7 #include "chrome/browser/extensions/extension_host.h"
8 #include "chrome/browser/renderer_host/render_view_host.h"
9 #include "chrome/browser/renderer_host/render_widget_host_view_mac.h"
10
11 ExtensionViewMac::ExtensionViewMac(ExtensionHost* extension_host,
12 Browser* browser)
13 : is_toolstrip_(true),
14 browser_(browser),
15 extension_host_(extension_host),
16 render_widget_host_view_(NULL) {
17 DCHECK(extension_host_);
18 }
19
20 ExtensionViewMac::~ExtensionViewMac() {
21 if (render_widget_host_view_)
22 [render_widget_host_view_->native_view() release];
23 }
24
25 void ExtensionViewMac::Init() {
26 CreateWidgetHostView();
27 }
28
29 gfx::NativeView ExtensionViewMac::native_view() {
30 DCHECK(render_widget_host_view_);
31 return render_widget_host_view_->native_view();
32 }
33
34 RenderViewHost* ExtensionViewMac::render_view_host() const {
35 return extension_host_->render_view_host();
36 }
37
38 void ExtensionViewMac::SetBackground(const SkBitmap& background) {
39 DCHECK(render_widget_host_view_);
40 render_widget_host_view_->SetBackground(background);
41 }
42
43 void ExtensionViewMac::UpdatePreferredWidth(int pref_width) {
44 // TODO(thakis, erikkay): Windows does some tricks to resize the extension
45 // view not before it's visible. Do something similar here.
46
47 // No need to use CA here, our caller calls us repeatedly to animate the
48 // resizing.
49 NSView* view = native_view();
50 NSRect frame = [view frame];
51 frame.size.width = pref_width;
52
53 // RenderWidgetHostViewCocoa overrides setFrame but not setFrameSize.
54 [view setFrame:frame];
55 [view setNeedsDisplay:YES];
56 }
57
58 void ExtensionViewMac::CreateWidgetHostView() {
59 DCHECK(!render_widget_host_view_);
60 render_widget_host_view_ = new RenderWidgetHostViewMac(render_view_host());
61
62 // The RenderWidgetHostViewMac is owned by its native view, which is created
63 // in an autoreleased state. retain it, so that it doesn't immediately
64 // disappear.
65 [render_widget_host_view_->native_view() retain];
66
67 extension_host_->CreateRenderView(render_widget_host_view_);
68 }
OLDNEW
« no previous file with comments | « chrome/browser/cocoa/extension_view_mac.h ('k') | chrome/browser/cocoa/status_bubble_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698