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

Side by Side Diff: chrome/renderer/searchbox/searchbox_extension.cc

Issue 17526008: Log NTP hovers in 1993 clients (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 7 years, 5 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
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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/renderer/searchbox/searchbox_extension.h" 5 #include "chrome/renderer/searchbox/searchbox_extension.h"
6 6
7 #include "base/i18n/rtl.h" 7 #include "base/i18n/rtl.h"
8 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after
644 // chrome-search://suggestion can call this function. 644 // chrome-search://suggestion can call this function.
645 static void GetSuggestionData( 645 static void GetSuggestionData(
646 const v8::FunctionCallbackInfo<v8::Value>& args); 646 const v8::FunctionCallbackInfo<v8::Value>& args);
647 647
648 // Gets the raw data for a most visited item including its raw URL. 648 // Gets the raw data for a most visited item including its raw URL.
649 // GetRenderViewWithCheckedOrigin() enforces that only code in the origin 649 // GetRenderViewWithCheckedOrigin() enforces that only code in the origin
650 // chrome-search://most-visited can call this function. 650 // chrome-search://most-visited can call this function.
651 static void GetMostVisitedItemData( 651 static void GetMostVisitedItemData(
652 const v8::FunctionCallbackInfo<v8::Value>& args); 652 const v8::FunctionCallbackInfo<v8::Value>& args);
653 653
654 // Logs information from the iframes/titles on the NTP.
655 static void LogEvent(const v8::FunctionCallbackInfo<v8::Value>& args);
656
654 // Gets whether the omnibox has focus or not. 657 // Gets whether the omnibox has focus or not.
655 static void IsFocused(const v8::FunctionCallbackInfo<v8::Value>& args); 658 static void IsFocused(const v8::FunctionCallbackInfo<v8::Value>& args);
656 659
657 // Gets whether user input is in progress. 660 // Gets whether user input is in progress.
658 static void IsInputInProgress( 661 static void IsInputInProgress(
659 const v8::FunctionCallbackInfo<v8::Value>& args); 662 const v8::FunctionCallbackInfo<v8::Value>& args);
660 663
661 private: 664 private:
662 DISALLOW_COPY_AND_ASSIGN(SearchBoxExtensionWrapper); 665 DISALLOW_COPY_AND_ASSIGN(SearchBoxExtensionWrapper);
663 }; 666 };
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
738 if (name->Equals(v8::String::New("UndoMostVisitedDeletion"))) 741 if (name->Equals(v8::String::New("UndoMostVisitedDeletion")))
739 return v8::FunctionTemplate::New(UndoMostVisitedDeletion); 742 return v8::FunctionTemplate::New(UndoMostVisitedDeletion);
740 if (name->Equals(v8::String::New("ShowBars"))) 743 if (name->Equals(v8::String::New("ShowBars")))
741 return v8::FunctionTemplate::New(ShowBars); 744 return v8::FunctionTemplate::New(ShowBars);
742 if (name->Equals(v8::String::New("HideBars"))) 745 if (name->Equals(v8::String::New("HideBars")))
743 return v8::FunctionTemplate::New(HideBars); 746 return v8::FunctionTemplate::New(HideBars);
744 if (name->Equals(v8::String::New("GetSuggestionData"))) 747 if (name->Equals(v8::String::New("GetSuggestionData")))
745 return v8::FunctionTemplate::New(GetSuggestionData); 748 return v8::FunctionTemplate::New(GetSuggestionData);
746 if (name->Equals(v8::String::New("GetMostVisitedItemData"))) 749 if (name->Equals(v8::String::New("GetMostVisitedItemData")))
747 return v8::FunctionTemplate::New(GetMostVisitedItemData); 750 return v8::FunctionTemplate::New(GetMostVisitedItemData);
751 if (name->Equals(v8::String::New("LogEvent")))
752 return v8::FunctionTemplate::New(LogEvent);
748 if (name->Equals(v8::String::New("IsFocused"))) 753 if (name->Equals(v8::String::New("IsFocused")))
749 return v8::FunctionTemplate::New(IsFocused); 754 return v8::FunctionTemplate::New(IsFocused);
750 if (name->Equals(v8::String::New("IsInputInProgress"))) 755 if (name->Equals(v8::String::New("IsInputInProgress")))
751 return v8::FunctionTemplate::New(IsInputInProgress); 756 return v8::FunctionTemplate::New(IsInputInProgress);
752 return v8::Handle<v8::FunctionTemplate>(); 757 return v8::Handle<v8::FunctionTemplate>();
753 } 758 }
754 759
755 // static 760 // static
756 content::RenderView* SearchBoxExtensionWrapper::GetRenderView() { 761 content::RenderView* SearchBoxExtensionWrapper::GetRenderView() {
757 WebKit::WebFrame* webframe = WebKit::WebFrame::frameForCurrentContext(); 762 WebKit::WebFrame* webframe = WebKit::WebFrame::frameForCurrentContext();
(...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after
1467 if (!SearchBox::Get(render_view)->GetMostVisitedItemWithID( 1472 if (!SearchBox::Get(render_view)->GetMostVisitedItemWithID(
1468 restricted_id, &mv_item)) { 1473 restricted_id, &mv_item)) {
1469 return; 1474 return;
1470 } 1475 }
1471 args.GetReturnValue().Set( 1476 args.GetReturnValue().Set(
1472 GenerateMostVisitedItem(render_view->GetRoutingID(), restricted_id, 1477 GenerateMostVisitedItem(render_view->GetRoutingID(), restricted_id,
1473 mv_item)); 1478 mv_item));
1474 } 1479 }
1475 1480
1476 // static 1481 // static
1482 void SearchBoxExtensionWrapper::LogEvent(
1483 const v8::FunctionCallbackInfo<v8::Value>& args) {
1484 content::RenderView* render_view = GetRenderViewWithCheckedOrigin(
1485 GURL(chrome::kChromeSearchMostVisitedUrl));
1486 if (!render_view) return;
1487
1488 if (args.Length() < 1 || !args[0]->IsString())
1489 return;
1490
1491 DVLOG(1) << render_view << " LogEvent";
1492
1493 std::string histogram_name = *v8::String::Utf8Value(args[0]->ToString());
1494
1495 if (histogram_name == "NewTabPage.NumberOfMouseOvers")
1496 SearchBox::Get(render_view)->CountMouseover();
beaudoin 2013/07/04 16:12:03 In the else case we should probably DVLOG(1) that
annark1 2013/07/04 19:25:09 Done.
1497 }
1498
1499 // static
1477 void SearchBoxExtensionWrapper::IsFocused( 1500 void SearchBoxExtensionWrapper::IsFocused(
1478 const v8::FunctionCallbackInfo<v8::Value>& args) { 1501 const v8::FunctionCallbackInfo<v8::Value>& args) {
1479 content::RenderView* render_view = GetRenderView(); 1502 content::RenderView* render_view = GetRenderView();
1480 if (!render_view) return; 1503 if (!render_view) return;
1481 1504
1482 bool is_focused = SearchBox::Get(render_view)->is_focused(); 1505 bool is_focused = SearchBox::Get(render_view)->is_focused();
1483 DVLOG(1) << render_view << " IsFocused: " << is_focused; 1506 DVLOG(1) << render_view << " IsFocused: " << is_focused;
1484 args.GetReturnValue().Set(is_focused); 1507 args.GetReturnValue().Set(is_focused);
1485 } 1508 }
1486 1509
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
1576 Dispatch(frame, kDispatchInputCancelScript); 1599 Dispatch(frame, kDispatchInputCancelScript);
1577 } 1600 }
1578 1601
1579 // static 1602 // static
1580 void SearchBoxExtension::DispatchToggleVoiceSearch( 1603 void SearchBoxExtension::DispatchToggleVoiceSearch(
1581 WebKit::WebFrame* frame) { 1604 WebKit::WebFrame* frame) {
1582 Dispatch(frame, kDispatchToggleVoiceSearchScript); 1605 Dispatch(frame, kDispatchToggleVoiceSearchScript);
1583 } 1606 }
1584 1607
1585 } // namespace extensions_v8 1608 } // namespace extensions_v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698