diff options
-rw-r--r-- | chrome/app/chromium_strings.grd | 15 | ||||
-rw-r--r-- | chrome/app/generated_resources.grd | 42 | ||||
-rw-r--r-- | chrome/app/google_chrome_strings.grd | 15 | ||||
-rw-r--r-- | chrome/browser/chromeos/external_protocol_dialog.cc | 105 | ||||
-rw-r--r-- | chrome/browser/chromeos/external_protocol_dialog.h | 51 | ||||
-rw-r--r-- | chrome/browser/external_protocol_handler.cc | 4 | ||||
-rw-r--r-- | chrome/browser/views/external_protocol_dialog.cc | 3 | ||||
-rw-r--r-- | chrome/browser/views/external_protocol_dialog.h | 6 | ||||
-rwxr-xr-x | chrome/chrome.gyp | 8 |
9 files changed, 215 insertions, 34 deletions
diff --git a/chrome/app/chromium_strings.grd b/chrome/app/chromium_strings.grd index f4a10e2..0337d28 100644 --- a/chrome/app/chromium_strings.grd +++ b/chrome/app/chromium_strings.grd @@ -127,7 +127,7 @@ be available for now. --> <message name="IDS_PRODUCT_NAME" desc="The Chrome application name"> Chromium </message> - <if expr="pp_ifdef('chromeos') or pp_ifdef('toolkit_views')"> + <if expr="pp_ifdef('chromeos')"> <message name="IDS_PRODUCT_OS_NAME" desc="The Chrome OS application name"> Chromium OS </message> @@ -236,9 +236,16 @@ be available for now. --> desc="Title for the hard-coded thumbnail that represents the Google Chrome Welcome page. This is used on the NTP when there aren't enough thumbnails to show."> Welcome to Chromium </message> - <message name="IDS_EXTERNAL_PROTOCOL_INFORMATION" desc="General information about what Chrome is trying to do when opening this external protocol"> - Chromium needs to launch an external application to handle <ph name="SCHEME">$1<ex>acrobat:</ex></ph> links. The link requested is <ph name="PROTOLINK">$2<ex>acrobat:yourpdf</ex></ph>. - </message> + <if expr="not pp_ifdef('chromeos')"> + <message name="IDS_EXTERNAL_PROTOCOL_INFORMATION" desc="General information about what Chrome is trying to do when opening this external protocol"> + Chromium needs to launch an external application to handle <ph name="SCHEME">$1<ex>acrobat:</ex></ph> links. The link requested is <ph name="PROTOLINK">$2<ex>acrobat:yourpdf</ex></ph>. + </message> + </if> + <if expr="pp_ifdef('chromeos')"> + <message name="IDS_EXTERNAL_PROTOCOL_INFORMATION" desc="General information about what Chrome is trying to do when opening this external protocol"> + Chromium OS does not support launching an external application to handle <ph name="SCHEME">$1<ex>acrobat:</ex></ph> links. The link requested is <ph name="PROTOLINK">$2<ex>acrobat:yourpdf</ex></ph>. + </message> + </if> <!-- Strings used to warn that an OS is not supported --> <message name="IDS_UNSUPPORTED_OS_WIN2000" desc="The text used to warn the user that Windows 2000 is not supported"> Chromium does not support Windows 2000. Some features may not work. diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index f086093..1dd6357 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd @@ -4905,21 +4905,31 @@ Keep your key file in a safe place. You will need it to create new versions of y <message name="IDS_EXTERNAL_PROTOCOL_TITLE" desc="External Protocol Dialog Title"> External Protocol Request </message> - <message name="IDS_EXTERNAL_PROTOCOL_OK_BUTTON_TEXT" desc="Button in External Protocol Dialog that launches the application associated with the protocol"> - Launch Application - </message> - <message name="IDS_EXTERNAL_PROTOCOL_CANCEL_BUTTON_TEXT" desc="Button in External Protocol Dialog that cancels the application launch"> - Do Nothing - </message> - <message name="IDS_EXTERNAL_PROTOCOL_APPLICATION_TO_LAUNCH" desc="Information about the application being launched by the external protocol"> - The following application will be launched if you accept this request:\n\n <ph name="APPLICATION">$1<ex>C:\Program Files\Adobe\Reader 8.0\Reader\AcroRd32.exe /u "%1"</ex></ph> - </message> - <message name="IDS_EXTERNAL_PROTOCOL_WARNING" desc="Warn user about external protocols."> - If you did not initiate this request, it may represent an attempted attack on your system. Unless you took an explicit action to initiate this request, you should press Cancel. - </message> - <message name="IDS_EXTERNAL_PROTOCOL_CHECKBOX_TEXT" desc="Checkbox to remember users decision."> - Remember my choice for all links of this type. - </message> + <if expr="not pp_ifdef('chromeos')"> + <message name="IDS_EXTERNAL_PROTOCOL_OK_BUTTON_TEXT" desc="Button in External Protocol Dialog that launches the application associated with the protocol"> + Launch Application + </message> + <message name="IDS_EXTERNAL_PROTOCOL_CANCEL_BUTTON_TEXT" desc="Button in External Protocol Dialog that cancels the application launch"> + Do Nothing + </message> + <message name="IDS_EXTERNAL_PROTOCOL_APPLICATION_TO_LAUNCH" desc="Information about the application being launched by the external protocol"> + The following application will be launched if you accept this request:\n\n <ph name="APPLICATION">$1<ex>C:\Program Files\Adobe\Reader 8.0\Reader\AcroRd32.exe /u "%1"</ex></ph> + </message> + <message name="IDS_EXTERNAL_PROTOCOL_WARNING" desc="Warn user about external protocols."> + If you did not initiate this request, it may represent an attempted attack on your system. Unless you took an explicit action to initiate this request, you should press Cancel. + </message> + <message name="IDS_EXTERNAL_PROTOCOL_CHECKBOX_TEXT" desc="Checkbox to remember users decision."> + Remember my choice for all links of this type. + </message> + </if> + <if expr="pp_ifdef('chromeos')"> + <message name="IDS_EXTERNAL_PROTOCOL_OK_BUTTON_TEXT" desc="Button in External Protocol Dialog that closes the dialog"> + Close + </message> + <message name="IDS_EXTERNAL_PROTOCOL_CHECKBOX_TEXT" desc="Checkbox to remember users decision."> + Never show the dialog again for all links of this type. + </message> + </if> <!-- Shortcut Modifiers --> <message name="IDS_CONTROL_MODIFIER" desc="Control key shortcut modifier"> @@ -5747,7 +5757,7 @@ Keep your key file in a safe place. You will need it to create new versions of y </if> <!-- Chrome OS Strings --> - <if expr="pp_ifdef('chromeos') or pp_ifdef('toolkit_views')"> + <if expr="pp_ifdef('chromeos')"> <message name="IDS_OPTIONS_SETTINGS_SECTION_TITLE_DATETIME"> Date and Time </message> diff --git a/chrome/app/google_chrome_strings.grd b/chrome/app/google_chrome_strings.grd index 6ef50a93..d7177b3 100644 --- a/chrome/app/google_chrome_strings.grd +++ b/chrome/app/google_chrome_strings.grd @@ -177,7 +177,7 @@ Chrome supports. --> <message name="IDS_PRODUCT_NAME" desc="The Chrome application name"> Google Chrome </message> - <if expr="pp_ifdef('chromeos') or pp_ifdef('toolkit_views')"> + <if expr="pp_ifdef('chromeos')"> <message name="IDS_PRODUCT_OS_NAME" desc="The Chrome OS application name"> Google Chrome OS </message> @@ -286,9 +286,16 @@ Chrome supports. --> desc="Title for the hard-coded thumbnail that represents the Google Chrome Welcome page. This is used on the NTP when there aren't enough thumbnails to show."> Welcome to Google Chrome </message> - <message name="IDS_EXTERNAL_PROTOCOL_INFORMATION" desc="General information about what Chrome is trying to do when opening this external protocol"> - Google Chrome needs to launch an external application to handle <ph name="SCHEME">$1<ex>acrobat:</ex></ph> links. The link requested is <ph name="PROTOLINK">$2<ex>acrobat:yourpdf</ex></ph>. - </message> + <if expr="not pp_ifdef('chromeos')"> + <message name="IDS_EXTERNAL_PROTOCOL_INFORMATION" desc="General information about what Chrome is trying to do when opening this external protocol"> + Google Chrome needs to launch an external application to handle <ph name="SCHEME">$1<ex>acrobat:</ex></ph> links. The link requested is <ph name="PROTOLINK">$2<ex>acrobat:yourpdf</ex></ph>. + </message> + </if> + <if expr="pp_ifdef('chromeos')"> + <message name="IDS_EXTERNAL_PROTOCOL_INFORMATION" desc="General information about what Chrome is trying to do when opening this external protocol"> + Google ChromeOS does not support launching an external application to handle <ph name="SCHEME">$1<ex>acrobat:</ex></ph> links. The link requested is <ph name="PROTOLINK">$2<ex>acrobat:yourpdf</ex></ph>. + </message> + </if> <!-- Strings used to warn that an OS is not supported --> <message name="IDS_UNSUPPORTED_OS_WIN2000" desc="The text used to warn the user that Windows 2000 is not supported"> Google Chrome does not support Windows 2000. Some features may not work. diff --git a/chrome/browser/chromeos/external_protocol_dialog.cc b/chrome/browser/chromeos/external_protocol_dialog.cc new file mode 100644 index 0000000..faeff75 --- /dev/null +++ b/chrome/browser/chromeos/external_protocol_dialog.cc @@ -0,0 +1,105 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/chromeos/external_protocol_dialog.h" + +#include "app/l10n_util.h" +#include "app/message_box_flags.h" +#include "base/histogram.h" +#include "base/string_util.h" +#include "chrome/browser/external_protocol_handler.h" +#include "chrome/browser/tab_contents/tab_contents.h" +#include "chrome/browser/tab_contents/tab_contents_view.h" +#include "chrome/browser/tab_contents/tab_util.h" +#include "googleurl/src/gurl.h" +#include "grit/chromium_strings.h" +#include "grit/generated_resources.h" +#include "views/controls/message_box_view.h" +#include "views/window/window.h" + +namespace { + +const int kMessageWidth = 400; + +} // namespace + +/////////////////////////////////////////////////////////////////////////////// +// ExternalProtocolHandler + +// static +void ExternalProtocolHandler::RunExternalProtocolDialog( + const GURL& url, int render_process_host_id, int routing_id) { + TabContents* tab_contents = tab_util::GetTabContentsByID( + render_process_host_id, routing_id); + DCHECK(tab_contents); + new ExternalProtocolDialog(tab_contents, url); +} + +/////////////////////////////////////////////////////////////////////////////// +// ExternalProtocolDialog + +ExternalProtocolDialog::~ExternalProtocolDialog() { +} + +////////////////////////////////////////////////////////////////////////////// +// ExternalProtocolDialog, views::DialogDelegate implementation: + +int ExternalProtocolDialog::GetDialogButtons() const { + return MessageBoxFlags::DIALOGBUTTON_OK; +} + +std::wstring ExternalProtocolDialog::GetDialogButtonLabel( + MessageBoxFlags::DialogButton button) const { + return l10n_util::GetString(IDS_EXTERNAL_PROTOCOL_OK_BUTTON_TEXT); +} + +std::wstring ExternalProtocolDialog::GetWindowTitle() const { + return l10n_util::GetString(IDS_EXTERNAL_PROTOCOL_TITLE); +} + +void ExternalProtocolDialog::DeleteDelegate() { + delete this; +} + +bool ExternalProtocolDialog::Accept() { + if (message_box_view_->IsCheckBoxSelected()) { + ExternalProtocolHandler::SetBlockState( + scheme_, ExternalProtocolHandler::DONT_BLOCK); + } + // Returning true closes the dialog. + return true; +} + +views::View* ExternalProtocolDialog::GetContentsView() { + return message_box_view_; +} + +/////////////////////////////////////////////////////////////////////////////// +// ExternalProtocolDialog, private: + +ExternalProtocolDialog::ExternalProtocolDialog(TabContents* tab_contents, + const GURL& url) + : creation_time_(base::Time::Now()), + scheme_(UTF8ToWide(url.scheme())) { + std::wstring message_text = l10n_util::GetStringF( + IDS_EXTERNAL_PROTOCOL_INFORMATION, + ASCIIToWide(url.scheme() + ":"), + ASCIIToWide(url.possibly_invalid_spec())) + L"\n\n"; + + message_box_view_ = new MessageBoxView(MessageBoxFlags::kIsConfirmMessageBox, + message_text, + std::wstring(), + kMessageWidth); + message_box_view_->SetCheckBoxLabel( + l10n_util::GetString(IDS_EXTERNAL_PROTOCOL_CHECKBOX_TEXT)); + + gfx::NativeWindow parent_window; + if (tab_contents) { + parent_window = tab_contents->view()->GetTopLevelNativeWindow(); + } else { + // Dialog is top level if we don't have a tab_contents associated with us. + parent_window = NULL; + } + views::Window::CreateChromeWindow(parent_window, gfx::Rect(), this)->Show(); +} diff --git a/chrome/browser/chromeos/external_protocol_dialog.h b/chrome/browser/chromeos/external_protocol_dialog.h new file mode 100644 index 0000000..9631004 --- /dev/null +++ b/chrome/browser/chromeos/external_protocol_dialog.h @@ -0,0 +1,51 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_CHROMEOS_EXTERNAL_PROTOCOL_DIALOG_H_ +#define CHROME_BROWSER_CHROMEOS_EXTERNAL_PROTOCOL_DIALOG_H_ + +#include "base/time.h" +#include "views/window/dialog_delegate.h" + +class GURL; +class MessageBoxView; +class TabContents; + +// An external protocol dialog for ChromeOS. Unlike other platforms, +// ChromeOS does not support launching external program, therefore, +// this dialog simply says it is not supported. +class ExternalProtocolDialog : public views::DialogDelegate { + public: + // RunExternalProtocolDialog calls this private constructor. + ExternalProtocolDialog(TabContents* tab_contents, const GURL& url); + + virtual ~ExternalProtocolDialog(); + + // views::DialogDelegate Methods: + virtual int GetDialogButtons() const; + virtual std::wstring GetDialogButtonLabel( + MessageBoxFlags::DialogButton button) const; + virtual std::wstring GetWindowTitle() const; + virtual void DeleteDelegate(); + virtual bool Accept(); + virtual views::View* GetContentsView(); + + // views::WindowDelegate Methods: + virtual bool IsAlwaysOnTop() const { return false; } + virtual bool IsModal() const { return false; } + + private: + // The message box view whose commands we handle. + MessageBoxView* message_box_view_; + + // The time at which this dialog was created. + base::Time creation_time_; + + // The scheme of the url. + std::wstring scheme_; + + DISALLOW_COPY_AND_ASSIGN(ExternalProtocolDialog); +}; + +#endif // CHROME_BROWSER_CHROMEOS_EXTERNAL_PROTOCOL_DIALOG_H_ diff --git a/chrome/browser/external_protocol_handler.cc b/chrome/browser/external_protocol_handler.cc index 8e041be..6855bdc 100644 --- a/chrome/browser/external_protocol_handler.cc +++ b/chrome/browser/external_protocol_handler.cc @@ -145,15 +145,11 @@ void ExternalProtocolHandler::LaunchUrl(const GURL& url, g_accept_requests = false; if (block_state == UNKNOWN) { -#if defined(OS_WIN) || defined(TOOLKIT_GTK) || defined(OS_MACOSX) // Ask the user if they want to allow the protocol. This will call // LaunchUrlWithoutSecurityCheck if the user decides to accept the protocol. RunExternalProtocolDialog(escaped_url, render_process_host_id, tab_contents_id); -#endif - // For now, allow only whitelisted protocols to fire on Linux/Views. - // See http://crbug.com/23853 . return; } diff --git a/chrome/browser/views/external_protocol_dialog.cc b/chrome/browser/views/external_protocol_dialog.cc index 1f7bf42..6548eb6 100644 --- a/chrome/browser/views/external_protocol_dialog.cc +++ b/chrome/browser/views/external_protocol_dialog.cc @@ -39,6 +39,7 @@ void ExternalProtocolHandler::RunExternalProtocolDialog( } TabContents* tab_contents = tab_util::GetTabContentsByID( render_process_host_id, routing_id); + DCHECK(tab_contents); ExternalProtocolDialog* handler = new ExternalProtocolDialog(tab_contents, url, command); } @@ -128,7 +129,7 @@ ExternalProtocolDialog::ExternalProtocolDialog(TabContents* tab_contents, message_box_view_ = new MessageBoxView(MessageBoxFlags::kIsConfirmMessageBox, message_text, - L"", + std::wstring(), kMessageWidth); message_box_view_->SetCheckBoxLabel( l10n_util::GetString(IDS_EXTERNAL_PROTOCOL_CHECKBOX_TEXT)); diff --git a/chrome/browser/views/external_protocol_dialog.h b/chrome/browser/views/external_protocol_dialog.h index c7a01d1..4a5e469 100644 --- a/chrome/browser/views/external_protocol_dialog.h +++ b/chrome/browser/views/external_protocol_dialog.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_EXTERNAL_PROTOCOL_DIALOG_H_ -#define CHROME_BROWSER_EXTERNAL_PROTOCOL_DIALOG_H_ +#ifndef CHROME_BROWSER_VIEWS_EXTERNAL_PROTOCOL_DIALOG_H_ +#define CHROME_BROWSER_VIEWS_EXTERNAL_PROTOCOL_DIALOG_H_ #include "base/time.h" #include "googleurl/src/gurl.h" @@ -55,4 +55,4 @@ class ExternalProtocolDialog : public views::DialogDelegate { DISALLOW_COPY_AND_ASSIGN(ExternalProtocolDialog); }; -#endif // CHROME_BROWSER_EXTERNAL_PROTOCOL_DIALOG_H_ +#endif // CHROME_BROWSER_VIEWS_EXTERNAL_PROTOCOL_DIALOG_H_ diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp index c50c3a9..91fcfab 100755 --- a/chrome/chrome.gyp +++ b/chrome/chrome.gyp @@ -974,6 +974,8 @@ 'browser/chromeos/cros_library.h', 'browser/chromeos/external_cookie_handler.cc', 'browser/chromeos/external_cookie_handler.h', + 'browser/chromeos/external_protocol_dialog.cc', + 'browser/chromeos/external_protocol_dialog.h', 'browser/chromeos/gview_request_interceptor.cc', 'browser/chromeos/gview_request_interceptor.h', 'browser/chromeos/main_menu.cc', @@ -2463,8 +2465,10 @@ ], }], ['chromeos==1 and toolkit_views==0', { - 'sources!': [ - 'browser/chromeos/browser_extenders.cc', + 'sources/': [ + ['exclude', '^browser/chromeos/browser_extenders.cc'], + ['exclude', '^browser/gtk/external_protocol_dialog_gtk.cc'], + ['exclude', '^browser/gtk/external_protocol_dialog_gtk.h'], ], }], ['chromeos==0 and toolkit_views==0', { |