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 3// found in the LICENSE file. 4 5#ifndef CHROME_BROWSER_UI_SEARCH_ENGINES_SEARCH_ENGINE_TAB_HELPER_H_ 6#define CHROME_BROWSER_UI_SEARCH_ENGINES_SEARCH_ENGINE_TAB_HELPER_H_ 7 8#include "chrome/browser/ui/find_bar/find_bar_controller.h" 9#include "chrome/browser/ui/find_bar/find_notification_details.h" 10#include "chrome/common/search_provider.h" 11#include "content/public/browser/web_contents_observer.h" 12#include "content/public/browser/web_contents_user_data.h" 13 14class SearchEngineTabHelperDelegate; 15 16// Per-tab search engine manager. Handles dealing search engine processing 17// functionality. 18class SearchEngineTabHelper 19 : public content::WebContentsObserver, 20 public content::WebContentsUserData<SearchEngineTabHelper> { 21 public: 22 virtual ~SearchEngineTabHelper(); 23 24 SearchEngineTabHelperDelegate* delegate() const { return delegate_; } 25 void set_delegate(SearchEngineTabHelperDelegate* d) { delegate_ = d; } 26 27 // content::WebContentsObserver overrides. 28 virtual void DidNavigateMainFrame( 29 const content::LoadCommittedDetails& details, 30 const content::FrameNavigateParams& params) OVERRIDE; 31 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 32 33 private: 34 explicit SearchEngineTabHelper(content::WebContents* web_contents); 35 friend class content::WebContentsUserData<SearchEngineTabHelper>; 36 37 // Handles when a page specifies an OSDD (OpenSearch Description Document). 38 void OnPageHasOSDD(const GURL& page_url, 39 const GURL& osdd_url, 40 const search_provider::OSDDType& msg_provider_type); 41 42 // If params has a searchable form, this tries to create a new keyword. 43 void GenerateKeywordIfNecessary( 44 const content::FrameNavigateParams& params); 45 46 // Delegate for notifying our owner about stuff. Not owned by us. 47 SearchEngineTabHelperDelegate* delegate_; 48 49 DISALLOW_COPY_AND_ASSIGN(SearchEngineTabHelper); 50}; 51 52#endif // CHROME_BROWSER_UI_SEARCH_ENGINES_SEARCH_ENGINE_TAB_HELPER_H_ 53