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

Side by Side Diff: chrome/browser/ui/webui/media_router/media_router_dialog_controller_impl.cc

Issue 1773073002: Revert of [Media Router] Enable autoresizing for the Media Router dialog for Mac. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/ui/webui/media_router/media_router_dialog_controller_im pl.h" 5 #include "chrome/browser/ui/webui/media_router/media_router_dialog_controller_im pl.h"
6 6
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 23 matching lines...) Expand all
34 DEFINE_WEB_CONTENTS_USER_DATA_KEY( 34 DEFINE_WEB_CONTENTS_USER_DATA_KEY(
35 media_router::MediaRouterDialogControllerImpl); 35 media_router::MediaRouterDialogControllerImpl);
36 36
37 using content::LoadCommittedDetails; 37 using content::LoadCommittedDetails;
38 using content::NavigationController; 38 using content::NavigationController;
39 using content::WebContents; 39 using content::WebContents;
40 using content::WebUIMessageHandler; 40 using content::WebUIMessageHandler;
41 using ui::WebDialogDelegate; 41 using ui::WebDialogDelegate;
42 42
43 namespace { 43 namespace {
44 #if defined(OS_MACOSX)
45 const int kFixedHeight = 350;
46 #else
44 const int kMaxHeight = 2000; 47 const int kMaxHeight = 2000;
45 const int kMinHeight = 80; 48 const int kMinHeight = 80;
49 #endif
46 const int kWidth = 340; 50 const int kWidth = 340;
47 } 51 }
48 52
49 namespace media_router { 53 namespace media_router {
50 54
51 namespace { 55 namespace {
52 56
53 // WebDialogDelegate that specifies what the Media Router dialog 57 // WebDialogDelegate that specifies what the Media Router dialog
54 // will look like. 58 // will look like.
55 class MediaRouterDialogDelegate : public WebDialogDelegate { 59 class MediaRouterDialogDelegate : public WebDialogDelegate {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 107
104 private: 108 private:
105 base::WeakPtr<MediaRouterAction> action_; 109 base::WeakPtr<MediaRouterAction> action_;
106 base::WeakPtr<MediaRouterDialogControllerImpl> controller_; 110 base::WeakPtr<MediaRouterDialogControllerImpl> controller_;
107 111
108 DISALLOW_COPY_AND_ASSIGN(MediaRouterDialogDelegate); 112 DISALLOW_COPY_AND_ASSIGN(MediaRouterDialogDelegate);
109 }; 113 };
110 114
111 void MediaRouterDialogDelegate::GetDialogSize(gfx::Size* size) const { 115 void MediaRouterDialogDelegate::GetDialogSize(gfx::Size* size) const {
112 DCHECK(size); 116 DCHECK(size);
117 // TODO(apacible): Remove after autoresizing is implemented for OSX.
118 #if defined(OS_MACOSX)
119 *size = gfx::Size(kWidth, kFixedHeight);
120 #else
113 // GetDialogSize() is called when the browser window resizes. We may want to 121 // GetDialogSize() is called when the browser window resizes. We may want to
114 // update the maximum height of the dialog and scale the WebUI to the new 122 // update the maximum height of the dialog and scale the WebUI to the new
115 // height. |size| is not set because the dialog is auto-resizeable. 123 // height. |size| is not set because the dialog is auto-resizeable.
116 controller_->UpdateMaxDialogSize(); 124 controller_->UpdateMaxDialogSize();
125 #endif
117 } 126 }
118 127
119 } // namespace 128 } // namespace
120 129
121 // static 130 // static
122 MediaRouterDialogControllerImpl* 131 MediaRouterDialogControllerImpl*
123 MediaRouterDialogControllerImpl::GetOrCreateForWebContents( 132 MediaRouterDialogControllerImpl::GetOrCreateForWebContents(
124 WebContents* web_contents) { 133 WebContents* web_contents) {
125 DCHECK(web_contents); 134 DCHECK(web_contents);
126 // This call does nothing if the controller already exists. 135 // This call does nothing if the controller already exists.
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 void MediaRouterDialogControllerImpl::CreateMediaRouterDialog() { 236 void MediaRouterDialogControllerImpl::CreateMediaRouterDialog() {
228 DCHECK(!dialog_observer_.get()); 237 DCHECK(!dialog_observer_.get());
229 238
230 base::Time dialog_creation_time = base::Time::Now(); 239 base::Time dialog_creation_time = base::Time::Now();
231 TRACE_EVENT_NESTABLE_ASYNC_BEGIN0("media_router", "UI", initiator()); 240 TRACE_EVENT_NESTABLE_ASYNC_BEGIN0("media_router", "UI", initiator());
232 241
233 Profile* profile = 242 Profile* profile =
234 Profile::FromBrowserContext(initiator()->GetBrowserContext()); 243 Profile::FromBrowserContext(initiator()->GetBrowserContext());
235 DCHECK(profile); 244 DCHECK(profile);
236 245
246 WebDialogDelegate* web_dialog_delegate =
247 new MediaRouterDialogDelegate(action_, weak_ptr_factory_.GetWeakPtr());
237 // |web_dialog_delegate|'s owner is |constrained_delegate|. 248 // |web_dialog_delegate|'s owner is |constrained_delegate|.
238 // |constrained_delegate| is owned by the parent |views::View|. 249 // |constrained_delegate| is owned by the parent |views::View|.
239 WebDialogDelegate* web_dialog_delegate = 250 // TODO(apacible): Remove after autoresizing is implemented for OSX.
240 new MediaRouterDialogDelegate(action_, weak_ptr_factory_.GetWeakPtr()); 251 #if defined(OS_MACOSX)
252 ConstrainedWebDialogDelegate* constrained_delegate =
253 ShowConstrainedWebDialog(profile, web_dialog_delegate, initiator());
254 #else
255 // TODO(apacible): Adjust min and max sizes based on new WebUI design.
256 gfx::Size min_size = gfx::Size(kWidth, kMinHeight);
257 gfx::Size max_size = gfx::Size(kWidth, kMaxHeight);
241 258
242 // |ShowConstrainedWebDialogWithAutoResize()| will end up creating 259 // |ShowConstrainedWebDialogWithAutoResize()| will end up creating
243 // ConstrainedWebDialogDelegateViewViews containing a WebContents containing 260 // ConstrainedWebDialogDelegateViewViews containing a WebContents containing
244 // the MediaRouterUI, using the provided |web_dialog_delegate|. Then, the 261 // the MediaRouterUI, using the provided |web_dialog_delegate|. Then, the
245 // view is shown as a modal dialog constrained to the |initiator| WebContents. 262 // view is shown as a modal dialog constrained to the |initiator| WebContents.
246 // The dialog will resize between the given minimum and maximum size bounds 263 // The dialog will resize between the |min_size| and |max_size| bounds based
247 // based on the currently rendered contents. 264 // on the currently rendered contents.
248 ConstrainedWebDialogDelegate* constrained_delegate = 265 ConstrainedWebDialogDelegate* constrained_delegate =
249 ShowConstrainedWebDialogWithAutoResize( 266 ShowConstrainedWebDialogWithAutoResize(
250 profile, web_dialog_delegate, initiator(), 267 profile, web_dialog_delegate, initiator(), min_size, max_size);
251 gfx::Size(kWidth, kMinHeight), gfx::Size(kWidth, kMaxHeight)); 268 #endif
252 269
253 WebContents* media_router_dialog = constrained_delegate->GetWebContents(); 270 WebContents* media_router_dialog = constrained_delegate->GetWebContents();
254 TRACE_EVENT_NESTABLE_ASYNC_INSTANT1("media_router", "UI", initiator(), 271 TRACE_EVENT_NESTABLE_ASYNC_INSTANT1("media_router", "UI", initiator(),
255 "WebContents created", 272 "WebContents created",
256 media_router_dialog); 273 media_router_dialog);
257 274
258 // |media_router_ui| is created when |constrained_delegate| is created. 275 // |media_router_ui| is created when |constrained_delegate| is created.
259 // For tests, GetWebUI() returns a nullptr. 276 // For tests, GetWebUI() returns a nullptr.
260 if (media_router_dialog->GetWebUI()) { 277 if (media_router_dialog->GetWebUI()) {
261 MediaRouterUI* media_router_ui = static_cast<MediaRouterUI*>( 278 MediaRouterUI* media_router_ui = static_cast<MediaRouterUI*>(
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 ->GetWeakPtr(); 337 ->GetWeakPtr();
321 if (!create_connection_request.get()) { 338 if (!create_connection_request.get()) {
322 media_router_ui->InitWithDefaultMediaSource(delegate); 339 media_router_ui->InitWithDefaultMediaSource(delegate);
323 } else { 340 } else {
324 media_router_ui->InitWithPresentationSessionRequest( 341 media_router_ui->InitWithPresentationSessionRequest(
325 initiator(), delegate, std::move(create_connection_request)); 342 initiator(), delegate, std::move(create_connection_request));
326 } 343 }
327 } 344 }
328 345
329 } // namespace media_router 346 } // namespace media_router
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698