Home | History | Annotate | Download | only in searchbox
      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
      3 // found in the LICENSE file.
      4 
      5 #ifndef CHROME_RENDERER_SEARCHBOX_SEARCHBOX_EXTENSION_H_
      6 #define CHROME_RENDERER_SEARCHBOX_SEARCHBOX_EXTENSION_H_
      7 
      8 #include "base/basictypes.h"
      9 
     10 namespace v8 {
     11 class Extension;
     12 }
     13 
     14 namespace WebKit {
     15 class WebFrame;
     16 }
     17 
     18 namespace extensions_v8 {
     19 
     20 // Reference implementation of the SearchBox API as described in:
     21 // http://dev.chromium.org/searchbox
     22 class SearchBoxExtension {
     23  public:
     24   // Returns the v8::Extension object handling searchbox bindings. Returns null
     25   // if match-preview is not enabled. Caller takes ownership of returned object.
     26   static v8::Extension* Get();
     27 
     28   // Returns true if a page supports Instant, that is, if it has bound an
     29   // onsubmit() handler.
     30   static bool PageSupportsInstant(WebKit::WebFrame* frame);
     31 
     32   // Helpers to dispatch Javascript events.
     33   static void DispatchFocusChange(WebKit::WebFrame* frame);
     34   static void DispatchInputCancel(WebKit::WebFrame* frame);
     35   static void DispatchInputStart(WebKit::WebFrame* frame);
     36   static void DispatchKeyCaptureChange(WebKit::WebFrame* frame);
     37   static void DispatchMarginChange(WebKit::WebFrame* frame);
     38   static void DispatchMostVisitedChanged(WebKit::WebFrame* frame);
     39   static void DispatchSubmit(WebKit::WebFrame* frame);
     40   static void DispatchThemeChange(WebKit::WebFrame* frame);
     41   static void DispatchToggleVoiceSearch(WebKit::WebFrame* frame);
     42 
     43  private:
     44   DISALLOW_IMPLICIT_CONSTRUCTORS(SearchBoxExtension);
     45 };
     46 
     47 }  // namespace extensions_v8
     48 
     49 #endif  // CHROME_RENDERER_SEARCHBOX_SEARCHBOX_EXTENSION_H_
     50