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

Side by Side Diff: chrome/browser/chromeos/external_protocol_dialog.cc

Issue 342040: Enable ExternalProtocolDialog for linux/views (Closed)
Patch Set: fix linux build Created 11 years, 1 month 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
(Empty)
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/chromeos/external_protocol_dialog.h"
6
7 #include "app/l10n_util.h"
8 #include "app/message_box_flags.h"
9 #include "base/histogram.h"
10 #include "base/string_util.h"
11 #include "chrome/browser/external_protocol_handler.h"
12 #include "chrome/browser/tab_contents/tab_contents.h"
13 #include "chrome/browser/tab_contents/tab_contents_view.h"
14 #include "chrome/browser/tab_contents/tab_util.h"
15 #include "googleurl/src/gurl.h"
16 #include "grit/chromium_strings.h"
17 #include "grit/generated_resources.h"
18 #include "views/controls/message_box_view.h"
19 #include "views/window/window.h"
20
21 namespace {
22
23 const int kMessageWidth = 400;
24
25 } // namespace
26
27 ///////////////////////////////////////////////////////////////////////////////
28 // ExternalProtocolHandler
29
30 // static
31 void ExternalProtocolHandler::RunExternalProtocolDialog(
32 const GURL& url, int render_process_host_id, int routing_id) {
33 TabContents* tab_contents = tab_util::GetTabContentsByID(
34 render_process_host_id, routing_id);
35 DCHECK(tab_contents);
36 new ExternalProtocolDialog(tab_contents, url);
37 }
38
39 ///////////////////////////////////////////////////////////////////////////////
40 // ExternalProtocolDialog
41
42 ExternalProtocolDialog::~ExternalProtocolDialog() {
43 }
44
45 //////////////////////////////////////////////////////////////////////////////
46 // ExternalProtocolDialog, views::DialogDelegate implementation:
47
48 int ExternalProtocolDialog::GetDialogButtons() const {
49 return MessageBoxFlags::DIALOGBUTTON_OK;
50 }
51
52 std::wstring ExternalProtocolDialog::GetDialogButtonLabel(
53 MessageBoxFlags::DialogButton button) const {
54 return l10n_util::GetString(IDS_EXTERNAL_PROTOCOL_OK_BUTTON_TEXT);
55 }
56
57 std::wstring ExternalProtocolDialog::GetWindowTitle() const {
58 return l10n_util::GetString(IDS_EXTERNAL_PROTOCOL_TITLE);
59 }
60
61 void ExternalProtocolDialog::DeleteDelegate() {
62 delete this;
63 }
64
65 bool ExternalProtocolDialog::Accept() {
66 if (message_box_view_->IsCheckBoxSelected()) {
67 ExternalProtocolHandler::SetBlockState(
68 scheme_, ExternalProtocolHandler::DONT_BLOCK);
69 }
70 // Returning true closes the dialog.
71 return true;
72 }
73
74 views::View* ExternalProtocolDialog::GetContentsView() {
75 return message_box_view_;
76 }
77
78 ///////////////////////////////////////////////////////////////////////////////
79 // ExternalProtocolDialog, private:
80
81 ExternalProtocolDialog::ExternalProtocolDialog(TabContents* tab_contents,
82 const GURL& url)
83 : creation_time_(base::Time::Now()),
84 scheme_(UTF8ToWide(url.scheme())) {
85 std::wstring message_text = l10n_util::GetStringF(
86 IDS_EXTERNAL_PROTOCOL_INFORMATION,
87 ASCIIToWide(url.scheme() + ":"),
88 ASCIIToWide(url.possibly_invalid_spec())) + L"\n\n";
89
90 message_box_view_ = new MessageBoxView(MessageBoxFlags::kIsConfirmMessageBox,
91 message_text,
92 std::wstring(),
93 kMessageWidth);
94 message_box_view_->SetCheckBoxLabel(
95 l10n_util::GetString(IDS_EXTERNAL_PROTOCOL_CHECKBOX_TEXT));
96
97 gfx::NativeWindow parent_window;
98 if (tab_contents) {
99 parent_window = tab_contents->view()->GetTopLevelNativeWindow();
100 } else {
101 // Dialog is top level if we don't have a tab_contents associated with us.
102 parent_window = NULL;
103 }
104 views::Window::CreateChromeWindow(parent_window, gfx::Rect(), this)->Show();
105 }
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/external_protocol_dialog.h ('k') | chrome/browser/external_protocol_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698