Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(96)

Side by Side Diff: chrome/browser/search_engines/search_provider_install_state_dispatcher_host.cc

Issue 3117034: Skeleton of sync handler on the I/O thread for GetSearchProviderInstallState. (Closed)
Patch Set: Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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 #include "chrome/browser/search_engines/search_provider_install_state_dispatcher _host.h"
6
7 #include "base/logging.h"
8 #include "chrome/browser/chrome_thread.h"
9 #include "chrome/browser/profile.h"
10 #include "chrome/browser/renderer_host/render_view_host.h"
11 #include "chrome/browser/renderer_host/resource_message_filter.h"
12 #include "chrome/common/render_messages.h"
13 #include "ipc/ipc_message.h"
14 #include "googleurl/src/gurl.h"
15
16 SearchProviderInstallStateDispatcherHost::
17 SearchProviderInstallStateDispatcherHost(
18 ResourceMessageFilter* ipc_sender,
19 Profile* profile)
20 : ipc_sender_(ipc_sender),
21 is_off_the_record_(profile->IsOffTheRecord()) {
22 // This is initialized by ResourceMessageFilter. Do not add any non-trivial
23 // initialization here. Instead do it lazily when required.
24 DCHECK(ipc_sender);
25 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
26 }
27
28 SearchProviderInstallStateDispatcherHost::
29 ~SearchProviderInstallStateDispatcherHost() {
30 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO));
31 }
32
33 void SearchProviderInstallStateDispatcherHost::Send(IPC::Message* message) {
34 ipc_sender_->Send(message);
35 }
36
37 bool SearchProviderInstallStateDispatcherHost::OnMessageReceived(
38 const IPC::Message& message,
39 bool* message_was_ok) {
40 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO));
41 bool handled = true;
42 IPC_BEGIN_MESSAGE_MAP_EX(SearchProviderInstallStateDispatcherHost, message,
43 *message_was_ok)
44 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_GetSearchProviderInstallState,
45 OnMsgGetSearchProviderInstallState)
46 IPC_MESSAGE_UNHANDLED(handled = false)
47 IPC_END_MESSAGE_MAP()
48 return handled;
49 }
50
51 ViewHostMsg_GetSearchProviderInstallState_Params
52 SearchProviderInstallStateDispatcherHost::GetSearchProviderInstallState(
53 const GURL& page_location,
54 const GURL& requested_host) {
55 GURL requested_origin = requested_host.GetOrigin();
56
57 // Do the security check before any others to avoid information leaks.
58 if (page_location.GetOrigin() != requested_origin)
59 return ViewHostMsg_GetSearchProviderInstallState_Params::Denied();
60
61 // In incognito mode, no search information is exposed. (This check must be
62 // done after the security check or else a web site can detect that the
63 // user is in incognito mode just by doing a cross origin request.)
64 if (is_off_the_record_)
65 return ViewHostMsg_GetSearchProviderInstallState_Params::NotInstalled();
66
67 // TODO(levin): Real logic goes here.
68 return ViewHostMsg_GetSearchProviderInstallState_Params::NotInstalled();
69 }
70
71 void
72 SearchProviderInstallStateDispatcherHost::OnMsgGetSearchProviderInstallState(
73 const GURL& page_location,
74 const GURL& requested_host,
75 IPC::Message* reply_msg) {
76 ViewHostMsg_GetSearchProviderInstallState_Params install_state =
77 GetSearchProviderInstallState(page_location, requested_host);
78 ReplyWithProviderInstallState(reply_msg, install_state);
79 }
80
81 void SearchProviderInstallStateDispatcherHost::ReplyWithProviderInstallState(
82 IPC::Message* reply_msg,
83 ViewHostMsg_GetSearchProviderInstallState_Params install_state) {
84 DCHECK(reply_msg);
85
86 ViewHostMsg_GetSearchProviderInstallState::WriteReplyParams(
87 reply_msg,
88 install_state);
89 Send(reply_msg);
90 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698