Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / browser / ui / search_engines / search_engine_tab_helper.h
blob4ccc1d6da479a725b561851806cd021322e39638
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.
5 #ifndef CHROME_BROWSER_UI_SEARCH_ENGINES_SEARCH_ENGINE_TAB_HELPER_H_
6 #define CHROME_BROWSER_UI_SEARCH_ENGINES_SEARCH_ENGINE_TAB_HELPER_H_
8 #include "base/memory/weak_ptr.h"
9 #include "chrome/browser/ui/find_bar/find_bar_controller.h"
10 #include "chrome/browser/ui/find_bar/find_notification_details.h"
11 #include "chrome/common/search_provider.h"
12 #include "content/public/browser/web_contents_observer.h"
13 #include "content/public/browser/web_contents_user_data.h"
15 class SearchEngineTabHelperDelegate;
16 class TemplateURL;
18 // Per-tab search engine manager. Handles dealing search engine processing
19 // functionality.
20 class SearchEngineTabHelper
21 : public content::WebContentsObserver,
22 public content::WebContentsUserData<SearchEngineTabHelper> {
23 public:
24 ~SearchEngineTabHelper() override;
26 SearchEngineTabHelperDelegate* delegate() const { return delegate_; }
27 void set_delegate(SearchEngineTabHelperDelegate* d) { delegate_ = d; }
29 // content::WebContentsObserver overrides.
30 void DidNavigateMainFrame(
31 const content::LoadCommittedDetails& details,
32 const content::FrameNavigateParams& params) override;
33 bool OnMessageReceived(const IPC::Message& message) override;
35 private:
36 explicit SearchEngineTabHelper(content::WebContents* web_contents);
37 friend class content::WebContentsUserData<SearchEngineTabHelper>;
39 // Handles when a page specifies an OSDD (OpenSearch Description Document).
40 void OnPageHasOSDD(const GURL& page_url,
41 const GURL& osdd_url,
42 const search_provider::OSDDType& msg_provider_type);
44 // Handles when an OSDD is downloaded.
45 void OnDownloadedOSDD(scoped_ptr<TemplateURL> template_url);
47 // If params has a searchable form, this tries to create a new keyword.
48 void GenerateKeywordIfNecessary(
49 const content::FrameNavigateParams& params);
51 // Delegate for notifying our owner about stuff. Not owned by us.
52 SearchEngineTabHelperDelegate* delegate_;
54 base::WeakPtrFactory<SearchEngineTabHelper> weak_ptr_factory_;
56 DISALLOW_COPY_AND_ASSIGN(SearchEngineTabHelper);
59 #endif // CHROME_BROWSER_UI_SEARCH_ENGINES_SEARCH_ENGINE_TAB_HELPER_H_