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

Unified Diff: chrome/browser/dom_ui/generic_handler.cc

Issue 6269015: Add facility to fix about: and file: links from chrome:// pages. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more automatic Created 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/dom_ui/generic_handler.h ('k') | chrome/browser/dom_ui/new_tab_ui.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/dom_ui/generic_handler.cc
diff --git a/chrome/browser/dom_ui/generic_handler.cc b/chrome/browser/dom_ui/generic_handler.cc
new file mode 100644
index 0000000000000000000000000000000000000000..ec1d185b0a77e4fd66d3ba130e9b7272af973099
--- /dev/null
+++ b/chrome/browser/dom_ui/generic_handler.cc
@@ -0,0 +1,52 @@
+// Copyright (c) 2011 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/generic_handler.h"
+
+#include "base/logging.h"
+#include "base/values.h"
+#include "chrome/browser/tab_contents/tab_contents.h"
+#include "googleurl/src/gurl.h"
+
+GenericHandler::GenericHandler() {
+}
+
+GenericHandler::~GenericHandler() {
+}
+
+void GenericHandler::RegisterMessages() {
+ dom_ui_->RegisterMessageCallback("navigateToUrl",
+ NewCallback(this, &GenericHandler::HandleNavigateToUrl));
+}
+
+void GenericHandler::HandleNavigateToUrl(const ListValue* args) {
+ std::string url_string;
+ CHECK(args->GetString(0, &url_string));
+ std::string button_string;
+ CHECK(args->GetString(1, &button_string));
+ CHECK(button_string == "0" || button_string == "1");
+ std::string ctrl_string;
+ CHECK(args->GetString(2, &ctrl_string));
+ std::string shift_string;
+ CHECK(args->GetString(3, &shift_string));
+ std::string alt_string;
+ CHECK(args->GetString(4, &alt_string));
+
+ // TODO(estade): This logic is replicated in 4 places throughout chrome.
+ // It would be nice to centralize it.
+ WindowOpenDisposition disposition;
+ if (button_string == "1" || ctrl_string == "true") {
+ disposition = shift_string == "true" ?
+ NEW_FOREGROUND_TAB : NEW_BACKGROUND_TAB;
+ } else if (shift_string == "true") {
+ disposition = NEW_WINDOW;
+ } else {
+ disposition = alt_string == "true" ? SAVE_TO_DISK : CURRENT_TAB;
+ }
+
+ dom_ui_->tab_contents()->OpenURL(
+ GURL(url_string), GURL(), disposition, PageTransition::LINK);
+
+ // This may delete us!
+}
« no previous file with comments | « chrome/browser/dom_ui/generic_handler.h ('k') | chrome/browser/dom_ui/new_tab_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698