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

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

Issue 9030032: Get rid of a bunch of tab_contents.h includes from chrome. These are all trivial changes to use W... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix cros Created 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/chromeos/external_protocol_dialog.h" 5 #include "chrome/browser/chromeos/external_protocol_dialog.h"
6 6
7 #include "base/metrics/histogram.h" 7 #include "base/metrics/histogram.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/external_protocol/external_protocol_handler.h" 10 #include "chrome/browser/external_protocol/external_protocol_handler.h"
11 #include "chrome/browser/tab_contents/tab_util.h" 11 #include "chrome/browser/tab_contents/tab_util.h"
12 #include "chrome/browser/ui/dialog_style.h" 12 #include "chrome/browser/ui/dialog_style.h"
13 #include "chrome/browser/ui/views/window.h" 13 #include "chrome/browser/ui/views/window.h"
14 #include "content/browser/tab_contents/tab_contents.h"
15 #include "content/browser/tab_contents/tab_contents_view.h" 14 #include "content/browser/tab_contents/tab_contents_view.h"
15 #include "content/public/browser/web_contents.h"
16 #include "googleurl/src/gurl.h" 16 #include "googleurl/src/gurl.h"
17 #include "grit/chromium_strings.h" 17 #include "grit/chromium_strings.h"
18 #include "grit/generated_resources.h" 18 #include "grit/generated_resources.h"
19 #include "ui/base/l10n/l10n_util.h" 19 #include "ui/base/l10n/l10n_util.h"
20 #include "ui/base/text/text_elider.h" 20 #include "ui/base/text/text_elider.h"
21 #include "ui/views/controls/message_box_view.h" 21 #include "ui/views/controls/message_box_view.h"
22 #include "ui/views/widget/widget.h" 22 #include "ui/views/widget/widget.h"
23 23
24 using content::WebContents;
25
24 namespace { 26 namespace {
25 27
26 const int kMessageWidth = 400; 28 const int kMessageWidth = 400;
27 29
28 } // namespace 30 } // namespace
29 31
30 /////////////////////////////////////////////////////////////////////////////// 32 ///////////////////////////////////////////////////////////////////////////////
31 // ExternalProtocolHandler 33 // ExternalProtocolHandler
32 34
33 // static 35 // static
34 void ExternalProtocolHandler::RunExternalProtocolDialog( 36 void ExternalProtocolHandler::RunExternalProtocolDialog(
35 const GURL& url, int render_process_host_id, int routing_id) { 37 const GURL& url, int render_process_host_id, int routing_id) {
36 TabContents* tab_contents = tab_util::GetTabContentsByID( 38 WebContents* web_contents = tab_util::GetWebContentsByID(
37 render_process_host_id, routing_id); 39 render_process_host_id, routing_id);
38 DCHECK(tab_contents); 40 DCHECK(web_contents);
39 new ExternalProtocolDialog(tab_contents, url); 41 new ExternalProtocolDialog(web_contents, url);
40 } 42 }
41 43
42 /////////////////////////////////////////////////////////////////////////////// 44 ///////////////////////////////////////////////////////////////////////////////
43 // ExternalProtocolDialog 45 // ExternalProtocolDialog
44 46
45 ExternalProtocolDialog::~ExternalProtocolDialog() { 47 ExternalProtocolDialog::~ExternalProtocolDialog() {
46 } 48 }
47 49
48 ////////////////////////////////////////////////////////////////////////////// 50 //////////////////////////////////////////////////////////////////////////////
49 // ExternalProtocolDialog, views::DialogDelegate implementation: 51 // ExternalProtocolDialog, views::DialogDelegate implementation:
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 return message_box_view_->GetWidget(); 88 return message_box_view_->GetWidget();
87 } 89 }
88 90
89 views::Widget* ExternalProtocolDialog::GetWidget() { 91 views::Widget* ExternalProtocolDialog::GetWidget() {
90 return message_box_view_->GetWidget(); 92 return message_box_view_->GetWidget();
91 } 93 }
92 94
93 /////////////////////////////////////////////////////////////////////////////// 95 ///////////////////////////////////////////////////////////////////////////////
94 // ExternalProtocolDialog, private: 96 // ExternalProtocolDialog, private:
95 97
96 ExternalProtocolDialog::ExternalProtocolDialog(TabContents* tab_contents, 98 ExternalProtocolDialog::ExternalProtocolDialog(WebContents* web_contents,
97 const GURL& url) 99 const GURL& url)
98 : creation_time_(base::TimeTicks::Now()), 100 : creation_time_(base::TimeTicks::Now()),
99 scheme_(url.scheme()) { 101 scheme_(url.scheme()) {
100 const int kMaxUrlWithoutSchemeSize = 256; 102 const int kMaxUrlWithoutSchemeSize = 256;
101 string16 elided_url_without_scheme; 103 string16 elided_url_without_scheme;
102 ui::ElideString(ASCIIToUTF16(url.possibly_invalid_spec()), 104 ui::ElideString(ASCIIToUTF16(url.possibly_invalid_spec()),
103 kMaxUrlWithoutSchemeSize, &elided_url_without_scheme); 105 kMaxUrlWithoutSchemeSize, &elided_url_without_scheme);
104 106
105 string16 message_text = l10n_util::GetStringFUTF16( 107 string16 message_text = l10n_util::GetStringFUTF16(
106 IDS_EXTERNAL_PROTOCOL_INFORMATION, 108 IDS_EXTERNAL_PROTOCOL_INFORMATION,
107 ASCIIToUTF16(url.scheme() + ":"), 109 ASCIIToUTF16(url.scheme() + ":"),
108 elided_url_without_scheme) + ASCIIToUTF16("\n\n"); 110 elided_url_without_scheme) + ASCIIToUTF16("\n\n");
109 111
110 message_box_view_ = new views::MessageBoxView( 112 message_box_view_ = new views::MessageBoxView(
111 views::MessageBoxView::NO_OPTIONS, 113 views::MessageBoxView::NO_OPTIONS,
112 message_text, 114 message_text,
113 string16(), 115 string16(),
114 kMessageWidth); 116 kMessageWidth);
115 message_box_view_->SetCheckBoxLabel( 117 message_box_view_->SetCheckBoxLabel(
116 l10n_util::GetStringUTF16(IDS_EXTERNAL_PROTOCOL_CHECKBOX_TEXT)); 118 l10n_util::GetStringUTF16(IDS_EXTERNAL_PROTOCOL_CHECKBOX_TEXT));
117 119
118 gfx::NativeWindow parent_window; 120 gfx::NativeWindow parent_window;
119 if (tab_contents) { 121 if (web_contents) {
120 parent_window = tab_contents->GetView()->GetTopLevelNativeWindow(); 122 parent_window = web_contents->GetView()->GetTopLevelNativeWindow();
121 } else { 123 } else {
122 // Dialog is top level if we don't have a tab_contents associated with us. 124 // Dialog is top level if we don't have a web_contents associated with us.
123 parent_window = NULL; 125 parent_window = NULL;
124 } 126 }
125 browser::CreateViewsWindow(parent_window, this, STYLE_GENERIC)->Show(); 127 browser::CreateViewsWindow(parent_window, this, STYLE_GENERIC)->Show();
126 } 128 }
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/external_protocol_dialog.h ('k') | chrome/browser/chromeos/login/html_page_screen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698