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

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

Issue 2275413002: Make the MediaRouterDialogDelegate set initial dialog size in OSX (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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/ui/cocoa/constrained_window/constrained_window_web_dialog_sheet.mm ('k') | 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 70
71 GURL GetDialogContentURL() const override { 71 GURL GetDialogContentURL() const override {
72 return GURL(chrome::kChromeUIMediaRouterURL); 72 return GURL(chrome::kChromeUIMediaRouterURL);
73 } 73 }
74 74
75 void GetWebUIMessageHandlers( 75 void GetWebUIMessageHandlers(
76 std::vector<WebUIMessageHandler*>* handlers) const override { 76 std::vector<WebUIMessageHandler*>* handlers) const override {
77 // MediaRouterUI adds its own message handlers. 77 // MediaRouterUI adds its own message handlers.
78 } 78 }
79 79
80 void GetDialogSize(gfx::Size* size) const override; 80 void GetDialogSize(gfx::Size* size) const override {
81 DCHECK(size);
82 #if defined(OS_MACOSX)
83 // We need to set the initial size to be positive for OSX, otherwise the
84 // dialog may fail to show.
apacible 2016/09/06 17:24:53 Add a comment mentioning this is done because spec
takumif 2016/09/06 19:01:37 Done.
85 if (size->IsEmpty())
apacible 2016/08/31 18:19:12 I would prefer handling everything on the sheets s
takumif 2016/08/31 22:44:30 I don't think the sheet has enough information to
apacible 2016/09/06 17:24:53 Acknowledged. I don't think having an arbitrary si
86 *size = gfx::Size(kWidth, kMinHeight);
87 #endif
88 // GetDialogSize() is called when the dialog is created or the browser
89 // window resizes. We may want to update the maximum height of the dialog
90 // and scale the WebUI to the new height. |size| is not set (except for in
91 // OSX) because the dialog is auto-resizeable.
92 controller_->UpdateMaxDialogSize();
93 }
81 94
82 std::string GetDialogArgs() const override { 95 std::string GetDialogArgs() const override {
83 return std::string(); 96 return std::string();
84 } 97 }
85 98
86 void OnDialogClosed(const std::string& json_retval) override { 99 void OnDialogClosed(const std::string& json_retval) override {
87 // We don't delete |this| here because this class is owned 100 // We don't delete |this| here because this class is owned
88 // by ConstrainedWebDialogDelegate. 101 // by ConstrainedWebDialogDelegate.
89 if (action_) 102 if (action_)
90 action_->OnPopupHidden(); 103 action_->OnPopupHidden();
91 } 104 }
92 105
93 void OnCloseContents(WebContents* source, bool* out_close_dialog) override { 106 void OnCloseContents(WebContents* source, bool* out_close_dialog) override {
94 if (out_close_dialog) 107 if (out_close_dialog)
95 *out_close_dialog = true; 108 *out_close_dialog = true;
96 } 109 }
97 110
98 bool ShouldShowDialogTitle() const override { 111 bool ShouldShowDialogTitle() const override {
99 return false; 112 return false;
100 } 113 }
101 114
102 private: 115 private:
103 base::WeakPtr<MediaRouterAction> action_; 116 base::WeakPtr<MediaRouterAction> action_;
104 base::WeakPtr<MediaRouterDialogControllerImpl> controller_; 117 base::WeakPtr<MediaRouterDialogControllerImpl> controller_;
105 118
106 DISALLOW_COPY_AND_ASSIGN(MediaRouterDialogDelegate); 119 DISALLOW_COPY_AND_ASSIGN(MediaRouterDialogDelegate);
107 }; 120 };
108 121
109 void MediaRouterDialogDelegate::GetDialogSize(gfx::Size* size) const {
110 DCHECK(size);
111 // GetDialogSize() is called when the browser window resizes. We may want to
112 // update the maximum height of the dialog and scale the WebUI to the new
113 // height. |size| is not set because the dialog is auto-resizeable.
114 controller_->UpdateMaxDialogSize();
115 }
116
117 } // namespace 122 } // namespace
118 123
119 // static 124 // static
120 MediaRouterDialogControllerImpl* 125 MediaRouterDialogControllerImpl*
121 MediaRouterDialogControllerImpl::GetOrCreateForWebContents( 126 MediaRouterDialogControllerImpl::GetOrCreateForWebContents(
122 WebContents* web_contents) { 127 WebContents* web_contents) {
123 DCHECK(web_contents); 128 DCHECK(web_contents);
124 // This call does nothing if the controller already exists. 129 // This call does nothing if the controller already exists.
125 MediaRouterDialogControllerImpl::CreateForWebContents(web_contents); 130 MediaRouterDialogControllerImpl::CreateForWebContents(web_contents);
126 return MediaRouterDialogControllerImpl::FromWebContents(web_contents); 131 return MediaRouterDialogControllerImpl::FromWebContents(web_contents);
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 ->GetWeakPtr(); 324 ->GetWeakPtr();
320 if (!create_connection_request.get()) { 325 if (!create_connection_request.get()) {
321 media_router_ui->InitWithDefaultMediaSource(delegate); 326 media_router_ui->InitWithDefaultMediaSource(delegate);
322 } else { 327 } else {
323 media_router_ui->InitWithPresentationSessionRequest( 328 media_router_ui->InitWithPresentationSessionRequest(
324 initiator(), delegate, std::move(create_connection_request)); 329 initiator(), delegate, std::move(create_connection_request));
325 } 330 }
326 } 331 }
327 332
328 } // namespace media_router 333 } // namespace media_router
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/constrained_window/constrained_window_web_dialog_sheet.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698