Skip to content

Commit

Permalink
Promotes metro related functions to MetroViewerProcessHost
Browse files Browse the repository at this point in the history
Since all these functions need the MetroViewerProcessHost it makes
more sense to put them here.

BUG=none
TEST=none
R=ananta@chromium.org

Review URL: https://codereview.chromium.org/294043011

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@273418 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
sky@chromium.org committed May 29, 2014
1 parent 5ccac3b commit 1279d3b
Show file tree
Hide file tree
Showing 14 changed files with 366 additions and 346 deletions.
2 changes: 1 addition & 1 deletion chrome/browser/browser_process_platform_part_aurawin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ void BrowserProcessPlatformPart::Observe(
chrome::ActivateDesktopHelper(chrome::ASH_TERMINATE);
} else {
// Metro -> Metro
aura::HandleMetroExit();
ChromeMetroViewerProcessHost::HandleMetroExit();
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion chrome/browser/lifetime/application_lifetime_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ void ActivateDesktopHelper(AshExecutionStatus ash_execution_status) {
// Actually launching the process needs to happen in the metro viewer,
// otherwise it won't automatically transition to desktop. So we have
// to send an IPC to the viewer to do the ShellExecute.
HandleActivateDesktop(path, ash_execution_status == ASH_TERMINATE);
ChromeMetroViewerProcessHost::HandleActivateDesktop(
path, ash_execution_status == ASH_TERMINATE);
}
#endif

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,28 +67,14 @@ void OpenURL(const GURL& url) {

} // namespace

void HandleActivateDesktop(const base::FilePath& path, bool ash_exit) {
if (ChromeMetroViewerProcessHost::instance()) {
ChromeMetroViewerProcessHost::instance()->Send(
new MetroViewerHostMsg_ActivateDesktop(path, ash_exit));
}
}

// static
ChromeMetroViewerProcessHost* ChromeMetroViewerProcessHost::instance_ = NULL;

ChromeMetroViewerProcessHost::ChromeMetroViewerProcessHost()
: MetroViewerProcessHost(
content::BrowserThread::GetMessageLoopProxyForThread(
content::BrowserThread::IO)) {
chrome::IncrementKeepAliveCount();
DCHECK(instance_ == NULL);
instance_ = this;
}

ChromeMetroViewerProcessHost::~ChromeMetroViewerProcessHost() {
DCHECK(instance_ == this);
instance_ = NULL;
}

void ChromeMetroViewerProcessHost::OnChannelError() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,15 @@ namespace base {
class FilePath;
}

// Handles the activate desktop command for Metro Chrome Ash. The |ash_exit|
// parameter indicates whether the Ash process would be shutdown after
// activating the desktop.
void HandleActivateDesktop(const base::FilePath& shortcut, bool ash_exit);

class ChromeMetroViewerProcessHost : public win8::MetroViewerProcessHost {
public:
ChromeMetroViewerProcessHost();
virtual ~ChromeMetroViewerProcessHost();

// Returns the singleton ChromeMetroViewerProcessHost instance. This may
// return NULL.
static ChromeMetroViewerProcessHost* instance() {
return instance_;
}

private:
// win8::MetroViewerProcessHost implementation
virtual void OnChannelError() OVERRIDE;

// IPC::Listener implementation
virtual void OnChannelConnected(int32 peer_pid) OVERRIDE;
virtual void OnSetTargetSurface(gfx::NativeViewId target_surface,
Expand All @@ -39,8 +29,6 @@ class ChromeMetroViewerProcessHost : public win8::MetroViewerProcessHost {
const base::string16& search_string) OVERRIDE;
virtual void OnWindowSizeChanged(uint32 width, uint32 height) OVERRIDE;

static ChromeMetroViewerProcessHost* instance_;

DISALLOW_COPY_AND_ASSIGN(ChromeMetroViewerProcessHost);
};

Expand Down
6 changes: 3 additions & 3 deletions ui/aura/aura_export.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef UI_AURA_AURA_EXPORT_H
#define UI_AURA_AURA_EXPORT_H
#ifndef UI_AURA_AURA_EXPORT_H_
#define UI_AURA_AURA_EXPORT_H_

// Defines AURA_EXPORT so that functionality implemented by the aura module
// can be exported to consumers.
Expand All @@ -29,4 +29,4 @@
#define AURA_EXPORT
#endif

#endif // UI_AURA_AURA_EXPORT_H
#endif // UI_AURA_AURA_EXPORT_H_
204 changes: 1 addition & 203 deletions ui/aura/remote_window_tree_host_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -82,64 +82,6 @@ void FillCompositionText(

} // namespace

void HandleOpenFile(const base::string16& title,
const base::FilePath& default_path,
const base::string16& filter,
const OpenFileCompletion& on_success,
const FileSelectionCanceled& on_failure) {
DCHECK(aura::RemoteWindowTreeHostWin::Instance());
aura::RemoteWindowTreeHostWin::Instance()->HandleOpenFile(title,
default_path,
filter,
on_success,
on_failure);
}

void HandleOpenMultipleFiles(const base::string16& title,
const base::FilePath& default_path,
const base::string16& filter,
const OpenMultipleFilesCompletion& on_success,
const FileSelectionCanceled& on_failure) {
DCHECK(aura::RemoteWindowTreeHostWin::Instance());
aura::RemoteWindowTreeHostWin::Instance()->HandleOpenMultipleFiles(
title,
default_path,
filter,
on_success,
on_failure);
}

void HandleSaveFile(const base::string16& title,
const base::FilePath& default_path,
const base::string16& filter,
int filter_index,
const base::string16& default_extension,
const SaveFileCompletion& on_success,
const FileSelectionCanceled& on_failure) {
DCHECK(aura::RemoteWindowTreeHostWin::Instance());
aura::RemoteWindowTreeHostWin::Instance()->HandleSaveFile(title,
default_path,
filter,
filter_index,
default_extension,
on_success,
on_failure);
}

void HandleSelectFolder(const base::string16& title,
const SelectFolderCompletion& on_success,
const FileSelectionCanceled& on_failure) {
DCHECK(aura::RemoteWindowTreeHostWin::Instance());
aura::RemoteWindowTreeHostWin::Instance()->HandleSelectFolder(title,
on_success,
on_failure);
}

void HandleMetroExit() {
DCHECK(aura::RemoteWindowTreeHostWin::Instance());
aura::RemoteWindowTreeHostWin::Instance()->HandleMetroExit();
}

RemoteWindowTreeHostWin* g_instance = NULL;

// static
Expand Down Expand Up @@ -215,14 +157,6 @@ bool RemoteWindowTreeHostWin::OnMessageReceived(const IPC::Message& message) {
OnTouchUp)
IPC_MESSAGE_HANDLER(MetroViewerHostMsg_TouchMoved,
OnTouchMoved)
IPC_MESSAGE_HANDLER(MetroViewerHostMsg_FileSaveAsDone,
OnFileSaveAsDone)
IPC_MESSAGE_HANDLER(MetroViewerHostMsg_FileOpenDone,
OnFileOpenDone)
IPC_MESSAGE_HANDLER(MetroViewerHostMsg_MultiFileOpenDone,
OnMultiFileOpenDone)
IPC_MESSAGE_HANDLER(MetroViewerHostMsg_SelectFolderDone,
OnSelectFolderDone)
IPC_MESSAGE_HANDLER(MetroViewerHostMsg_SetCursorPosAck,
OnSetCursorPosAck)
IPC_MESSAGE_HANDLER(MetroViewerHostMsg_ImeCandidatePopupChanged,
Expand All @@ -246,98 +180,6 @@ void RemoteWindowTreeHostWin::HandleOpenURLOnDesktop(
host_->Send(new MetroViewerHostMsg_OpenURLOnDesktop(shortcut, url));
}

void RemoteWindowTreeHostWin::HandleMetroExit() {
if (!host_)
return;
host_->Send(new MetroViewerHostMsg_MetroExit());
}

void RemoteWindowTreeHostWin::HandleOpenFile(
const base::string16& title,
const base::FilePath& default_path,
const base::string16& filter,
const OpenFileCompletion& on_success,
const FileSelectionCanceled& on_failure) {
if (!host_)
return;

// Can only have one of these operations in flight.
DCHECK(file_open_completion_callback_.is_null());
DCHECK(failure_callback_.is_null());

file_open_completion_callback_ = on_success;
failure_callback_ = on_failure;

host_->Send(new MetroViewerHostMsg_DisplayFileOpen(title,
filter,
default_path,
false));
}

void RemoteWindowTreeHostWin::HandleOpenMultipleFiles(
const base::string16& title,
const base::FilePath& default_path,
const base::string16& filter,
const OpenMultipleFilesCompletion& on_success,
const FileSelectionCanceled& on_failure) {
if (!host_)
return;

// Can only have one of these operations in flight.
DCHECK(multi_file_open_completion_callback_.is_null());
DCHECK(failure_callback_.is_null());
multi_file_open_completion_callback_ = on_success;
failure_callback_ = on_failure;

host_->Send(new MetroViewerHostMsg_DisplayFileOpen(title,
filter,
default_path,
true));
}

void RemoteWindowTreeHostWin::HandleSaveFile(
const base::string16& title,
const base::FilePath& default_path,
const base::string16& filter,
int filter_index,
const base::string16& default_extension,
const SaveFileCompletion& on_success,
const FileSelectionCanceled& on_failure) {
if (!host_)
return;

MetroViewerHostMsg_SaveAsDialogParams params;
params.title = title;
params.default_extension = default_extension;
params.filter = filter;
params.filter_index = filter_index;
params.suggested_name = default_path;

// Can only have one of these operations in flight.
DCHECK(file_saveas_completion_callback_.is_null());
DCHECK(failure_callback_.is_null());
file_saveas_completion_callback_ = on_success;
failure_callback_ = on_failure;

host_->Send(new MetroViewerHostMsg_DisplayFileSaveAs(params));
}

void RemoteWindowTreeHostWin::HandleSelectFolder(
const base::string16& title,
const SelectFolderCompletion& on_success,
const FileSelectionCanceled& on_failure) {
if (!host_)
return;

// Can only have one of these operations in flight.
DCHECK(select_folder_completion_callback_.is_null());
DCHECK(failure_callback_.is_null());
select_folder_completion_callback_ = on_success;
failure_callback_ = on_failure;

host_->Send(new MetroViewerHostMsg_DisplaySelectFolder(title));
}

void RemoteWindowTreeHostWin::HandleWindowSizeChanged(uint32 width,
uint32 height) {
SetBounds(gfx::Rect(0, 0, width, height));
Expand Down Expand Up @@ -396,7 +238,7 @@ void RemoteWindowTreeHostWin::SetCursorNative(gfx::NativeCursor native_cursor) {
if (!host_)
return;
host_->Send(
new MetroViewerHostMsg_SetCursor(uint64(native_cursor.platform())));
new MetroViewerHostMsg_SetCursor(uint64(native_cursor.platform())));
}

void RemoteWindowTreeHostWin::MoveCursorToNative(const gfx::Point& location) {
Expand Down Expand Up @@ -591,50 +433,6 @@ void RemoteWindowTreeHostWin::OnTouchMoved(int32 x,
SendEventToProcessor(&event);
}

void RemoteWindowTreeHostWin::OnFileSaveAsDone(bool success,
const base::FilePath& filename,
int filter_index) {
if (success)
file_saveas_completion_callback_.Run(filename, filter_index, NULL);
else
failure_callback_.Run(NULL);
file_saveas_completion_callback_.Reset();
failure_callback_.Reset();
}


void RemoteWindowTreeHostWin::OnFileOpenDone(bool success,
const base::FilePath& filename) {
if (success)
file_open_completion_callback_.Run(base::FilePath(filename), 0, NULL);
else
failure_callback_.Run(NULL);
file_open_completion_callback_.Reset();
failure_callback_.Reset();
}

void RemoteWindowTreeHostWin::OnMultiFileOpenDone(
bool success,
const std::vector<base::FilePath>& files) {
if (success)
multi_file_open_completion_callback_.Run(files, NULL);
else
failure_callback_.Run(NULL);
multi_file_open_completion_callback_.Reset();
failure_callback_.Reset();
}

void RemoteWindowTreeHostWin::OnSelectFolderDone(
bool success,
const base::FilePath& folder) {
if (success)
select_folder_completion_callback_.Run(base::FilePath(folder), 0, NULL);
else
failure_callback_.Run(NULL);
select_folder_completion_callback_.Reset();
failure_callback_.Reset();
}

void RemoteWindowTreeHostWin::OnSetCursorPosAck() {
DCHECK(ignore_mouse_moves_until_set_cursor_ack_);
ignore_mouse_moves_until_set_cursor_ack_ = false;
Expand Down
Loading

0 comments on commit 1279d3b

Please sign in to comment.