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

Side by Side Diff: chrome/renderer/resources/extensions/searchbox_api.js

Issue 2531443003: Searchbox API cleanup: Move getMostVisitedItemData to newTabPage (Closed)
Patch Set: Created 4 years 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
« no previous file with comments | « chrome/browser/resources/local_ntp/most_visited_util.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 var chrome; 5 var chrome;
6 if (!chrome) 6 if (!chrome)
7 chrome = {}; 7 chrome = {};
8 8
9 if (!chrome.embeddedSearch) { 9 if (!chrome.embeddedSearch) {
10 chrome.embeddedSearch = new function() { 10 chrome.embeddedSearch = new function() {
11 this.searchBox = new function() { 11 this.searchBox = new function() {
12 12
13 // ======================================================================= 13 // =======================================================================
14 // Private functions 14 // Private functions
15 // ======================================================================= 15 // =======================================================================
16 native function GetMostVisitedItemData();
17 native function GetQuery(); 16 native function GetQuery();
18 native function GetSearchRequestParams(); 17 native function GetSearchRequestParams();
19 native function GetRightToLeft(); 18 native function GetRightToLeft();
20 native function GetSuggestionToPrefetch(); 19 native function GetSuggestionToPrefetch();
21 native function IsFocused(); 20 native function IsFocused();
22 native function IsKeyCaptureEnabled(); 21 native function IsKeyCaptureEnabled();
23 native function Paste(); 22 native function Paste();
24 native function StartCapturingKeyStrokes(); 23 native function StartCapturingKeyStrokes();
25 native function StopCapturingKeyStrokes(); 24 native function StopCapturingKeyStrokes();
26 25
27 // ======================================================================= 26 // =======================================================================
28 // Exported functions 27 // Exported functions
29 // ======================================================================= 28 // =======================================================================
30 this.__defineGetter__('isFocused', IsFocused); 29 this.__defineGetter__('isFocused', IsFocused);
31 this.__defineGetter__('isKeyCaptureEnabled', IsKeyCaptureEnabled); 30 this.__defineGetter__('isKeyCaptureEnabled', IsKeyCaptureEnabled);
32 this.__defineGetter__('rtl', GetRightToLeft); 31 this.__defineGetter__('rtl', GetRightToLeft);
33 this.__defineGetter__('suggestion', GetSuggestionToPrefetch); 32 this.__defineGetter__('suggestion', GetSuggestionToPrefetch);
34 this.__defineGetter__('value', GetQuery); 33 this.__defineGetter__('value', GetQuery);
35 Object.defineProperty(this, 'requestParams', 34 Object.defineProperty(this, 'requestParams',
36 { get: GetSearchRequestParams }); 35 { get: GetSearchRequestParams });
37 36
38 // This method is restricted to chrome-search://most-visited pages by
39 // checking the invoking context's origin in searchbox_extension.cc.
40 // TODO(treib): Why is this in searchBox rather than newTabPage?
41 this.getMostVisitedItemData = function(restrictedId) {
42 var item = GetMostVisitedItemData(restrictedId);
43 if (item) {
44 var sizeInPx = Math.floor(48 * window.devicePixelRatio + 0.5);
45 // Populate large icon and fallback icon data, if they exist. We'll
46 // render everything here, once these become available by default.
47 if (item.largeIconUrl) {
48 item.largeIconUrl +=
49 sizeInPx + "/" + item.renderViewId + "/" + item.rid;
50 }
51 if (item.fallbackIconUrl) {
52 item.fallbackIconUrl +=
53 sizeInPx + ",,,,/" + item.renderViewId + "/" + item.rid;
54 }
55 }
56 return item;
57 };
58
59 this.paste = function(value) { 37 this.paste = function(value) {
60 Paste(value); 38 Paste(value);
61 }; 39 };
62 40
63 this.startCapturingKeyStrokes = function() { 41 this.startCapturingKeyStrokes = function() {
64 StartCapturingKeyStrokes(); 42 StartCapturingKeyStrokes();
65 }; 43 };
66 44
67 this.stopCapturingKeyStrokes = function() { 45 this.stopCapturingKeyStrokes = function() {
68 StopCapturingKeyStrokes(); 46 StopCapturingKeyStrokes();
69 }; 47 };
70 48
71 this.onfocuschange = null; 49 this.onfocuschange = null;
72 this.onkeycapturechange = null; 50 this.onkeycapturechange = null;
73 this.onsubmit = null; 51 this.onsubmit = null;
74 this.onsuggestionchange = null; 52 this.onsuggestionchange = null;
75 }; 53 };
76 54
77 this.newTabPage = new function() { 55 this.newTabPage = new function() {
78 56
79 // ======================================================================= 57 // =======================================================================
80 // Private functions 58 // Private functions
81 // ======================================================================= 59 // =======================================================================
82 native function CheckIsUserSignedInToChromeAs(); 60 native function CheckIsUserSignedInToChromeAs();
83 native function CheckIsUserSyncingHistory(); 61 native function CheckIsUserSyncingHistory();
84 native function DeleteMostVisitedItem(); 62 native function DeleteMostVisitedItem();
63 native function GetMostVisitedItemData();
85 native function GetMostVisitedItems(); 64 native function GetMostVisitedItems();
86 native function GetThemeBackgroundInfo(); 65 native function GetThemeBackgroundInfo();
87 native function IsInputInProgress(); 66 native function IsInputInProgress();
88 native function LogEvent(); 67 native function LogEvent();
89 native function LogMostVisitedImpression(); 68 native function LogMostVisitedImpression();
90 native function LogMostVisitedNavigation(); 69 native function LogMostVisitedNavigation();
91 native function UndoAllMostVisitedDeletions(); 70 native function UndoAllMostVisitedDeletions();
92 native function UndoMostVisitedDeletion(); 71 native function UndoMostVisitedDeletion();
93 72
94 function GetMostVisitedItemsWrapper() { 73 function GetMostVisitedItemsWrapper() {
(...skipping 20 matching lines...) Expand all
115 renderViewId + "/" + rid; 94 renderViewId + "/" + rid;
116 } 95 }
117 96
118 // ======================================================================= 97 // =======================================================================
119 // Exported functions 98 // Exported functions
120 // ======================================================================= 99 // =======================================================================
121 this.__defineGetter__('isInputInProgress', IsInputInProgress); 100 this.__defineGetter__('isInputInProgress', IsInputInProgress);
122 this.__defineGetter__('mostVisited', GetMostVisitedItemsWrapper); 101 this.__defineGetter__('mostVisited', GetMostVisitedItemsWrapper);
123 this.__defineGetter__('themeBackgroundInfo', GetThemeBackgroundInfo); 102 this.__defineGetter__('themeBackgroundInfo', GetThemeBackgroundInfo);
124 103
125 this.deleteMostVisitedItem = function(restrictedId) {
126 DeleteMostVisitedItem(restrictedId);
127 };
128
129 this.checkIsUserSignedIntoChromeAs = function(identity) { 104 this.checkIsUserSignedIntoChromeAs = function(identity) {
130 CheckIsUserSignedInToChromeAs(identity); 105 CheckIsUserSignedInToChromeAs(identity);
131 }; 106 };
132 107
133 this.checkIsUserSyncingHistory = function() { 108 this.checkIsUserSyncingHistory = function() {
134 CheckIsUserSyncingHistory(); 109 CheckIsUserSyncingHistory();
135 }; 110 };
136 111
112 this.deleteMostVisitedItem = function(restrictedId) {
113 DeleteMostVisitedItem(restrictedId);
114 };
115
116 // This method is restricted to chrome-search://most-visited pages by
117 // checking the invoking context's origin in searchbox_extension.cc.
118 this.getMostVisitedItemData = function(restrictedId) {
119 var item = GetMostVisitedItemData(restrictedId);
120 if (item) {
121 var sizeInPx = Math.floor(48 * window.devicePixelRatio + 0.5);
122 // Populate large icon and fallback icon data, if they exist. We'll
123 // render everything here, once these become available by default.
124 if (item.largeIconUrl) {
125 item.largeIconUrl +=
126 sizeInPx + "/" + item.renderViewId + "/" + item.rid;
127 }
128 if (item.fallbackIconUrl) {
129 item.fallbackIconUrl +=
130 sizeInPx + ",,,,/" + item.renderViewId + "/" + item.rid;
131 }
132 }
133 return item;
134 };
135
137 // This method is restricted to chrome-search://most-visited pages by 136 // This method is restricted to chrome-search://most-visited pages by
138 // checking the invoking context's origin in searchbox_extension.cc. 137 // checking the invoking context's origin in searchbox_extension.cc.
139 this.logEvent = function(histogram_name) { 138 this.logEvent = function(histogram_name) {
140 LogEvent(histogram_name); 139 LogEvent(histogram_name);
141 }; 140 };
142 141
143 // This method is restricted to chrome-search://most-visited pages by 142 // This method is restricted to chrome-search://most-visited pages by
144 // checking the invoking context's origin in searchbox_extension.cc. 143 // checking the invoking context's origin in searchbox_extension.cc.
145 this.logMostVisitedImpression = function(position, provider) { 144 this.logMostVisitedImpression = function(position, provider) {
146 LogMostVisitedImpression(position, provider); 145 LogMostVisitedImpression(position, provider);
(...skipping 18 matching lines...) Expand all
165 this.oninputcancel = null; 164 this.oninputcancel = null;
166 this.oninputstart = null; 165 this.oninputstart = null;
167 this.onmostvisitedchange = null; 166 this.onmostvisitedchange = null;
168 this.onthemechange = null; 167 this.onthemechange = null;
169 }; 168 };
170 169
171 // TODO(jered): Remove when google no longer expects this object. 170 // TODO(jered): Remove when google no longer expects this object.
172 chrome.searchBox = this.searchBox; 171 chrome.searchBox = this.searchBox;
173 }; 172 };
174 } 173 }
OLDNEW
« no previous file with comments | « chrome/browser/resources/local_ntp/most_visited_util.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698