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

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

Issue 2332693003: Show media router toolbar icon ephemerally for active local routes and issues (Closed)
Patch Set: Address Derek'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
« no previous file with comments | « chrome/browser/ui/views/media_router/media_router_ui_browsertest.cc ('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 <memory>
7 #include <string> 8 #include <string>
8 #include <utility> 9 #include <utility>
9 #include <vector> 10 #include <vector>
10 11
11 #include "base/macros.h" 12 #include "base/macros.h"
12 #include "base/trace_event/trace_event.h" 13 #include "base/trace_event/trace_event.h"
13 #include "build/build_config.h" 14 #include "build/build_config.h"
14 #include "chrome/browser/media/router/presentation_service_delegate_impl.h" 15 #include "chrome/browser/media/router/presentation_service_delegate_impl.h"
15 #include "chrome/browser/profiles/profile.h" 16 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/browser/ui/browser_finder.h" 17 #include "chrome/browser/ui/browser_finder.h"
(...skipping 28 matching lines...) Expand all
45 namespace { 46 namespace {
46 47
47 constexpr const int kMaxHeight = 2000; 48 constexpr const int kMaxHeight = 2000;
48 constexpr const int kMinHeight = 80; 49 constexpr const int kMinHeight = 80;
49 constexpr const int kWidth = 340; 50 constexpr const int kWidth = 340;
50 51
51 // WebDialogDelegate that specifies what the Media Router dialog 52 // WebDialogDelegate that specifies what the Media Router dialog
52 // will look like. 53 // will look like.
53 class MediaRouterDialogDelegate : public WebDialogDelegate { 54 class MediaRouterDialogDelegate : public WebDialogDelegate {
54 public: 55 public:
55 MediaRouterDialogDelegate(base::WeakPtr<MediaRouterAction> action, 56 explicit MediaRouterDialogDelegate(
56 const base::WeakPtr<MediaRouterDialogControllerImpl>& controller) 57 const base::WeakPtr<MediaRouterDialogControllerImpl>& controller)
57 : action_(action), 58 : controller_(controller) {}
58 controller_(controller) {}
59 ~MediaRouterDialogDelegate() override {} 59 ~MediaRouterDialogDelegate() override {}
60 60
61 // WebDialogDelegate implementation. 61 // WebDialogDelegate implementation.
62 ui::ModalType GetDialogModalType() const override { 62 ui::ModalType GetDialogModalType() const override {
63 // Not used, returning dummy value. 63 // Not used, returning dummy value.
64 return ui::MODAL_TYPE_WINDOW; 64 return ui::MODAL_TYPE_WINDOW;
65 } 65 }
66 66
67 base::string16 GetDialogTitle() const override { 67 base::string16 GetDialogTitle() const override {
68 return base::string16(); 68 return base::string16();
(...skipping 10 matching lines...) Expand all
79 79
80 void GetDialogSize(gfx::Size* size) const override; 80 void GetDialogSize(gfx::Size* size) const override;
81 81
82 std::string GetDialogArgs() const override { 82 std::string GetDialogArgs() const override {
83 return std::string(); 83 return std::string();
84 } 84 }
85 85
86 void OnDialogClosed(const std::string& json_retval) override { 86 void OnDialogClosed(const std::string& json_retval) override {
87 // We don't delete |this| here because this class is owned 87 // We don't delete |this| here because this class is owned
88 // by ConstrainedWebDialogDelegate. 88 // by ConstrainedWebDialogDelegate.
89 if (action_)
90 action_->OnPopupHidden();
91 } 89 }
92 90
93 void OnCloseContents(WebContents* source, bool* out_close_dialog) override { 91 void OnCloseContents(WebContents* source, bool* out_close_dialog) override {
94 if (out_close_dialog) 92 if (out_close_dialog)
95 *out_close_dialog = true; 93 *out_close_dialog = true;
96 } 94 }
97 95
98 bool ShouldShowDialogTitle() const override { 96 bool ShouldShowDialogTitle() const override {
99 return false; 97 return false;
100 } 98 }
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 base::Time dialog_creation_time = base::Time::Now(); 225 base::Time dialog_creation_time = base::Time::Now();
228 TRACE_EVENT_NESTABLE_ASYNC_BEGIN0("media_router", "UI", initiator()); 226 TRACE_EVENT_NESTABLE_ASYNC_BEGIN0("media_router", "UI", initiator());
229 227
230 Profile* profile = 228 Profile* profile =
231 Profile::FromBrowserContext(initiator()->GetBrowserContext()); 229 Profile::FromBrowserContext(initiator()->GetBrowserContext());
232 DCHECK(profile); 230 DCHECK(profile);
233 231
234 // |web_dialog_delegate|'s owner is |constrained_delegate|. 232 // |web_dialog_delegate|'s owner is |constrained_delegate|.
235 // |constrained_delegate| is owned by the parent |views::View|. 233 // |constrained_delegate| is owned by the parent |views::View|.
236 WebDialogDelegate* web_dialog_delegate = 234 WebDialogDelegate* web_dialog_delegate =
237 new MediaRouterDialogDelegate(action_, weak_ptr_factory_.GetWeakPtr()); 235 new MediaRouterDialogDelegate(weak_ptr_factory_.GetWeakPtr());
238 236
239 // |ShowConstrainedWebDialogWithAutoResize()| will end up creating 237 // |ShowConstrainedWebDialogWithAutoResize()| will end up creating
240 // ConstrainedWebDialogDelegateViewViews containing a WebContents containing 238 // ConstrainedWebDialogDelegateViewViews containing a WebContents containing
241 // the MediaRouterUI, using the provided |web_dialog_delegate|. Then, the 239 // the MediaRouterUI, using the provided |web_dialog_delegate|. Then, the
242 // view is shown as a modal dialog constrained to the |initiator| WebContents. 240 // view is shown as a modal dialog constrained to the |initiator| WebContents.
243 // The dialog will resize between the given minimum and maximum size bounds 241 // The dialog will resize between the given minimum and maximum size bounds
244 // based on the currently rendered contents. 242 // based on the currently rendered contents.
245 ConstrainedWebDialogDelegate* constrained_delegate = 243 ConstrainedWebDialogDelegate* constrained_delegate =
246 ShowConstrainedWebDialogWithAutoResize( 244 ShowConstrainedWebDialogWithAutoResize(
247 profile, web_dialog_delegate, initiator(), 245 profile, web_dialog_delegate, initiator(),
(...skipping 12 matching lines...) Expand all
260 DCHECK(media_router_ui); 258 DCHECK(media_router_ui);
261 media_router_ui->SetUIInitializationTimer(dialog_creation_time); 259 media_router_ui->SetUIInitializationTimer(dialog_creation_time);
262 } 260 }
263 261
264 media_router_dialog_pending_ = true; 262 media_router_dialog_pending_ = true;
265 263
266 dialog_observer_.reset(new DialogWebContentsObserver( 264 dialog_observer_.reset(new DialogWebContentsObserver(
267 media_router_dialog, this)); 265 media_router_dialog, this));
268 266
269 if (action_) 267 if (action_)
270 action_->OnPopupShown(); 268 action_->OnDialogShown();
271 } 269 }
272 270
273 void MediaRouterDialogControllerImpl::Reset() { 271 void MediaRouterDialogControllerImpl::Reset() {
274 MediaRouterDialogController::Reset(); 272 MediaRouterDialogController::Reset();
275 dialog_observer_.reset(); 273 dialog_observer_.reset();
274 if (action_)
275 action_->OnDialogHidden();
276 } 276 }
277 277
278 void MediaRouterDialogControllerImpl::OnDialogNavigated( 278 void MediaRouterDialogControllerImpl::OnDialogNavigated(
279 const content::LoadCommittedDetails& details) { 279 const content::LoadCommittedDetails& details) {
280 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 280 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
281 WebContents* media_router_dialog = GetMediaRouterDialog(); 281 WebContents* media_router_dialog = GetMediaRouterDialog();
282 CHECK(media_router_dialog); 282 CHECK(media_router_dialog);
283 ui::PageTransition transition_type = details.entry->GetTransitionType(); 283 ui::PageTransition transition_type = details.entry->GetTransitionType();
284 content::NavigationType nav_type = details.type; 284 content::NavigationType nav_type = details.type;
285 285
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 ->GetWeakPtr(); 318 ->GetWeakPtr();
319 if (!create_connection_request.get()) { 319 if (!create_connection_request.get()) {
320 media_router_ui->InitWithDefaultMediaSource(delegate); 320 media_router_ui->InitWithDefaultMediaSource(delegate);
321 } else { 321 } else {
322 media_router_ui->InitWithPresentationSessionRequest( 322 media_router_ui->InitWithPresentationSessionRequest(
323 initiator(), delegate, std::move(create_connection_request)); 323 initiator(), delegate, std::move(create_connection_request));
324 } 324 }
325 } 325 }
326 326
327 } // namespace media_router 327 } // namespace media_router
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/media_router/media_router_ui_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698