OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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_extension.h" | 5 #include "chrome/renderer/searchbox_extension.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
413 | 413 |
414 v8::Handle<v8::Value> v = frame->executeScriptAndReturnValue( | 414 v8::Handle<v8::Value> v = frame->executeScriptAndReturnValue( |
415 WebScriptSource(kSupportsInstantScript)); | 415 WebScriptSource(kSupportsInstantScript)); |
416 bool supports_deprecated_api = !v.IsEmpty() && v->BooleanValue(); | 416 bool supports_deprecated_api = !v.IsEmpty() && v->BooleanValue(); |
417 // TODO(tonyg): Add way of detecting instant support to SearchBox API. | 417 // TODO(tonyg): Add way of detecting instant support to SearchBox API. |
418 bool supports_searchbox_api = supports_deprecated_api; | 418 bool supports_searchbox_api = supports_deprecated_api; |
419 | 419 |
420 // The deprecated API needs to notify the page of events it may have missed. | 420 // The deprecated API needs to notify the page of events it may have missed. |
421 // This isn't necessary in the SearchBox API, since the page can query the | 421 // This isn't necessary in the SearchBox API, since the page can query the |
422 // API at any time. | 422 // API at any time. |
423 static std::string init_script( | 423 CR_DEFINE_STATIC_LOCAL(std::string, init_script, |
424 StringPrintf(kInitScript, kSetOmniboxBoundsScript, kUserInputScript)); | 424 (StringPrintf(kInitScript, kSetOmniboxBoundsScript, kUserInputScript))); |
425 if (supports_deprecated_api) { | 425 if (supports_deprecated_api) { |
426 frame->executeScript(WebScriptSource(WebString::fromUTF8(init_script))); | 426 frame->executeScript(WebScriptSource(WebString::fromUTF8(init_script))); |
427 } | 427 } |
428 | 428 |
429 return supports_searchbox_api || supports_deprecated_api; | 429 return supports_searchbox_api || supports_deprecated_api; |
430 } | 430 } |
431 | 431 |
432 // static | 432 // static |
433 v8::Extension* SearchBoxExtension::Get() { | 433 v8::Extension* SearchBoxExtension::Get() { |
434 return new SearchBoxExtensionWrapper(); | 434 return new SearchBoxExtensionWrapper(); |
435 } | 435 } |
436 | 436 |
437 } // namespace extensions_v8 | 437 } // namespace extensions_v8 |
OLD | NEW |