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