| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_SEARCH_ENGINES_SEARCH_PROVIDER_INSTALL_STATE_IMPL_H_ | |
| 6 #define CHROME_BROWSER_SEARCH_ENGINES_SEARCH_PROVIDER_INSTALL_STATE_IMPL_H_ | |
| 7 | |
| 8 #include "base/callback_forward.h" | |
| 9 #include "base/macros.h" | |
| 10 #include "base/memory/weak_ptr.h" | |
| 11 #include "chrome/browser/search_engines/search_provider_install_data.h" | |
| 12 #include "chrome/common/search_provider.mojom.h" | |
| 13 #include "content/public/browser/browser_message_filter.h" | |
| 14 #include "mojo/public/cpp/bindings/strong_binding.h" | |
| 15 | |
| 16 class GURL; | |
| 17 class Profile; | |
| 18 | |
| 19 namespace content { | |
| 20 class RenderProcessHost; | |
| 21 } // namespace content | |
| 22 | |
| 23 // Handles messages regarding search provider install state on the I/O thread. | |
| 24 class SearchProviderInstallStateImpl | |
| 25 : public chrome::mojom::SearchProviderInstallState { | |
| 26 public: | |
| 27 // Unlike the other methods, the constructor must be called on the UI thread. | |
| 28 SearchProviderInstallStateImpl(int render_process_id, Profile* profile); | |
| 29 ~SearchProviderInstallStateImpl() override; | |
| 30 | |
| 31 static void Create(int render_process_id, | |
| 32 Profile* profile, | |
| 33 chrome::mojom::SearchProviderInstallStateRequest request); | |
| 34 | |
| 35 private: | |
| 36 void BindOnIOThread(chrome::mojom::SearchProviderInstallStateRequest request); | |
| 37 | |
| 38 // Figures out the install state for the search provider. | |
| 39 chrome::mojom::InstallState GetSearchProviderInstallState( | |
| 40 const GURL& page_location, | |
| 41 const GURL& requested_host); | |
| 42 | |
| 43 // Starts handling the message requesting the search provider install state. | |
| 44 // chrome::mojom::SearchProviderInstallState override. | |
| 45 void GetInstallState(const GURL& page_location, | |
| 46 const GURL& requested_host, | |
| 47 const GetInstallStateCallback& callback) override; | |
| 48 | |
| 49 // Sends the reply message about the search provider install state. | |
| 50 void ReplyWithProviderInstallState(const GURL& page_location, | |
| 51 const GURL& requested_host, | |
| 52 const GetInstallStateCallback& callback); | |
| 53 | |
| 54 // Used to do a load and get information about install states. | |
| 55 SearchProviderInstallData provider_data_; | |
| 56 | |
| 57 // Copied from the profile since the profile can't be accessed on the I/O | |
| 58 // thread. | |
| 59 const bool is_off_the_record_; | |
| 60 | |
| 61 mojo::StrongBinding<chrome::mojom::SearchProviderInstallState> binding_; | |
| 62 | |
| 63 // Used to schedule invocations of ReplyWithProviderInstallState. | |
| 64 base::WeakPtrFactory<SearchProviderInstallStateImpl> weak_factory_; | |
| 65 | |
| 66 DISALLOW_COPY_AND_ASSIGN(SearchProviderInstallStateImpl); | |
| 67 }; | |
| 68 | |
| 69 #endif // CHROME_BROWSER_SEARCH_ENGINES_SEARCH_PROVIDER_INSTALL_STATE_IMPL_H_ | |
| OLD | NEW |