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

Side by Side Diff: chrome/browser/ui/views/external_protocol_dialog.cc

Issue 2632653002: MacViews: Enable views based External Protocol dialog behind secondary-ui-md flag. (Closed)
Patch Set: Address review. Created 3 years, 11 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/external_protocol_dialog_views_mac.mm ('k') | chrome/test/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/ui/views/external_protocol_dialog.h" 5 #include "chrome/browser/ui/views/external_protocol_dialog.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/metrics/histogram_macros.h" 9 #include "base/metrics/histogram_macros.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
11 #include "chrome/browser/external_protocol/external_protocol_handler.h" 11 #include "chrome/browser/external_protocol/external_protocol_handler.h"
12 #include "chrome/browser/tab_contents/tab_util.h" 12 #include "chrome/browser/tab_contents/tab_util.h"
13 #include "chrome/browser/ui/external_protocol_dialog_delegate.h" 13 #include "chrome/browser/ui/external_protocol_dialog_delegate.h"
14 #include "chrome/grit/generated_resources.h" 14 #include "chrome/grit/generated_resources.h"
15 #include "components/constrained_window/constrained_window_views.h" 15 #include "components/constrained_window/constrained_window_views.h"
16 #include "content/public/browser/web_contents.h" 16 #include "content/public/browser/web_contents.h"
17 #include "ui/base/l10n/l10n_util.h" 17 #include "ui/base/l10n/l10n_util.h"
18 #include "ui/base/ui_features.h"
18 #include "ui/gfx/text_elider.h" 19 #include "ui/gfx/text_elider.h"
19 #include "ui/views/controls/message_box_view.h" 20 #include "ui/views/controls/message_box_view.h"
20 #include "ui/views/widget/widget.h" 21 #include "ui/views/widget/widget.h"
21 22
22 using content::WebContents; 23 using content::WebContents;
23 24
24 namespace { 25 namespace {
25 26
26 const int kMessageWidth = 400; 27 const int kMessageWidth = 400;
27 28
28 } // namespace 29 } // namespace
29 30
30 /////////////////////////////////////////////////////////////////////////////// 31 ///////////////////////////////////////////////////////////////////////////////
31 // ExternalProtocolHandler 32 // ExternalProtocolHandler
32 33
34 #if !defined(OS_MACOSX) || BUILDFLAG(MAC_VIEWS_BROWSER)
35 // This should be kept in sync with RunExternalProtocolDialogViews in
msw 2017/01/24 08:39:37 It'd be nice to avoid this duplication, is it toug
karandeepb 2017/01/24 08:43:57 It isn't actually. The rationale for this is that
36 // external_protocol_dialog_views_mac.mm.
33 // static 37 // static
34 void ExternalProtocolHandler::RunExternalProtocolDialog( 38 void ExternalProtocolHandler::RunExternalProtocolDialog(
35 const GURL& url, int render_process_host_id, int routing_id, 39 const GURL& url, int render_process_host_id, int routing_id,
36 ui::PageTransition page_transition, bool has_user_gesture) { 40 ui::PageTransition page_transition, bool has_user_gesture) {
37 std::unique_ptr<ExternalProtocolDialogDelegate> delegate( 41 std::unique_ptr<ExternalProtocolDialogDelegate> delegate(
38 new ExternalProtocolDialogDelegate(url, render_process_host_id, 42 new ExternalProtocolDialogDelegate(url, render_process_host_id,
39 routing_id)); 43 routing_id));
40 if (delegate->program_name().empty()) { 44 if (delegate->program_name().empty()) {
41 // ShellExecute won't do anything. Don't bother warning the user. 45 // ShellExecute won't do anything. Don't bother warning the user.
42 return; 46 return;
43 } 47 }
44 48
45 // Windowing system takes ownership. 49 // Windowing system takes ownership.
46 new ExternalProtocolDialog(std::move(delegate), render_process_host_id, 50 new ExternalProtocolDialog(std::move(delegate), render_process_host_id,
47 routing_id); 51 routing_id);
48 } 52 }
53 #endif // !OS_MACOSX || MAC_VIEWS_BROWSER
49 54
50 /////////////////////////////////////////////////////////////////////////////// 55 ///////////////////////////////////////////////////////////////////////////////
51 // ExternalProtocolDialog 56 // ExternalProtocolDialog
52 57
53 ExternalProtocolDialog::~ExternalProtocolDialog() { 58 ExternalProtocolDialog::~ExternalProtocolDialog() {
54 } 59 }
55 60
56 ////////////////////////////////////////////////////////////////////////////// 61 //////////////////////////////////////////////////////////////////////////////
57 // ExternalProtocolDialog, views::DialogDelegate implementation: 62 // ExternalProtocolDialog, views::DialogDelegate implementation:
58 63
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 message_box_view_ = new views::MessageBoxView(params); 147 message_box_view_ = new views::MessageBoxView(params);
143 message_box_view_->SetCheckBoxLabel(delegate_->GetCheckboxText()); 148 message_box_view_->SetCheckBoxLabel(delegate_->GetCheckboxText());
144 149
145 WebContents* web_contents = tab_util::GetWebContentsByID( 150 WebContents* web_contents = tab_util::GetWebContentsByID(
146 render_process_host_id_, routing_id_); 151 render_process_host_id_, routing_id_);
147 // Only launch the dialog if there is a web contents associated with the 152 // Only launch the dialog if there is a web contents associated with the
148 // request. 153 // request.
149 if (web_contents) 154 if (web_contents)
150 constrained_window::ShowWebModalDialogViews(this, web_contents); 155 constrained_window::ShowWebModalDialogViews(this, web_contents);
151 } 156 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/external_protocol_dialog_views_mac.mm ('k') | chrome/test/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698