1 // Copyright (c) 2012 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_SEARCH_ENGINES_SEARCH_PROVIDER_INSTALL_STATE_MESSAGE_FILTER_H_
6 #define CHROME_BROWSER_SEARCH_ENGINES_SEARCH_PROVIDER_INSTALL_STATE_MESSAGE_FILTER_H_
8 #include "base/memory/weak_ptr.h"
9 #include "chrome/browser/search_engines/search_provider_install_data.h"
10 #include "chrome/common/search_provider.h"
11 #include "content/public/browser/browser_message_filter.h"
16 // Handles messages regarding search provider install state on the I/O thread.
17 class SearchProviderInstallStateMessageFilter
18 : public content::BrowserMessageFilter {
20 // Unlike the other methods, the constructor must be called on the UI thread.
21 SearchProviderInstallStateMessageFilter(int render_process_id,
24 // content::BrowserMessageFilter implementation.
25 bool OnMessageReceived(const IPC::Message& message) override;
28 ~SearchProviderInstallStateMessageFilter() override;
30 // Figures out the install state for the search provider.
31 search_provider::InstallState GetSearchProviderInstallState(
32 const GURL& page_location,
33 const GURL& requested_host);
35 // Starts handling the message requesting the search provider install state.
36 void OnGetSearchProviderInstallState(const GURL& page_location,
37 const GURL& requested_host,
38 IPC::Message* reply_msg);
40 // Sends the reply message about the search provider install state.
41 void ReplyWithProviderInstallState(const GURL& page_location,
42 const GURL& requested_host,
43 IPC::Message* reply_msg);
45 // Used to do a load and get information about install states.
46 SearchProviderInstallData provider_data_;
48 // Copied from the profile since the profile can't be accessed on the I/O
50 const bool is_off_the_record_;
52 // Used to schedule invocations of ReplyWithProviderInstallState.
53 base::WeakPtrFactory<SearchProviderInstallStateMessageFilter> weak_factory_;
55 DISALLOW_COPY_AND_ASSIGN(SearchProviderInstallStateMessageFilter);
58 #endif // CHROME_BROWSER_SEARCH_ENGINES_SEARCH_PROVIDER_INSTALL_STATE_MESSAGE_FILTER_H_