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

Side by Side Diff: chrome/browser/dom_ui/new_tab_ui.cc

Issue 8186: Plumb the referrer throughout the OpenURL APIs.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 years, 1 month 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/dom_ui/new_tab_ui.h" 5 #include "chrome/browser/dom_ui/new_tab_ui.h"
6 6
7 #include "base/histogram.h" 7 #include "base/histogram.h"
8 #include "base/string_piece.h" 8 #include "base/string_piece.h"
9 #include "chrome/app/locales/locale_settings.h" 9 #include "chrome/app/locales/locale_settings.h"
10 #include "chrome/browser/browser.h" 10 #include "chrome/browser/browser.h"
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 const TemplateURLRef* url_ref = template_url->url(); 448 const TemplateURLRef* url_ref = template_url->url();
449 if (!url_ref || !url_ref->SupportsReplacement()) { 449 if (!url_ref || !url_ref->SupportsReplacement()) {
450 NOTREACHED(); 450 NOTREACHED();
451 return; 451 return;
452 } 452 }
453 std::wstring url = url_ref->ReplaceSearchTerms(*template_url, search, 453 std::wstring url = url_ref->ReplaceSearchTerms(*template_url, search,
454 TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, std::wstring()); 454 TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, std::wstring());
455 455
456 // Load the URL. 456 // Load the URL.
457 if (!url.empty()) { 457 if (!url.empty()) {
458 dom_ui_host_->OpenURL(GURL(WideToUTF8(url)), CURRENT_TAB, 458 dom_ui_host_->OpenURL(GURL(WideToUTF8(url)), GURL(), CURRENT_TAB,
459 PageTransition::LINK); 459 PageTransition::LINK);
460 } 460 }
461 } 461 }
462 462
463 // A helper function for sorting TemplateURLs where the most used ones show up 463 // A helper function for sorting TemplateURLs where the most used ones show up
464 // first. 464 // first.
465 static bool TemplateURLSortByUsage(const TemplateURL* a, 465 static bool TemplateURLSortByUsage(const TemplateURL* a,
466 const TemplateURL* b) { 466 const TemplateURL* b) {
467 return a->usage_count() > b->usage_count(); 467 return a->usage_count() > b->usage_count();
468 } 468 }
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
662 : dom_ui_host_(dom_ui_host) { 662 : dom_ui_host_(dom_ui_host) {
663 dom_ui_host->RegisterMessageCallback("showHistoryPage", 663 dom_ui_host->RegisterMessageCallback("showHistoryPage",
664 NewCallback(this, &HistoryHandler::HandleShowHistoryPage)); 664 NewCallback(this, &HistoryHandler::HandleShowHistoryPage));
665 dom_ui_host->RegisterMessageCallback("searchHistoryPage", 665 dom_ui_host->RegisterMessageCallback("searchHistoryPage",
666 NewCallback(this, &HistoryHandler::HandleSearchHistoryPage)); 666 NewCallback(this, &HistoryHandler::HandleSearchHistoryPage));
667 } 667 }
668 668
669 void HistoryHandler::HandleShowHistoryPage(const Value*) { 669 void HistoryHandler::HandleShowHistoryPage(const Value*) {
670 NavigationController* controller = dom_ui_host_->controller(); 670 NavigationController* controller = dom_ui_host_->controller();
671 if (controller) 671 if (controller)
672 controller->LoadURL(HistoryTabUI::GetURL(), PageTransition::LINK); 672 controller->LoadURL(HistoryTabUI::GetURL(), GURL(), PageTransition::LINK);
673 } 673 }
674 674
675 void HistoryHandler::HandleSearchHistoryPage(const Value* content) { 675 void HistoryHandler::HandleSearchHistoryPage(const Value* content) {
676 if (content && content->GetType() == Value::TYPE_LIST) { 676 if (content && content->GetType() == Value::TYPE_LIST) {
677 const ListValue* list_value = static_cast<const ListValue*>(content); 677 const ListValue* list_value = static_cast<const ListValue*>(content);
678 Value* list_member; 678 Value* list_member;
679 if (list_value->Get(0, &list_member) && 679 if (list_value->Get(0, &list_member) &&
680 list_member->GetType() == Value::TYPE_STRING) { 680 list_member->GetType() == Value::TYPE_STRING) {
681 const StringValue* string_value = 681 const StringValue* string_value =
682 static_cast<const StringValue*>(list_member); 682 static_cast<const StringValue*>(list_member);
683 std::wstring wstring_value; 683 std::wstring wstring_value;
684 if (string_value->GetAsString(&wstring_value)) { 684 if (string_value->GetAsString(&wstring_value)) {
685 NavigationController* controller = dom_ui_host_->controller(); 685 NavigationController* controller = dom_ui_host_->controller();
686 controller->LoadURL( 686 controller->LoadURL(
687 HistoryTabUI::GetHistoryURLWithSearchText(wstring_value), 687 HistoryTabUI::GetHistoryURLWithSearchText(wstring_value),
688 GURL(),
688 PageTransition::LINK); 689 PageTransition::LINK);
689 } 690 }
690 } 691 }
691 } 692 }
692 } 693 }
693 694
694 695
695 // This is the top-level URL handler for chrome-internal: URLs, and exposed in 696 // This is the top-level URL handler for chrome-internal: URLs, and exposed in
696 // our header file. 697 // our header file.
697 bool NewTabUIHandleURL(GURL* url, 698 bool NewTabUIHandleURL(GURL* url,
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
796 ::SetFocus(GetContainerHWND()); 797 ::SetFocus(GetContainerHWND());
797 } 798 }
798 799
799 bool NewTabUIContents::SupportsURL(GURL* url) { 800 bool NewTabUIContents::SupportsURL(GURL* url) {
800 if (url->SchemeIs("javascript")) 801 if (url->SchemeIs("javascript"))
801 return true; 802 return true;
802 return DOMUIHost::SupportsURL(url); 803 return DOMUIHost::SupportsURL(url);
803 } 804 }
804 805
805 void NewTabUIContents::RequestOpenURL(const GURL& url, 806 void NewTabUIContents::RequestOpenURL(const GURL& url,
807 const GURL& /*referrer*/,
806 WindowOpenDisposition disposition) { 808 WindowOpenDisposition disposition) {
807 // The user opened a URL on the page (including "open in new window"). 809 // The user opened a URL on the page (including "open in new window").
808 // We count all such clicks as AUTO_BOOKMARK, which increments the site's 810 // We count all such clicks as AUTO_BOOKMARK, which increments the site's
809 // visit count (which is used for ranking the most visited entries). 811 // visit count (which is used for ranking the most visited entries).
810 // Note this means we're including clicks on not only most visited thumbnails, 812 // Note this means we're including clicks on not only most visited thumbnails,
811 // but also clicks on recently bookmarked. 813 // but also clicks on recently bookmarked.
812 OpenURL(url, disposition, PageTransition::AUTO_BOOKMARK); 814 OpenURL(url, GURL(), disposition, PageTransition::AUTO_BOOKMARK);
813 815
814 // Figure out if this was a click on a MostVisited entry, and log it if so. 816 // Figure out if this was a click on a MostVisited entry, and log it if so.
815 if (most_visited_handler_) { 817 if (most_visited_handler_) {
816 const std::vector<GURL>& urls = most_visited_handler_->most_visited_urls(); 818 const std::vector<GURL>& urls = most_visited_handler_->most_visited_urls();
817 for (size_t i = 0; i < urls.size(); ++i) { 819 for (size_t i = 0; i < urls.size(); ++i) {
818 if (url == urls[i]) { 820 if (url == urls[i]) {
819 UserMetrics::RecordComputedAction(StringPrintf(L"MostVisited%d", i), 821 UserMetrics::RecordComputedAction(StringPrintf(L"MostVisited%d", i),
820 profile()); 822 profile());
821 break; 823 break;
822 } 824 }
823 } 825 }
824 } 826 }
825 } 827 }
826 828
OLDNEW
« no previous file with comments | « chrome/browser/dom_ui/new_tab_ui.h ('k') | chrome/browser/download/download_request_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698