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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/dom_ui/generic_handler.h"
6
7 #include "base/logging.h"
8 #include "base/values.h"
9 #include "chrome/browser/tab_contents/tab_contents.h"
10 #include "googleurl/src/gurl.h"
11
12 GenericHandler::GenericHandler() {
13 }
14
15 GenericHandler::~GenericHandler() {
16 }
17
18 void GenericHandler::RegisterMessages() {
19 dom_ui_->RegisterMessageCallback("navigateToUrl",
20 NewCallback(this, &GenericHandler::HandleNavigateToUrl));
21 }
22
23 void GenericHandler::HandleNavigateToUrl(const ListValue* args) {
24 std::string url_string;
25 CHECK(args->GetString(0, &url_string));
26 std::string button_string;
27 CHECK(args->GetString(1, &button_string));
28 CHECK(button_string == "0" || button_string == "1");
29 std::string ctrl_string;
30 CHECK(args->GetString(2, &ctrl_string));
31 std::string shift_string;
32 CHECK(args->GetString(3, &shift_string));
33 std::string alt_string;
34 CHECK(args->GetString(4, &alt_string));
35
36 // TODO(estade): This logic is replicated in 4 places throughout chrome.
37 // It would be nice to centralize it.
38 WindowOpenDisposition disposition;
39 if (button_string == "1" || ctrl_string == "true") {
40 disposition = shift_string == "true" ?
41 NEW_FOREGROUND_TAB : NEW_BACKGROUND_TAB;
42 } else if (shift_string == "true") {
43 disposition = NEW_WINDOW;
44 } else {
45 disposition = alt_string == "true" ? SAVE_TO_DISK : CURRENT_TAB;
46 }
47
48 dom_ui_->tab_contents()->OpenURL(
49 GURL(url_string), GURL(), disposition, PageTransition::LINK);
50
51 // This may delete us!
52 }
OLDNEW
« 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