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

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: Address Jennifer's comment 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
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 // When WebDialogConstrainedWindowSheet::updateSheetPosition() calls
84 // GetDialogSize() in OSX, we need to set |size| to be non-empty. Otherwise
85 // the dialog may fail to show.
86 if (size->IsEmpty())
87 *size = gfx::Size(kWidth, kMinHeight);
88 #endif
89 // GetDialogSize() is called when the dialog is created or the browser
90 // window resizes. We may want to update the maximum height of the dialog
91 // and scale the WebUI to the new height. |size| is not set (except for in
92 // OSX) because the dialog is auto-resizeable.
93 controller_->UpdateMaxDialogSize();
94 }
81 95
82 std::string GetDialogArgs() const override { 96 std::string GetDialogArgs() const override {
83 return std::string(); 97 return std::string();
84 } 98 }
85 99
86 void OnDialogClosed(const std::string& json_retval) override { 100 void OnDialogClosed(const std::string& json_retval) override {
87 // We don't delete |this| here because this class is owned 101 // We don't delete |this| here because this class is owned
88 // by ConstrainedWebDialogDelegate. 102 // by ConstrainedWebDialogDelegate.
89 if (action_) 103 if (action_)
90 action_->OnPopupHidden(); 104 action_->OnPopupHidden();
91 } 105 }
92 106
93 void OnCloseContents(WebContents* source, bool* out_close_dialog) override { 107 void OnCloseContents(WebContents* source, bool* out_close_dialog) override {
94 if (out_close_dialog) 108 if (out_close_dialog)
95 *out_close_dialog = true; 109 *out_close_dialog = true;
96 } 110 }
97 111
98 bool ShouldShowDialogTitle() const override { 112 bool ShouldShowDialogTitle() const override {
99 return false; 113 return false;
100 } 114 }
101 115
102 private: 116 private:
103 base::WeakPtr<MediaRouterAction> action_; 117 base::WeakPtr<MediaRouterAction> action_;
104 base::WeakPtr<MediaRouterDialogControllerImpl> controller_; 118 base::WeakPtr<MediaRouterDialogControllerImpl> controller_;
105 119
106 DISALLOW_COPY_AND_ASSIGN(MediaRouterDialogDelegate); 120 DISALLOW_COPY_AND_ASSIGN(MediaRouterDialogDelegate);
107 }; 121 };
108 122
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 123 } // namespace
118 124
119 // static 125 // static
120 MediaRouterDialogControllerImpl* 126 MediaRouterDialogControllerImpl*
121 MediaRouterDialogControllerImpl::GetOrCreateForWebContents( 127 MediaRouterDialogControllerImpl::GetOrCreateForWebContents(
122 WebContents* web_contents) { 128 WebContents* web_contents) {
123 DCHECK(web_contents); 129 DCHECK(web_contents);
124 // This call does nothing if the controller already exists. 130 // This call does nothing if the controller already exists.
125 MediaRouterDialogControllerImpl::CreateForWebContents(web_contents); 131 MediaRouterDialogControllerImpl::CreateForWebContents(web_contents);
126 return MediaRouterDialogControllerImpl::FromWebContents(web_contents); 132 return MediaRouterDialogControllerImpl::FromWebContents(web_contents);
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 ->GetWeakPtr(); 325 ->GetWeakPtr();
320 if (!create_connection_request.get()) { 326 if (!create_connection_request.get()) {
321 media_router_ui->InitWithDefaultMediaSource(delegate); 327 media_router_ui->InitWithDefaultMediaSource(delegate);
322 } else { 328 } else {
323 media_router_ui->InitWithPresentationSessionRequest( 329 media_router_ui->InitWithPresentationSessionRequest(
324 initiator(), delegate, std::move(create_connection_request)); 330 initiator(), delegate, std::move(create_connection_request));
325 } 331 }
326 } 332 }
327 333
328 } // namespace media_router 334 } // namespace media_router
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698