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