Home | History | Annotate | Download | only in search_engines
      1 // Copyright (c) 2010 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.
      4 
      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_
      7 
      8 #include "chrome/browser/search_engines/search_provider_install_data.h"
      9 #include "chrome/common/search_provider.h"
     10 #include "content/browser/browser_message_filter.h"
     11 
     12 class GURL;
     13 class Profile;
     14 
     15 // Handles messages regarding search provider install state on the I/O thread.
     16 class SearchProviderInstallStateMessageFilter : public BrowserMessageFilter {
     17  public:
     18   // Unlike the other methods, the constructor is called on the UI thread.
     19   SearchProviderInstallStateMessageFilter(int render_process_id,
     20                                           Profile* profile);
     21   ~SearchProviderInstallStateMessageFilter();
     22 
     23   // BrowserMessageFilter implementation.
     24   virtual bool OnMessageReceived(const IPC::Message& message,
     25                                  bool* message_was_ok);
     26 
     27  private:
     28   // Figures out the install state for the search provider.
     29    search_provider::InstallState GetSearchProviderInstallState(
     30       const GURL& page_location,
     31       const GURL& requested_host);
     32 
     33   // Starts handling the message requesting the search provider install state.
     34   void OnMsgGetSearchProviderInstallState(const GURL& page_location,
     35                                           const GURL& requested_host,
     36                                           IPC::Message* reply_msg);
     37 
     38   // Sends the reply message about the search provider install state.
     39   void ReplyWithProviderInstallState(const GURL& page_location,
     40                                      const GURL& requested_host,
     41                                      IPC::Message* reply_msg);
     42 
     43   // Used to schedule invocations of ReplyWithProviderInstallState.
     44   ScopedRunnableMethodFactory<SearchProviderInstallStateMessageFilter>
     45       reply_with_provider_install_state_factory_;
     46 
     47   // Used to do a load and get information about install states.
     48   SearchProviderInstallData provider_data_;
     49 
     50   // Copied from the profile since the profile can't be accessed on the I/O
     51   // thread.
     52   const bool is_off_the_record_;
     53 
     54   DISALLOW_COPY_AND_ASSIGN(SearchProviderInstallStateMessageFilter);
     55 };
     56 
     57 #endif  // CHROME_BROWSER_SEARCH_ENGINES_SEARCH_PROVIDER_INSTALL_STATE_MESSAGE_FILTER_H_
     58