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

Side by Side Diff: chrome/browser/extensions/extension_view.cc

Issue 56122: Callbacks through ChromeClient->RenderView->RenderViewHost for ContentsDidCha... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/extensions/extension_view.h" 5 #include "chrome/browser/extensions/extension_view.h"
6 6
7 #include "chrome/browser/extensions/extension.h" 7 #include "chrome/browser/extensions/extension.h"
8 #include "chrome/browser/extensions/extension_message_service.h" 8 #include "chrome/browser/extensions/extension_message_service.h"
9 #include "chrome/browser/renderer_host/render_view_host.h" 9 #include "chrome/browser/renderer_host/render_view_host.h"
10 #include "chrome/browser/renderer_host/render_process_host.h" 10 #include "chrome/browser/renderer_host/render_process_host.h"
11 #include "chrome/common/resource_bundle.h" 11 #include "chrome/common/resource_bundle.h"
12 12
13 #include "grit/browser_resources.h" 13 #include "grit/browser_resources.h"
14 #include "grit/generated_resources.h" 14 #include "grit/generated_resources.h"
15 15
16 ExtensionView::ExtensionView(Extension* extension, 16 ExtensionView::ExtensionView(Extension* extension,
17 const GURL& url, 17 const GURL& url,
18 Profile* profile) 18 Profile* profile)
19 : HWNDHtmlView(url, this, false), 19 : HWNDHtmlView(url, this, false),
20 extension_(extension), 20 extension_(extension),
21 profile_(profile) { 21 profile_(profile) {
22 // TODO(mpcomplete): query this from the renderer somehow? 22 // Set the width initially to 0, so that the WebCore::Document can
23 set_preferred_size(gfx::Size(100, 100)); 23 // correctly compute the minPrefWidth which is returned in
24 // DidContentsChangeSize()
25 set_preferred_size(gfx::Size(0, 100));
26 SetVisible(false);
27 }
28
29 void ExtensionView::DidStopLoading(RenderViewHost* render_view_host,
30 int32 page_id) {
31 SetVisible(true);
32 render_view_host->WasResized();
33 }
34
35 void ExtensionView::DidContentsPreferredWidthChange(const int pref_width) {
36 if (pref_width > 0) {
37 // SchedulePaint first because new_width may be smaller and we want
38 // the Parent to paint the vacated space.
39 SchedulePaint();
40 set_preferred_size(gfx::Size(pref_width, 100));
41 SizeToPreferredSize();
42
43 // TODO(rafaelw): This assumes that the extension view is a child of an
44 // ExtensionToolstrip, which is a child of the BookmarkBarView. There should
45 // be a way to do this where the ExtensionView doesn't have to know it's
46 // containment hierarchy.
47 if (GetParent() != NULL && GetParent()->GetParent() != NULL) {
48 GetParent()->GetParent()->Layout();
49 }
50
51 SchedulePaint();
52 render_view_host()->WasResized();
53 }
24 } 54 }
25 55
26 void ExtensionView::CreatingRenderer() { 56 void ExtensionView::CreatingRenderer() {
27 render_view_host()->AllowExtensionBindings(); 57 render_view_host()->AllowExtensionBindings();
28 } 58 }
29 59
30 void ExtensionView::RenderViewCreated(RenderViewHost* rvh) { 60 void ExtensionView::RenderViewCreated(RenderViewHost* rvh) {
31 ExtensionMessageService::GetInstance()->RegisterExtension( 61 ExtensionMessageService::GetInstance()->RegisterExtension(
32 extension_->id(), render_view_host()->process()->pid()); 62 extension_->id(), render_view_host()->process()->pid());
33 } 63 }
(...skipping 16 matching lines...) Expand all
50 render_view_host()->JavaScriptMessageBoxClosed(reply_msg, true, L""); 80 render_view_host()->JavaScriptMessageBoxClosed(reply_msg, true, L"");
51 } 81 }
52 82
53 void ExtensionView::DidStartLoading(RenderViewHost* render_view_host, 83 void ExtensionView::DidStartLoading(RenderViewHost* render_view_host,
54 int32 page_id) { 84 int32 page_id) {
55 static const StringPiece toolstrip_css( 85 static const StringPiece toolstrip_css(
56 ResourceBundle::GetSharedInstance().GetRawDataResource( 86 ResourceBundle::GetSharedInstance().GetRawDataResource(
57 IDR_EXTENSIONS_TOOLSTRIP_CSS)); 87 IDR_EXTENSIONS_TOOLSTRIP_CSS));
58 render_view_host->InsertCSSInWebFrame(L"", toolstrip_css.as_string()); 88 render_view_host->InsertCSSInWebFrame(L"", toolstrip_css.as_string());
59 } 89 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_view.h ('k') | chrome/browser/renderer_host/render_view_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698