diff options
author | mhm@chromium.org <mhm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-03 12:13:48 +0000 |
---|---|---|
committer | mhm@chromium.org <mhm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-03 12:13:48 +0000 |
commit | a21767477fef894a75d0b13a8da3da6cdc2f5e3e (patch) | |
tree | e45f5c969518b6a64ed54fc8d96ba28f4736aae7 | |
parent | 13c68582fc7a22a18cde190d09393912124f75b0 (diff) | |
download | chromium_src-a21767477fef894a75d0b13a8da3da6cdc2f5e3e.zip chromium_src-a21767477fef894a75d0b13a8da3da6cdc2f5e3e.tar.gz chromium_src-a21767477fef894a75d0b13a8da3da6cdc2f5e3e.tar.bz2 |
Foundations for Print Preview and Setup
Create the foundations of implementing a tab for printing should be in the form of:
print:http://www.google.com
I have followed similar approach as what has been done with view-source: and chrome-extension:
BUG=173, 947
TEST=none
Review URL: http://codereview.chromium.org/150207
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19906 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/autocomplete/autocomplete.cc | 12 | ||||
-rw-r--r-- | chrome/browser/child_process_security_policy.cc | 17 | ||||
-rw-r--r-- | chrome/browser/dom_ui/dom_ui_factory.cc | 7 | ||||
-rw-r--r-- | chrome/browser/dom_ui/print_ui.cc | 15 | ||||
-rw-r--r-- | chrome/browser/dom_ui/print_ui.h | 18 | ||||
-rw-r--r-- | chrome/browser/history/history.cc | 3 | ||||
-rw-r--r-- | chrome/chrome.gyp | 2 | ||||
-rw-r--r-- | chrome/common/url_constants.cc | 1 | ||||
-rw-r--r-- | chrome/common/url_constants.h | 1 | ||||
-rw-r--r-- | chrome/renderer/render_view.cc | 3 |
10 files changed, 65 insertions, 14 deletions
diff --git a/chrome/browser/autocomplete/autocomplete.cc b/chrome/browser/autocomplete/autocomplete.cc index 7678fc7..7b7b1c2 100644 --- a/chrome/browser/autocomplete/autocomplete.cc +++ b/chrome/browser/autocomplete/autocomplete.cc @@ -125,7 +125,8 @@ AutocompleteInput::Type AutocompleteInput::Parse( // should still claim to handle them. if (LowerCaseEqualsASCII(parsed_scheme, chrome::kViewSourceScheme) || LowerCaseEqualsASCII(parsed_scheme, chrome::kJavaScriptScheme) || - LowerCaseEqualsASCII(parsed_scheme, chrome::kDataScheme)) + LowerCaseEqualsASCII(parsed_scheme, chrome::kDataScheme) || + LowerCaseEqualsASCII(parsed_scheme, chrome::kPrintScheme)) return URL; // Finally, check and see if the user has explicitly opened this scheme as @@ -257,11 +258,12 @@ void AutocompleteInput::ParseForEmphasizeComponents( *host = parts.host; int after_scheme_and_colon = parts.scheme.end() + 1; - // For the view-source scheme, we should emphasize the scheme and host of - // the URL qualified by the view-source prefix. - if (LowerCaseEqualsASCII(scheme_str, chrome::kViewSourceScheme) && + // For the view-source and print schemes, we should emphasize the scheme and + // host of the URL qualified by the scheme prefix. + if ((LowerCaseEqualsASCII(scheme_str, chrome::kViewSourceScheme) || + LowerCaseEqualsASCII(scheme_str, chrome::kPrintScheme)) && (static_cast<int>(text.length()) > after_scheme_and_colon)) { - // Obtain the URL prefixed by view-source and parse it. + // Obtain the URL prefixed by scheme and parse it. std::wstring real_url(text.substr(after_scheme_and_colon)); url_parse::Parsed real_parts; AutocompleteInput::Parse(real_url, desired_tld, &real_parts, NULL); diff --git a/chrome/browser/child_process_security_policy.cc b/chrome/browser/child_process_security_policy.cc index b386e8e..b3ba538 100644 --- a/chrome/browser/child_process_security_policy.cc +++ b/chrome/browser/child_process_security_policy.cc @@ -98,6 +98,7 @@ ChildProcessSecurityPolicy::ChildProcessSecurityPolicy() { RegisterPseudoScheme(chrome::kAboutScheme); RegisterPseudoScheme(chrome::kJavaScriptScheme); RegisterPseudoScheme(chrome::kViewSourceScheme); + RegisterPseudoScheme(chrome::kPrintScheme); } ChildProcessSecurityPolicy::~ChildProcessSecurityPolicy() { @@ -170,10 +171,11 @@ void ChildProcessSecurityPolicy::GrantRequestURL(int renderer_id, const GURL& ur return; // The scheme has already been white-listed for every renderer. if (IsPseudoScheme(url.scheme())) { - // The view-source scheme is a special case of a pseudo URL that eventually - // results in requesting its embedded URL. - if (url.SchemeIs(chrome::kViewSourceScheme)) { - // URLs with the view-source scheme typically look like: + // The view-source and print schemes are a special case of a pseudo URL that + // eventually results in requesting its embedded URL. + if (url.SchemeIs(chrome::kViewSourceScheme) || + url.SchemeIs(chrome::kPrintScheme)) { + // URLs with the view-source and print schemes typically look like: // view-source:http://www.google.com/a // In order to request these URLs, the renderer needs to be able to // request the embedded URL. @@ -254,9 +256,10 @@ bool ChildProcessSecurityPolicy::CanRequestURL(int renderer_id, const GURL& url) if (IsPseudoScheme(url.scheme())) { // There are a number of special cases for pseudo schemes. - if (url.SchemeIs(chrome::kViewSourceScheme)) { - // A view-source URL is allowed if the renderer is permitted to request - // the embedded URL. + if (url.SchemeIs(chrome::kViewSourceScheme) || + url.SchemeIs(chrome::kPrintScheme)) { + // View-source and print URL's are allowed if the renderer is permitted + // to request the embedded URL. return CanRequestURL(renderer_id, GURL(url.path())); } diff --git a/chrome/browser/dom_ui/dom_ui_factory.cc b/chrome/browser/dom_ui/dom_ui_factory.cc index 8827c02..8ff6d03 100644 --- a/chrome/browser/dom_ui/dom_ui_factory.cc +++ b/chrome/browser/dom_ui/dom_ui_factory.cc @@ -9,6 +9,7 @@ #include "chrome/browser/dom_ui/history_ui.h" #include "chrome/browser/dom_ui/html_dialog_ui.h" #include "chrome/browser/dom_ui/new_tab_ui.h" +#include "chrome/browser/dom_ui/print_ui.h" #include "chrome/browser/extensions/extensions_ui.h" #include "chrome/browser/extensions/extension_dom_ui.h" #include "chrome/common/url_constants.h" @@ -41,6 +42,12 @@ static bool CreateDOMUI(const GURL& url, TabContents* tab_contents, return true; } + if (url.SchemeIs(chrome::kPrintScheme)) { + if (new_ui) + *new_ui = new PrintUI(tab_contents); + return true; + } + #ifdef CHROME_PERSONALIZATION if (Personalization::NeedsDOMUI(url)) { if (new_ui) diff --git a/chrome/browser/dom_ui/print_ui.cc b/chrome/browser/dom_ui/print_ui.cc new file mode 100644 index 0000000..973e5c7 --- /dev/null +++ b/chrome/browser/dom_ui/print_ui.cc @@ -0,0 +1,15 @@ +// 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/dom_ui/print_ui.h" + +/////////////////////////////////////////////////////////////////////////////// +// +// PrintUI +// +/////////////////////////////////////////////////////////////////////////////// + +PrintUI::PrintUI(TabContents* contents) : DOMUI(contents) { + NOTIMPLEMENTED(); +} diff --git a/chrome/browser/dom_ui/print_ui.h b/chrome/browser/dom_ui/print_ui.h new file mode 100644 index 0000000..020b3f1 --- /dev/null +++ b/chrome/browser/dom_ui/print_ui.h @@ -0,0 +1,18 @@ +// 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_DOM_UI_PRINT_UI_H_ +#define CHROME_BROWSER_DOM_UI_PRINT_UI_H_ + +#include "chrome/browser/dom_ui/dom_ui.h" + +class PrintUI : public DOMUI { + public: + explicit PrintUI(TabContents* contents); + + private: + DISALLOW_COPY_AND_ASSIGN(PrintUI); +}; + +#endif // CHROME_BROWSER_DOM_UI_PRINT_UI_H_ diff --git a/chrome/browser/history/history.cc b/chrome/browser/history/history.cc index 8c314067..aa004b4 100644 --- a/chrome/browser/history/history.cc +++ b/chrome/browser/history/history.cc @@ -593,7 +593,8 @@ bool HistoryService::CanAddURL(const GURL& url) const { if (url.SchemeIs(chrome::kJavaScriptScheme) || url.SchemeIs(chrome::kChromeUIScheme) || url.SchemeIs(chrome::kViewSourceScheme) || - url.SchemeIs(chrome::kChromeInternalScheme)) + url.SchemeIs(chrome::kChromeInternalScheme) || + url.SchemeIs(chrome::kPrintScheme)) return false; if (url.SchemeIs(chrome::kAboutScheme)) { diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp index 5533fed..04ce09e 100644 --- a/chrome/chrome.gyp +++ b/chrome/chrome.gyp @@ -851,6 +851,8 @@ 'browser/dom_ui/html_dialog_ui.h', 'browser/dom_ui/new_tab_ui.cc', 'browser/dom_ui/new_tab_ui.h', + 'browser/dom_ui/print_ui.cc', + 'browser/dom_ui/print_ui.h', 'browser/dom_ui/shown_sections_handler.cc', 'browser/dom_ui/shown_sections_handler.h', 'browser/dom_ui/tips_handler.cc', diff --git a/chrome/common/url_constants.cc b/chrome/common/url_constants.cc index 1f47987..eb3f78f 100644 --- a/chrome/common/url_constants.cc +++ b/chrome/common/url_constants.cc @@ -21,6 +21,7 @@ const char kHttpScheme[] = "http"; const char kHttpsScheme[] = "https"; const char kJavaScriptScheme[] = "javascript"; const char kMailToScheme[] = "mailto"; +const char kPrintScheme[] = "print"; const char kUserScriptScheme[] = "chrome-user-script"; const char kViewCacheScheme[] = "view-cache"; const char kViewSourceScheme[] = "view-source"; diff --git a/chrome/common/url_constants.h b/chrome/common/url_constants.h index 69d6c54..12d7651 100644 --- a/chrome/common/url_constants.h +++ b/chrome/common/url_constants.h @@ -22,6 +22,7 @@ extern const char kHttpScheme[]; extern const char kHttpsScheme[]; extern const char kJavaScriptScheme[]; extern const char kMailToScheme[]; +extern const char kPrintScheme[]; extern const char kUserScriptScheme[]; extern const char kViewCacheScheme[]; extern const char kViewSourceScheme[]; diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc index 5b98519..8e6fab8 100644 --- a/chrome/renderer/render_view.cc +++ b/chrome/renderer/render_view.cc @@ -1485,7 +1485,8 @@ WindowOpenDisposition RenderView::DispositionForNavigationAction( if (BindingsPolicy::is_dom_ui_enabled(enabled_bindings_) || BindingsPolicy::is_extension_enabled(enabled_bindings_) || frame->GetInViewSourceMode() || - url.SchemeIs(chrome::kViewSourceScheme)) { + url.SchemeIs(chrome::kViewSourceScheme) || + url.SchemeIs(chrome::kPrintScheme)) { OpenURL(webview, url, GURL(), disposition); return IGNORE_ACTION; // Suppress the load here. } |