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

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

Issue 2852693002: Remove DetermineIfPageSupportsInstant and all its plumbing (Closed)
Patch Set: rebase Created 3 years, 7 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
« no previous file with comments | « chrome/renderer/searchbox/searchbox_extension.h ('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 #include "chrome/renderer/searchbox/searchbox_extension.h" 5 #include "chrome/renderer/searchbox/searchbox_extension.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 return current_url.Resolve(possibly_relative_url); 222 return current_url.Resolve(possibly_relative_url);
223 return GURL(possibly_relative_url); 223 return GURL(possibly_relative_url);
224 } 224 }
225 225
226 } // namespace internal 226 } // namespace internal
227 227
228 namespace extensions_v8 { 228 namespace extensions_v8 {
229 229
230 static const char kSearchBoxExtensionName[] = "v8/EmbeddedSearch"; 230 static const char kSearchBoxExtensionName[] = "v8/EmbeddedSearch";
231 231
232 // We first send this script down to determine if the page supports instant.
233 static const char kSupportsInstantScript[] =
234 "if (window.chrome &&"
235 " window.chrome.embeddedSearch &&"
236 " window.chrome.embeddedSearch.searchBox &&"
237 " window.chrome.embeddedSearch.searchBox.onsubmit &&"
238 " typeof window.chrome.embeddedSearch.searchBox.onsubmit =="
239 " 'function') {"
240 " true;"
241 "} else {"
242 " false;"
243 "}";
244
245 static const char kDispatchChromeIdentityCheckResult[] = 232 static const char kDispatchChromeIdentityCheckResult[] =
246 "if (window.chrome &&" 233 "if (window.chrome &&"
247 " window.chrome.embeddedSearch &&" 234 " window.chrome.embeddedSearch &&"
248 " window.chrome.embeddedSearch.newTabPage &&" 235 " window.chrome.embeddedSearch.newTabPage &&"
249 " window.chrome.embeddedSearch.newTabPage.onsignedincheckdone &&" 236 " window.chrome.embeddedSearch.newTabPage.onsignedincheckdone &&"
250 " typeof window.chrome.embeddedSearch.newTabPage" 237 " typeof window.chrome.embeddedSearch.newTabPage"
251 " .onsignedincheckdone === 'function') {" 238 " .onsignedincheckdone === 'function') {"
252 " window.chrome.embeddedSearch.newTabPage.onsignedincheckdone(%s, %s);" 239 " window.chrome.embeddedSearch.newTabPage.onsignedincheckdone(%s, %s);"
253 " true;" 240 " true;"
254 "}"; 241 "}";
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 DISALLOW_COPY_AND_ASSIGN(SearchBoxExtensionWrapper); 440 DISALLOW_COPY_AND_ASSIGN(SearchBoxExtensionWrapper);
454 }; 441 };
455 442
456 // static 443 // static
457 v8::Extension* SearchBoxExtension::Get() { 444 v8::Extension* SearchBoxExtension::Get() {
458 return new SearchBoxExtensionWrapper(ResourceBundle::GetSharedInstance(). 445 return new SearchBoxExtensionWrapper(ResourceBundle::GetSharedInstance().
459 GetRawDataResource(IDR_SEARCHBOX_API)); 446 GetRawDataResource(IDR_SEARCHBOX_API));
460 } 447 }
461 448
462 // static 449 // static
463 bool SearchBoxExtension::PageSupportsInstant(blink::WebFrame* frame) {
464 if (!frame) return false;
465 v8::HandleScope handle_scope(v8::Isolate::GetCurrent());
466 v8::Local<v8::Value> v = frame->ExecuteScriptAndReturnValue(
467 blink::WebScriptSource(kSupportsInstantScript));
468 return !v.IsEmpty() && v->BooleanValue();
469 }
470
471 // static
472 void SearchBoxExtension::DispatchChromeIdentityCheckResult( 450 void SearchBoxExtension::DispatchChromeIdentityCheckResult(
473 blink::WebFrame* frame, 451 blink::WebFrame* frame,
474 const base::string16& identity, 452 const base::string16& identity,
475 bool identity_match) { 453 bool identity_match) {
476 std::string escaped_identity = base::GetQuotedJSONString(identity); 454 std::string escaped_identity = base::GetQuotedJSONString(identity);
477 blink::WebString script(blink::WebString::FromUTF8(base::StringPrintf( 455 blink::WebString script(blink::WebString::FromUTF8(base::StringPrintf(
478 kDispatchChromeIdentityCheckResult, escaped_identity.c_str(), 456 kDispatchChromeIdentityCheckResult, escaped_identity.c_str(),
479 identity_match ? "true" : "false"))); 457 identity_match ? "true" : "false")));
480 Dispatch(frame, script); 458 Dispatch(frame, script);
481 } 459 }
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after
1101 ThrowInvalidParameters(args); 1079 ThrowInvalidParameters(args);
1102 return; 1080 return;
1103 } 1081 }
1104 1082
1105 DVLOG(1) << render_frame << " UndoMostVisitedDeletion"; 1083 DVLOG(1) << render_frame << " UndoMostVisitedDeletion";
1106 SearchBox::Get(render_frame) 1084 SearchBox::Get(render_frame)
1107 ->UndoMostVisitedDeletion(args[0]->ToInteger()->Value()); 1085 ->UndoMostVisitedDeletion(args[0]->ToInteger()->Value());
1108 } 1086 }
1109 1087
1110 } // namespace extensions_v8 1088 } // namespace extensions_v8
OLDNEW
« no previous file with comments | « chrome/renderer/searchbox/searchbox_extension.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698