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