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

Side by Side Diff: chrome/browser/notifications/balloon_host.cc

Issue 9702068: Move extension pop-ups and notifications to the new auto-resize code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: small update Created 8 years, 9 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/notifications/balloon_host.h"
6
5 #include "chrome/browser/notifications/balloon.h" 7 #include "chrome/browser/notifications/balloon.h"
6 #include "chrome/browser/notifications/balloon_host.h" 8 #include "chrome/browser/notifications/balloon_collection_impl.h"
7 #include "chrome/browser/notifications/notification.h" 9 #include "chrome/browser/notifications/notification.h"
8 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/browser/renderer_preferences_util.h" 11 #include "chrome/browser/renderer_preferences_util.h"
10 #include "chrome/browser/ui/browser.h" 12 #include "chrome/browser/ui/browser.h"
11 #include "chrome/browser/ui/browser_list.h" 13 #include "chrome/browser/ui/browser_list.h"
12 #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h" 14 #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h"
13 #include "chrome/common/chrome_notification_types.h" 15 #include "chrome/common/chrome_notification_types.h"
14 #include "chrome/common/chrome_view_type.h" 16 #include "chrome/common/chrome_view_type.h"
15 #include "chrome/common/extensions/extension_messages.h" 17 #include "chrome/common/extensions/extension_messages.h"
16 #include "chrome/common/render_messages.h" 18 #include "chrome/common/render_messages.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 63
62 void BalloonHost::CloseContents(WebContents* source) { 64 void BalloonHost::CloseContents(WebContents* source) {
63 balloon_->CloseByScript(); 65 balloon_->CloseByScript();
64 NotifyDisconnect(); 66 NotifyDisconnect();
65 } 67 }
66 68
67 void BalloonHost::HandleMouseDown() { 69 void BalloonHost::HandleMouseDown() {
68 balloon_->OnClick(); 70 balloon_->OnClick();
69 } 71 }
70 72
71 void BalloonHost::UpdatePreferredSize(WebContents* source, 73 void BalloonHost::ResizeDueToAutoResize(WebContents* source,
72 const gfx::Size& pref_size) { 74 const gfx::Size& pref_size) {
73 balloon_->SetContentPreferredSize(pref_size); 75 balloon_->ResizeDueToAutoResize(pref_size);
74 } 76 }
75 77
76 void BalloonHost::AddNewContents(WebContents* source, 78 void BalloonHost::AddNewContents(WebContents* source,
77 WebContents* new_contents, 79 WebContents* new_contents,
78 WindowOpenDisposition disposition, 80 WindowOpenDisposition disposition,
79 const gfx::Rect& initial_pos, 81 const gfx::Rect& initial_pos,
80 bool user_gesture) { 82 bool user_gesture) {
81 Browser* browser = BrowserList::GetLastActiveWithProfile( 83 Browser* browser = BrowserList::GetLastActiveWithProfile(
82 Profile::FromBrowserContext(new_contents->GetBrowserContext())); 84 Profile::FromBrowserContext(new_contents->GetBrowserContext()));
83 if (!browser) 85 if (!browser)
84 return; 86 return;
85 browser->AddWebContents(new_contents, disposition, initial_pos, user_gesture); 87 browser->AddWebContents(new_contents, disposition, initial_pos, user_gesture);
86 } 88 }
87 89
88 void BalloonHost::RenderViewCreated(content::RenderViewHost* render_view_host) { 90 void BalloonHost::RenderViewCreated(content::RenderViewHost* render_view_host) {
89 render_view_host->DisableScrollbarsForThreshold( 91 gfx::Size min_size(BalloonCollectionImpl::min_balloon_width(),
90 balloon_->min_scrollbar_size()); 92 BalloonCollectionImpl::min_balloon_height());
91 render_view_host->WasResized(); 93 gfx::Size max_size(BalloonCollectionImpl::max_balloon_width(),
92 render_view_host->EnablePreferredSizeMode(); 94 BalloonCollectionImpl::max_balloon_height());
95 render_view_host->EnableAutoResize(min_size, max_size);
93 96
94 if (enable_web_ui_) 97 if (enable_web_ui_)
95 render_view_host->AllowBindings(content::BINDINGS_POLICY_WEB_UI); 98 render_view_host->AllowBindings(content::BINDINGS_POLICY_WEB_UI);
96 } 99 }
97 100
98 void BalloonHost::RenderViewReady() { 101 void BalloonHost::RenderViewReady() {
99 should_notify_on_disconnect_ = true; 102 should_notify_on_disconnect_ = true;
100 content::NotificationService::current()->Notify( 103 content::NotificationService::current()->Notify(
101 chrome::NOTIFICATION_NOTIFY_BALLOON_CONNECTED, 104 chrome::NOTIFICATION_NOTIFY_BALLOON_CONNECTED,
102 content::Source<BalloonHost>(this), 105 content::Source<BalloonHost>(this),
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 should_notify_on_disconnect_ = false; 159 should_notify_on_disconnect_ = false;
157 content::NotificationService::current()->Notify( 160 content::NotificationService::current()->Notify(
158 chrome::NOTIFICATION_NOTIFY_BALLOON_DISCONNECTED, 161 chrome::NOTIFICATION_NOTIFY_BALLOON_DISCONNECTED,
159 content::Source<BalloonHost>(this), 162 content::Source<BalloonHost>(this),
160 content::NotificationService::NoDetails()); 163 content::NotificationService::NoDetails());
161 } 164 }
162 165
163 bool BalloonHost::IsRenderViewReady() const { 166 bool BalloonHost::IsRenderViewReady() const {
164 return should_notify_on_disconnect_; 167 return should_notify_on_disconnect_;
165 } 168 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698