• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
3 // found in the LICENSE file.
4 
5 #include "chrome/browser/automation/chrome_frame_automation_provider.h"
6 #include "chrome/browser/profiles/profile.h"
7 #include "chrome/browser/profiles/profile_manager.h"
8 #include "chrome/common/automation_messages.h"
9 #include "ipc/ipc_message.h"
10 #include "ipc/ipc_channel.h"
11 
ChromeFrameAutomationProvider(Profile * profile)12 ChromeFrameAutomationProvider::ChromeFrameAutomationProvider(Profile* profile)
13     : AutomationProvider(profile) {}
14 
OnMessageReceived(const IPC::Message & message)15 bool ChromeFrameAutomationProvider::OnMessageReceived(
16     const IPC::Message& message) {
17   if (IsValidMessage(message.type()))
18     return AutomationProvider::OnMessageReceived(message);
19 
20   OnUnhandledMessage(message);
21   return false;
22 }
23 
OnUnhandledMessage(const IPC::Message & message)24 void ChromeFrameAutomationProvider::OnUnhandledMessage(
25     const IPC::Message& message) {
26   NOTREACHED() << __FUNCTION__
27                << " Unhandled message type: "
28                << message.type();
29 }
30 
IsValidMessage(uint32 type)31 bool ChromeFrameAutomationProvider::IsValidMessage(uint32 type) {
32   bool is_valid_message = false;
33 
34   switch (type) {
35     case AutomationMsg_CreateExternalTab::ID:
36     case AutomationMsg_ConnectExternalTab::ID:
37 #if defined(OS_WIN)
38     case AutomationMsg_BrowserMove::ID:
39     case AutomationMsg_ProcessUnhandledAccelerator::ID:
40     case AutomationMsg_TabReposition::ID:
41     case AutomationMsg_ForwardContextMenuCommandToChrome::ID:
42 #endif  // defined(OS_WIN)
43     case AutomationMsg_NavigateInExternalTab::ID:
44     case AutomationMsg_NavigateExternalTabAtIndex::ID:
45     case AutomationMsg_Find::ID:
46     case AutomationMsg_SetInitialFocus::ID:
47     case AutomationMsg_SetPageFontSize::ID:
48     case AutomationMsg_SetProxyConfig::ID:
49     case AutomationMsg_Cut::ID:
50     case AutomationMsg_Copy::ID:
51     case AutomationMsg_Paste::ID:
52     case AutomationMsg_SelectAll::ID:
53     case AutomationMsg_ReloadAsync::ID:
54     case AutomationMsg_StopAsync::ID:
55     case AutomationMsg_PrintAsync::ID:
56     case AutomationMsg_HandleUnused::ID:
57     case AutomationMsg_HandleMessageFromExternalHost::ID:
58     case AutomationMsg_RequestStarted::ID:
59     case AutomationMsg_RequestData::ID:
60     case AutomationMsg_RequestEnd::ID:
61     case AutomationMsg_SaveAsAsync::ID:
62     case AutomationMsg_RemoveBrowsingData::ID:
63     case AutomationMsg_OverrideEncoding::ID:
64     case AutomationMsg_RunUnloadHandlers::ID:
65     case AutomationMsg_SetZoomLevel::ID: {
66       is_valid_message = true;
67       break;
68     }
69 
70     default:
71       break;
72   }
73 
74   return is_valid_message;
75 }
76