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

Side by Side Diff: chrome/browser/automation/chrome_frame_automation_provider.cc

Issue 12220101: Minimal Chrome Frame with Aura. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: revert install_worker.cc to un-break win64 build Created 7 years, 9 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 | Annotate | Revision Log
OLDNEW
(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 #include "chrome/browser/automation/chrome_frame_automation_provider.h"
6
7 #include <algorithm>
8
9 #include "base/command_line.h"
10 #include "base/strings/string_number_conversions.h"
11 #include "chrome/browser/browser_process.h"
12 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/profiles/profile_manager.h"
14 #include "chrome/common/automation_messages.h"
15 #include "chrome/common/chrome_switches.h"
16 #include "ipc/ipc_channel.h"
17 #include "ipc/ipc_message.h"
18
19 const int kMaxChromeShutdownDelaySeconds = 60*60;
20
21 ChromeFrameAutomationProvider::ChromeFrameAutomationProvider(Profile* profile)
22 : AutomationProvider(profile) {
23 DCHECK(g_browser_process);
24 if (g_browser_process)
25 g_browser_process->AddRefModule();
26 }
27
28 ChromeFrameAutomationProvider::~ChromeFrameAutomationProvider() {
29 DCHECK(g_browser_process);
30 if (g_browser_process) {
31 CommandLine& cmd_line = *CommandLine::ForCurrentProcess();
32
33 CommandLine::StringType shutdown_delay(
34 cmd_line.GetSwitchValueNative(switches::kChromeFrameShutdownDelay));
35 if (!shutdown_delay.empty()) {
36 VLOG(1) << "ChromeFrameAutomationProvider: "
37 "Scheduling ReleaseBrowserProcess.";
38
39 // Grab the specified shutdown delay.
40 int shutdown_delay_seconds = 0;
41 base::StringToInt(shutdown_delay, &shutdown_delay_seconds);
42
43 // Clamp to reasonable values.
44 shutdown_delay_seconds = std::max(0, shutdown_delay_seconds);
45 shutdown_delay_seconds = std::min(shutdown_delay_seconds,
46 kMaxChromeShutdownDelaySeconds);
47
48 // We have Chrome Frame defer Chrome shutdown for a time to improve
49 // intra-page load times.
50 // Note that we are tracking the perf impact of this under
51 // http://crbug.com/98506
52 MessageLoop::current()->PostDelayedTask(
53 FROM_HERE,
54 base::Bind(&ChromeFrameAutomationProvider::ReleaseBrowserProcess),
55 base::TimeDelta::FromSeconds(shutdown_delay_seconds));
56 } else {
57 VLOG(1) << "ChromeFrameAutomationProvider: "
58 "Releasing browser module with no delay.";
59 g_browser_process->ReleaseModule();
60 }
61 }
62 }
63
64 bool ChromeFrameAutomationProvider::OnMessageReceived(
65 const IPC::Message& message) {
66 if (IsValidMessage(message.type()))
67 return AutomationProvider::OnMessageReceived(message);
68
69 OnUnhandledMessage(message);
70 return false;
71 }
72
73 void ChromeFrameAutomationProvider::OnUnhandledMessage(
74 const IPC::Message& message) {
75 NOTREACHED() << __FUNCTION__
76 << " Unhandled message type: "
77 << message.type();
78 }
79
80 bool ChromeFrameAutomationProvider::IsValidMessage(uint32 type) {
81 bool is_valid_message = false;
82
83 switch (type) {
84 case AutomationMsg_CreateExternalTab::ID:
85 case AutomationMsg_ConnectExternalTab::ID:
86 #if defined(OS_WIN)
87 case AutomationMsg_BrowserMove::ID:
88 case AutomationMsg_ProcessUnhandledAccelerator::ID:
89 case AutomationMsg_ForwardContextMenuCommandToChrome::ID:
90 #endif // defined(OS_WIN)
91 #if defined(OS_WIN)
92 case AutomationMsg_TabReposition::ID:
93 #endif
94 case AutomationMsg_NavigateInExternalTab::ID:
95 case AutomationMsg_NavigateExternalTabAtIndex::ID:
96 case AutomationMsg_Find::ID:
97 case AutomationMsg_SetInitialFocus::ID:
98 case AutomationMsg_SetPageFontSize::ID:
99 case AutomationMsg_SetProxyConfig::ID:
100 case AutomationMsg_Cut::ID:
101 case AutomationMsg_Copy::ID:
102 case AutomationMsg_Paste::ID:
103 case AutomationMsg_SelectAll::ID:
104 case AutomationMsg_ReloadAsync::ID:
105 case AutomationMsg_StopAsync::ID:
106 case AutomationMsg_PrintAsync::ID:
107 case AutomationMsg_HandleUnused::ID:
108 case AutomationMsg_HandleMessageFromExternalHost::ID:
109 case AutomationMsg_RequestStarted::ID:
110 case AutomationMsg_RequestData::ID:
111 case AutomationMsg_RequestEnd::ID:
112 case AutomationMsg_SaveAsAsync::ID:
113 case AutomationMsg_RemoveBrowsingData::ID:
114 case AutomationMsg_OverrideEncoding::ID:
115 case AutomationMsg_RunUnloadHandlers::ID:
116 case AutomationMsg_SetZoomLevel::ID: {
117 is_valid_message = true;
118 break;
119 }
120
121 default:
122 break;
123 }
124
125 return is_valid_message;
126 }
127
128 // static
129 void ChromeFrameAutomationProvider::ReleaseBrowserProcess() {
130 if (g_browser_process) {
131 VLOG(1) << "ChromeFrameAutomationProvider: "
132 "Releasing browser process.";
133 g_browser_process->ReleaseModule();
134 }
135 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698