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