diff options
author | Torne (Richard Coles) <torne@google.com> | 2014-02-21 12:16:55 +0000 |
---|---|---|
committer | Torne (Richard Coles) <torne@google.com> | 2014-02-21 12:16:55 +0000 |
commit | 5d1f7b1de12d16ceb2c938c56701a3e8bfa558f7 (patch) | |
tree | 5d4ae202b870bd86673f596f0d424bc4b3e55ebe /win8 | |
parent | e862bac9c33104a29d98631d62668ae7b6676510 (diff) | |
download | chromium_org-5d1f7b1de12d16ceb2c938c56701a3e8bfa558f7.tar.gz |
Merge from Chromium at DEPS revision 251904
This commit was generated by merge_to_master.py.
Change-Id: I1f9543259d7d2a57d81aa41a1b84f85837439d21
Diffstat (limited to 'win8')
54 files changed, 818 insertions, 612 deletions
diff --git a/win8/delegate_execute/chrome_util.cc b/win8/delegate_execute/chrome_util.cc index 3695b3331f..89d869d361 100644 --- a/win8/delegate_execute/chrome_util.cc +++ b/win8/delegate_execute/chrome_util.cc @@ -45,10 +45,10 @@ const wchar_t kRegPathChromeClientBase[] = // use by a browser process. // TODO(grt): Move this somewhere central so it can be used by both this // IsBrowserRunning (below) and IsBrowserAlreadyRunning (browser_util_win.cc). -string16 GetEventName(const base::FilePath& chrome_exe) { +base::string16 GetEventName(const base::FilePath& chrome_exe) { static wchar_t const kEventPrefix[] = L"Global\\"; const size_t prefix_len = arraysize(kEventPrefix) - 1; - string16 name; + base::string16 name; name.reserve(prefix_len + chrome_exe.value().size()); name.assign(kEventPrefix, prefix_len); name.append(chrome_exe.value()); @@ -80,10 +80,10 @@ bool NewChromeExeExists(const base::FilePath& chrome_exe) { return base::PathExists(new_chrome_exe); } -bool GetUpdateCommand(bool is_per_user, string16* update_command) { +bool GetUpdateCommand(bool is_per_user, base::string16* update_command) { const HKEY root = is_per_user ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE; BrowserDistribution* dist = BrowserDistribution::GetDistribution(); - string16 reg_path_chrome_client = kRegPathChromeClientBase; + base::string16 reg_path_chrome_client = kRegPathChromeClientBase; reg_path_chrome_client.append(dist->GetAppGuid()); base::win::RegKey key(root, reg_path_chrome_client.c_str(), KEY_QUERY_VALUE); @@ -107,7 +107,7 @@ void UpdateChromeIfNeeded(const base::FilePath& chrome_exe) { if (InstallUtil::IsPerUserInstall(chrome_exe.value().c_str())) { // Read the update command from the registry. - string16 update_command; + base::string16 update_command; if (!GetUpdateCommand(true, &update_command)) { AtlTrace("%hs. Failed to read update command from registry.\n", __FUNCTION__); diff --git a/win8/delegate_execute/command_execute_impl.cc b/win8/delegate_execute/command_execute_impl.cc index cb68f54e57..0d05dc517e 100644 --- a/win8/delegate_execute/command_execute_impl.cc +++ b/win8/delegate_execute/command_execute_impl.cc @@ -33,10 +33,9 @@ #include "win8/viewer/metro_viewer_constants.h" namespace { - // Helper function to retrieve the url from IShellItem interface passed in. // Returns S_OK on success. -HRESULT GetUrlFromShellItem(IShellItem* shell_item, string16* url) { +HRESULT GetUrlFromShellItem(IShellItem* shell_item, base::string16* url) { DCHECK(shell_item); DCHECK(url); // First attempt to get the url from the underlying IDataObject if any. This @@ -66,7 +65,6 @@ HRESULT GetUrlFromShellItem(IShellItem* shell_item, string16* url) { return S_OK; } -#if defined(USE_AURA) bool LaunchChromeBrowserProcess() { base::FilePath delegate_exe_path; if (!PathService::Get(base::FILE_EXE, &delegate_exe_path)) @@ -104,7 +102,6 @@ bool LaunchChromeBrowserProcess() { return base::LaunchProcess(cl, launch_options, NULL); } -#endif // defined(USE_AURA) } // namespace @@ -137,12 +134,10 @@ bool CommandExecuteImpl::path_provider_initialized_ = false; // 5- Windows calls CommandExecuteImpl::Getvalue() // Here we need to return AHE_IMMERSIVE or AHE_DESKTOP. That depends on: // a) if run in high-integrity return AHE_DESKTOP -// b) if chrome is running return the AHE_ mode of chrome -// c) else we return what GetLaunchMode() tells us, which is: +// b) else we return what GetLaunchMode() tells us, which is: // i) if the command line --force-xxx is present return that // ii) if the registry 'launch_mode' exists return that -// iii) if IsTouchEnabledDevice() is true return AHE_IMMERSIVE -// iv) else return AHE_DESKTOP +// iii) else return AHE_DESKTOP // 6- If we returned AHE_IMMERSIVE in step 5 windows might not call us back // and simply activate chrome in metro by itself, however in some cases // it might proceed at step 7. @@ -161,15 +156,10 @@ bool CommandExecuteImpl::path_provider_initialized_ = false; // in the registry so next time the logic reaches 5c-ii it will use the same // mode again. // -// Also note that if we are not the default browser and IsTouchEnabledDevice() -// returns true, launching chrome can go all the way to 7c, which might be -// a slow way to start chrome. -// CommandExecuteImpl::CommandExecuteImpl() : parameters_(CommandLine::NO_PROGRAM), launch_scheme_(INTERNET_SCHEME_DEFAULT), - integrity_level_(base::INTEGRITY_UNKNOWN), - chrome_mode_(ECHUIM_SYSTEM_LAUNCHER) { + integrity_level_(base::INTEGRITY_UNKNOWN) { memset(&start_info_, 0, sizeof(start_info_)); start_info_.cb = sizeof(start_info_); @@ -184,127 +174,43 @@ CommandExecuteImpl::CommandExecuteImpl() // CommandExecuteImpl STDMETHODIMP CommandExecuteImpl::SetKeyState(DWORD key_state) { - AtlTrace("In %hs\n", __FUNCTION__); return S_OK; } STDMETHODIMP CommandExecuteImpl::SetParameters(LPCWSTR params) { - AtlTrace("In %hs [%S]\n", __FUNCTION__, params); parameters_ = delegate_execute::CommandLineFromParameters(params); return S_OK; } STDMETHODIMP CommandExecuteImpl::SetPosition(POINT pt) { - AtlTrace("In %hs\n", __FUNCTION__); return S_OK; } STDMETHODIMP CommandExecuteImpl::SetShowWindow(int show) { - AtlTrace("In %hs show=%d\n", __FUNCTION__, show); start_info_.wShowWindow = show; start_info_.dwFlags |= STARTF_USESHOWWINDOW; return S_OK; } STDMETHODIMP CommandExecuteImpl::SetNoShowUI(BOOL no_show_ui) { - AtlTrace("In %hs no_show=%d\n", __FUNCTION__, no_show_ui); return S_OK; } STDMETHODIMP CommandExecuteImpl::SetDirectory(LPCWSTR directory) { - AtlTrace("In %hs\n", __FUNCTION__); return S_OK; } STDMETHODIMP CommandExecuteImpl::GetValue(enum AHE_TYPE* pahe) { - AtlTrace("In %hs\n", __FUNCTION__); - if (!GetLaunchScheme(&display_name_, &launch_scheme_)) { AtlTrace("Failed to get scheme, E_FAIL\n"); return E_FAIL; } - if (integrity_level_ == base::HIGH_INTEGRITY) { - // Metro mode apps don't work in high integrity mode. - AtlTrace("High integrity, AHE_DESKTOP\n"); - *pahe = AHE_DESKTOP; - return S_OK; - } - - if (GetAsyncKeyState(VK_SHIFT) && GetAsyncKeyState(VK_F11)) { - AtlTrace("Using Shift-F11 debug hook, returning AHE_IMMERSIVE\n"); - *pahe = AHE_IMMERSIVE; - -#if defined(USE_AURA) - // Launch the chrome browser process that metro chrome will connect to. - LaunchChromeBrowserProcess(); -#endif - - return S_OK; - } - - if (GetAsyncKeyState(VK_SHIFT) && GetAsyncKeyState(VK_F12)) { - AtlTrace("Using Shift-F12 debug hook, returning AHE_DESKTOP\n"); - *pahe = AHE_DESKTOP; - return S_OK; - } - - base::FilePath user_data_dir; - if (!PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)) { - AtlTrace("Failed to get chrome's data dir path, E_FAIL\n"); - return E_FAIL; - } - - bool decision_made = false; - - // New Aura/Ash world we don't want to go throgh FindWindow path - // and instead take decision based on launch mode. -#if !defined(USE_AURA) - HWND chrome_window = base::win::MessageWindow::FindWindow( - user_data_dir.value()); - if (chrome_window) { - AtlTrace("Found chrome window %p\n", chrome_window); - // The failure cases below are deemed to happen due to the inherently racy - // procedure of going from chrome's window to process handle during which - // chrome might have exited. Failing here would probably just cause the - // user to retry at which point we would do the right thing. - DWORD chrome_pid = 0; - ::GetWindowThreadProcessId(chrome_window, &chrome_pid); - if (!chrome_pid) { - AtlTrace("Failed to get chrome's PID, E_FAIL\n"); - return E_FAIL; - } - base::win::ScopedHandle process( - ::OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, chrome_pid)); - if (!process.IsValid()) { - AtlTrace("Failed to open chrome's process [%d], E_FAIL\n", chrome_pid); - return E_FAIL; - } - - if (IsImmersiveProcess(process.Get())) { - AtlTrace("Chrome [%d] is inmmersive, AHE_IMMERSIVE\n", chrome_pid); - chrome_mode_ = ECHUIM_IMMERSIVE; - *pahe = AHE_IMMERSIVE; - } else { - AtlTrace("Chrome [%d] is Desktop, AHE_DESKTOP\n"); - chrome_mode_ = ECHUIM_DESKTOP; - *pahe = AHE_DESKTOP; - } - - decision_made = true; - } -#endif - - if (!decision_made) { - EC_HOST_UI_MODE mode = GetLaunchMode(); - *pahe = (mode == ECHUIM_DESKTOP) ? AHE_DESKTOP : AHE_IMMERSIVE; - } + EC_HOST_UI_MODE mode = GetLaunchMode(); + *pahe = (mode == ECHUIM_DESKTOP) ? AHE_DESKTOP : AHE_IMMERSIVE; -#if defined(USE_AURA) if (*pahe == AHE_IMMERSIVE && verb_ != win8::kMetroViewerConnectVerb) LaunchChromeBrowserProcess(); -#endif - return S_OK; } @@ -329,12 +235,12 @@ STDMETHODIMP CommandExecuteImpl::Execute() { BrowserDistribution* distribution = BrowserDistribution::GetDistribution(); bool is_per_user_install = InstallUtil::IsPerUserInstall( chrome_exe_.value().c_str()); - string16 app_id = ShellUtil::GetBrowserModelId( + base::string16 app_id = ShellUtil::GetBrowserModelId( distribution, is_per_user_install); DWORD pid = 0; if (launch_scheme_ == INTERNET_SCHEME_FILE && - display_name_.find(installer::kChromeExe) != string16::npos) { + display_name_.find(installer::kChromeExe) != base::string16::npos) { AtlTrace("Activating for file\n"); hr = activation_manager->ActivateApplication(app_id.c_str(), verb_.c_str(), @@ -356,10 +262,10 @@ STDMETHODIMP CommandExecuteImpl::Execute() { STDMETHODIMP CommandExecuteImpl::Initialize(LPCWSTR name, IPropertyBag* bag) { - AtlTrace("In %hs\n", __FUNCTION__); if (!FindChromeExe(&chrome_exe_)) return E_FAIL; delegate_execute::UpdateChromeIfNeeded(chrome_exe_); + if (name) { AtlTrace("Verb is %S\n", name); verb_ = name; @@ -367,32 +273,25 @@ STDMETHODIMP CommandExecuteImpl::Initialize(LPCWSTR name, base::GetProcessIntegrityLevel(base::GetCurrentProcessHandle(), &integrity_level_); - if (integrity_level_ == base::HIGH_INTEGRITY) { - AtlTrace("Delegate execute launched in high integrity level\n"); - } return S_OK; } STDMETHODIMP CommandExecuteImpl::SetSelection(IShellItemArray* item_array) { - AtlTrace("In %hs\n", __FUNCTION__); item_array_ = item_array; return S_OK; } STDMETHODIMP CommandExecuteImpl::GetSelection(REFIID riid, void** selection) { - AtlTrace("In %hs\n", __FUNCTION__); return S_OK; } STDMETHODIMP CommandExecuteImpl::AllowForegroundTransfer(void* reserved) { - AtlTrace("In %hs\n", __FUNCTION__); return S_OK; } // Returns false if chrome.exe cannot be found. // static bool CommandExecuteImpl::FindChromeExe(base::FilePath* chrome_exe) { - AtlTrace("In %hs\n", __FUNCTION__); // Look for chrome.exe one folder above delegate_execute.exe (as expected in // Chrome installs). Failing that, look for it alonside delegate_execute.exe. base::FilePath dir_exe; @@ -409,13 +308,11 @@ bool CommandExecuteImpl::FindChromeExe(base::FilePath* chrome_exe) { return false; } } - - AtlTrace("Got chrome exe path as %ls\n", chrome_exe->value().c_str()); return true; } bool CommandExecuteImpl::GetLaunchScheme( - string16* display_name, INTERNET_SCHEME* scheme) { + base::string16* display_name, INTERNET_SCHEME* scheme) { if (!item_array_) return false; @@ -445,8 +342,6 @@ bool CommandExecuteImpl::GetLaunchScheme( return false; } - AtlTrace("url [%ls]\n", display_name->c_str()); - wchar_t scheme_name[16]; URL_COMPONENTS components = {0}; components.lpszScheme = scheme_name; @@ -464,8 +359,7 @@ bool CommandExecuteImpl::GetLaunchScheme( } HRESULT CommandExecuteImpl::LaunchDesktopChrome() { - AtlTrace("In %hs\n", __FUNCTION__); - string16 display_name = display_name_; + base::string16 display_name = display_name_; switch (launch_scheme_) { case INTERNET_SCHEME_FILE: @@ -473,7 +367,7 @@ HRESULT CommandExecuteImpl::LaunchDesktopChrome() { // should honor it. For e.g. If the user clicks on a html file when // chrome is the default we should treat it as a parameter to be passed // to chrome. - if (display_name.find(installer::kChromeExe) != string16::npos) + if (display_name.find(installer::kChromeExe) != base::string16::npos) display_name.clear(); break; @@ -484,7 +378,7 @@ HRESULT CommandExecuteImpl::LaunchDesktopChrome() { CommandLine chrome( delegate_execute::MakeChromeCommandLine(chrome_exe_, parameters_, display_name)); - string16 command_line(chrome.GetCommandLineString()); + base::string16 command_line(chrome.GetCommandLineString()); AtlTrace("Formatted command line is %ls\n", command_line.c_str()); @@ -514,13 +408,22 @@ EC_HOST_UI_MODE CommandExecuteImpl::GetLaunchMode() { if (launch_mode_determined) return launch_mode; - if (chrome_mode_ != ECHUIM_SYSTEM_LAUNCHER) { - launch_mode = chrome_mode_; - AtlTrace("Launch mode is that of chrome, %s\n", modes[launch_mode]); + if (integrity_level_ == base::HIGH_INTEGRITY) { + // Metro mode apps don't work in high integrity mode. + AtlTrace("High integrity: launching in desktop mode\n"); + launch_mode = ECHUIM_DESKTOP; + launch_mode_determined = true; + return launch_mode; + } + if (GetAsyncKeyState(VK_SHIFT) && GetAsyncKeyState(VK_F11)) { + AtlTrace("Hotkey: launching in immersive mode\n"); + launch_mode = ECHUIM_IMMERSIVE; launch_mode_determined = true; return launch_mode; } + // From here on, if we can, we will write the outcome + // of this function to the registry. if (parameters_.HasSwitch(switches::kForceImmersive)) { launch_mode = ECHUIM_IMMERSIVE; launch_mode_determined = true; @@ -540,6 +443,8 @@ EC_HOST_UI_MODE CommandExecuteImpl::GetLaunchMode() { chrome::kMetroRegistryPath, key_result); if (!launch_mode_determined) { + // If we cannot open the key and we don't know the + // launch mode we default to desktop mode. launch_mode = ECHUIM_DESKTOP; launch_mode_determined = true; } @@ -553,11 +458,12 @@ EC_HOST_UI_MODE CommandExecuteImpl::GetLaunchMode() { return launch_mode; } + // Use the previous mode if available. Else launch in desktop mode. DWORD reg_value; if (reg_key.ReadValueDW(chrome::kLaunchModeValue, ®_value) != ERROR_SUCCESS) { launch_mode = ECHUIM_DESKTOP; - AtlTrace("Launch mode forced by heuristics to %s\n", modes[launch_mode]); + AtlTrace("Can't read registry, defaulting to %s\n", modes[launch_mode]); } else if (reg_value >= ECHUIM_SYSTEM_LAUNCHER) { AtlTrace("Invalid registry launch mode value %u\n", reg_value); launch_mode = ECHUIM_DESKTOP; diff --git a/win8/delegate_execute/command_execute_impl.h b/win8/delegate_execute/command_execute_impl.h index 7b1490b21d..f27bf7a763 100644 --- a/win8/delegate_execute/command_execute_impl.h +++ b/win8/delegate_execute/command_execute_impl.h @@ -88,7 +88,7 @@ class ATL_NO_VTABLE DECLSPEC_UUID("071BB5F2-85A4-424F-BFE7-5F1609BE4C2C") static bool path_provider_initialized_; - bool GetLaunchScheme(string16* display_name, INTERNET_SCHEME* scheme); + bool GetLaunchScheme(base::string16* display_name, INTERNET_SCHEME* scheme); HRESULT LaunchDesktopChrome(); // Returns the launch mode, i.e. desktop launch/metro launch, etc. EC_HOST_UI_MODE GetLaunchMode(); @@ -97,12 +97,11 @@ class ATL_NO_VTABLE DECLSPEC_UUID("071BB5F2-85A4-424F-BFE7-5F1609BE4C2C") CommandLine parameters_; base::FilePath chrome_exe_; STARTUPINFO start_info_; - string16 verb_; - string16 display_name_; + base::string16 verb_; + base::string16 display_name_; INTERNET_SCHEME launch_scheme_; base::IntegrityLevel integrity_level_; - EC_HOST_UI_MODE chrome_mode_; }; OBJECT_ENTRY_AUTO(__uuidof(CommandExecuteImpl), CommandExecuteImpl) diff --git a/win8/delegate_execute/crash_server_init.cc b/win8/delegate_execute/crash_server_init.cc index 7689316429..646c57bbba 100644 --- a/win8/delegate_execute/crash_server_init.cc +++ b/win8/delegate_execute/crash_server_init.cc @@ -70,12 +70,12 @@ scoped_ptr<google_breakpad::ExceptionHandler> InitializeCrashReporting() { wchar_t temp_path[MAX_PATH + 1] = {0}; DWORD path_len = ::GetTempPath(MAX_PATH, temp_path); - string16 pipe_name; + base::string16 pipe_name; pipe_name = kGoogleUpdatePipeName; if (IsRunningSystemInstall()) { pipe_name += kSystemPrincipalSid; } else { - string16 user_sid; + base::string16 user_sid; if (base::win::GetUserSidString(&user_sid)) { pipe_name += user_sid; } else { diff --git a/win8/delegate_execute/delegate_execute.cc b/win8/delegate_execute/delegate_execute.cc index ddb9883daa..837505b7c4 100644 --- a/win8/delegate_execute/delegate_execute.cc +++ b/win8/delegate_execute/delegate_execute.cc @@ -47,7 +47,7 @@ class DelegateExecuteModule HRESULT PreMessageLoop(int nShowCmd) { HRESULT hr = S_OK; - string16 clsid_string; + base::string16 clsid_string; GUID clsid; BrowserDistribution* dist = BrowserDistribution::GetDistribution(); if (!dist->GetCommandExecuteImplClsid(&clsid_string)) @@ -121,7 +121,7 @@ int RelaunchChrome(const DelegateExecuteOperation& operation) { base::win::ScopedCOMInitializer com_initializer; - string16 relaunch_flags(operation.relaunch_flags()); + base::string16 relaunch_flags(operation.relaunch_flags()); SHELLEXECUTEINFO sei = { sizeof(sei) }; sei.fMask = SEE_MASK_FLAG_LOG_USAGE; sei.nShow = SW_SHOWNORMAL; diff --git a/win8/delegate_execute/delegate_execute.gyp b/win8/delegate_execute/delegate_execute.gyp index 935534f0a8..6230920046 100644 --- a/win8/delegate_execute/delegate_execute.gyp +++ b/win8/delegate_execute/delegate_execute.gyp @@ -45,6 +45,7 @@ '../../content/content.gyp:content_common', '../../google_update/google_update.gyp:google_update', '../../ui/gfx/gfx.gyp:gfx', + '../../ui/gfx/gfx.gyp:gfx_geometry', '../../ui/ui.gyp:ui', '../../win8/win8.gyp:check_sdk_patch', 'delegate_execute_version_resources', diff --git a/win8/delegate_execute/delegate_execute_operation.cc b/win8/delegate_execute/delegate_execute_operation.cc index a7333125ba..91e5effdc6 100644 --- a/win8/delegate_execute/delegate_execute_operation.cc +++ b/win8/delegate_execute/delegate_execute_operation.cc @@ -45,7 +45,7 @@ bool DelegateExecuteOperation::Init(const CommandLine* cmd_line) { } DWORD DelegateExecuteOperation::GetParentPid() const { - std::vector<string16> parts; + std::vector<base::string16> parts; base::SplitString(mutex_, L'.', &parts); if (parts.size() != 3) return 0; diff --git a/win8/delegate_execute/delegate_execute_operation.h b/win8/delegate_execute/delegate_execute_operation.h index 7d1456cef5..91e2231f72 100644 --- a/win8/delegate_execute/delegate_execute_operation.h +++ b/win8/delegate_execute/delegate_execute_operation.h @@ -49,11 +49,11 @@ class DelegateExecuteOperation { return operation_type_; } - const string16& relaunch_flags() const { + const base::string16& relaunch_flags() const { return relaunch_flags_; } - const string16& mutex() const { + const base::string16& mutex() const { return mutex_; } @@ -66,9 +66,9 @@ class DelegateExecuteOperation { private: OperationType operation_type_; - string16 relaunch_flags_; + base::string16 relaunch_flags_; base::FilePath relaunch_shortcut_; - string16 mutex_; + base::string16 mutex_; DISALLOW_COPY_AND_ASSIGN(DelegateExecuteOperation); }; diff --git a/win8/delegate_execute/delegate_execute_util.cc b/win8/delegate_execute/delegate_execute_util.cc index 6a3dc048db..c3097a2a5a 100644 --- a/win8/delegate_execute/delegate_execute_util.cc +++ b/win8/delegate_execute/delegate_execute_util.cc @@ -13,7 +13,7 @@ CommandLine CommandLineFromParameters(const wchar_t* params) { CommandLine command_line(CommandLine::NO_PROGRAM); if (params) { - string16 command_string(L"noprogram.exe "); + base::string16 command_string(L"noprogram.exe "); command_string.append(params); command_line.ParseFromString(command_string); command_line.SetProgram(base::FilePath()); @@ -24,7 +24,7 @@ CommandLine CommandLineFromParameters(const wchar_t* params) { CommandLine MakeChromeCommandLine(const base::FilePath& chrome_exe, const CommandLine& params, - const string16& argument) { + const base::string16& argument) { CommandLine chrome_cmd(params); chrome_cmd.SetProgram(chrome_exe); @@ -34,15 +34,15 @@ CommandLine MakeChromeCommandLine(const base::FilePath& chrome_exe, return chrome_cmd; } -string16 ParametersFromSwitch(const char* a_switch) { +base::string16 ParametersFromSwitch(const char* a_switch) { if (!a_switch) - return string16(); + return base::string16(); CommandLine cmd_line(CommandLine::NO_PROGRAM); cmd_line.AppendSwitch(a_switch); - string16 command_string(cmd_line.GetCommandLineString()); + base::string16 command_string(cmd_line.GetCommandLineString()); TrimWhitespace(command_string, TRIM_ALL, &command_string); return command_string; } diff --git a/win8/delegate_execute/delegate_execute_util.h b/win8/delegate_execute/delegate_execute_util.h index adb2e7acc9..4f32e9697c 100644 --- a/win8/delegate_execute/delegate_execute_util.h +++ b/win8/delegate_execute/delegate_execute_util.h @@ -21,11 +21,11 @@ CommandLine CommandLineFromParameters(const wchar_t* params); // from |params| plus an optional |argument|. CommandLine MakeChromeCommandLine(const base::FilePath& chrome_exe, const CommandLine& params, - const string16& argument); + const base::string16& argument); // Returns a properly quoted command-line string less the program (argv[0]) // containing |switch|. -string16 ParametersFromSwitch(const char* a_switch); +base::string16 ParametersFromSwitch(const char* a_switch); } // namespace delegate_execute diff --git a/win8/delegate_execute/delegate_execute_util_unittest.cc b/win8/delegate_execute/delegate_execute_util_unittest.cc index f01b15757b..40a2e7144b 100644 --- a/win8/delegate_execute/delegate_execute_util_unittest.cc +++ b/win8/delegate_execute/delegate_execute_util_unittest.cc @@ -28,7 +28,8 @@ TEST(DelegateExecuteUtil, CommandLineFromParametersTest) { // Parameters with a switch are parsed properly. cl = delegate_execute::CommandLineFromParameters( - base::StringPrintf(L"--%ls", ASCIIToWide(kSomeSwitch).c_str()).c_str()); + base::StringPrintf(L"--%ls", + base::ASCIIToWide(kSomeSwitch).c_str()).c_str()); EXPECT_EQ(std::wstring(), cl.GetProgram().value()); EXPECT_TRUE(cl.HasSwitch(kSomeSwitch)); } @@ -42,38 +43,42 @@ TEST(DelegateExecuteUtil, MakeChromeCommandLineTest) { // Empty params and argument contains only the exe. cl = delegate_execute::MakeChromeCommandLine( - this_exe, delegate_execute::CommandLineFromParameters(NULL), string16()); + this_exe, + delegate_execute::CommandLineFromParameters(NULL), + base::string16()); EXPECT_EQ(1, cl.argv().size()); EXPECT_EQ(this_exe.value(), cl.GetProgram().value()); // Empty params with arg contains the arg. cl = delegate_execute::MakeChromeCommandLine( this_exe, delegate_execute::CommandLineFromParameters(NULL), - string16(kSomeArgument)); + base::string16(kSomeArgument)); EXPECT_EQ(2, cl.argv().size()); EXPECT_EQ(this_exe.value(), cl.GetProgram().value()); EXPECT_EQ(1, cl.GetArgs().size()); - EXPECT_EQ(string16(kSomeArgument), cl.GetArgs()[0]); + EXPECT_EQ(base::string16(kSomeArgument), cl.GetArgs()[0]); // Params with switchs and args plus arg contains the arg. cl = delegate_execute::MakeChromeCommandLine( this_exe, delegate_execute::CommandLineFromParameters( - base::StringPrintf(L"--%ls -- %ls", ASCIIToWide(kSomeSwitch).c_str(), + base::StringPrintf(L"--%ls -- %ls", + base::ASCIIToWide(kSomeSwitch).c_str(), kOtherArgument).c_str()), - string16(kSomeArgument)); + base::string16(kSomeArgument)); EXPECT_EQ(5, cl.argv().size()); EXPECT_EQ(this_exe.value(), cl.GetProgram().value()); EXPECT_TRUE(cl.HasSwitch(kSomeSwitch)); CommandLine::StringVector args(cl.GetArgs()); EXPECT_EQ(2, args.size()); + EXPECT_NE( + args.end(), + std::find(args.begin(), args.end(), base::string16(kOtherArgument))); EXPECT_NE(args.end(), - std::find(args.begin(), args.end(), string16(kOtherArgument))); - EXPECT_NE(args.end(), - std::find(args.begin(), args.end(), string16(kSomeArgument))); + std::find(args.begin(), args.end(), base::string16(kSomeArgument))); } TEST(DelegateExecuteUtil, ParametersFromSwitchTest) { - EXPECT_EQ(string16(), delegate_execute::ParametersFromSwitch(NULL)); - EXPECT_EQ(string16(L"--some-switch"), + EXPECT_EQ(base::string16(), delegate_execute::ParametersFromSwitch(NULL)); + EXPECT_EQ(base::string16(L"--some-switch"), delegate_execute::ParametersFromSwitch(kSomeSwitch)); } diff --git a/win8/metro_driver/chrome_app_view.cc b/win8/metro_driver/chrome_app_view.cc index 79bd58474b..3a9d23ec0f 100644 --- a/win8/metro_driver/chrome_app_view.cc +++ b/win8/metro_driver/chrome_app_view.cc @@ -819,7 +819,7 @@ ChromeAppView::Run() { } // Create a message loop to allow message passing into this thread. - base::MessageLoop msg_loop(base::MessageLoop::TYPE_UI); + base::MessageLoopForUI msg_loop; // Announce our message loop to the world. globals.appview_msg_loop = msg_loop.message_loop_proxy(); @@ -1088,8 +1088,8 @@ HRESULT ChromeAppView::OnShareDataRequested( return E_FAIL; } - string16 current_title(current_tab_info.title); - string16 current_url(current_tab_info.url); + base::string16 current_title(current_tab_info.title); + base::string16 current_url(current_tab_info.url); LocalFree(current_tab_info.title); LocalFree(current_tab_info.url); diff --git a/win8/metro_driver/chrome_app_view.h b/win8/metro_driver/chrome_app_view.h index 0554ab3136..77d6781592 100644 --- a/win8/metro_driver/chrome_app_view.h +++ b/win8/metro_driver/chrome_app_view.h @@ -155,8 +155,8 @@ struct Globals { HANDLE host_thread; ChromeAppView* view; WNDPROC g_core_proc; - string16 navigation_url; - string16 search_string; + base::string16 navigation_url; + base::string16 search_string; winapp::Activation::ApplicationExecutionState previous_state; winapp::Activation::ActivationKind initial_activation_kind; bool is_initial_activation; @@ -164,7 +164,7 @@ struct Globals { // to be initiated from that thread, notably spawning file pickers. base::MessageLoopProxy* appview_msg_loop; winapp::Core::ICoreApplicationExit* app_exit; - string16 metro_command_line_switches; + base::string16 metro_command_line_switches; }; extern Globals globals; diff --git a/win8/metro_driver/chrome_app_view_ash.cc b/win8/metro_driver/chrome_app_view_ash.cc index 91eec0a848..9b7e6b67ca 100644 --- a/win8/metro_driver/chrome_app_view_ash.cc +++ b/win8/metro_driver/chrome_app_view_ash.cc @@ -24,6 +24,7 @@ #include "ui/events/gestures/gesture_sequence.h" #include "ui/metro_viewer/metro_viewer_messages.h" #include "win8/metro_driver/file_picker_ash.h" +#include "win8/metro_driver/ime/ime_popup_monitor.h" #include "win8/metro_driver/ime/input_source.h" #include "win8/metro_driver/ime/text_service.h" #include "win8/metro_driver/metro_driver.h" @@ -156,6 +157,7 @@ class ChromeChannelListener : public IPC::Listener { IPC_BEGIN_MESSAGE_MAP(ChromeChannelListener, message) IPC_MESSAGE_HANDLER(MetroViewerHostMsg_ActivateDesktop, OnActivateDesktop) + IPC_MESSAGE_HANDLER(MetroViewerHostMsg_MetroExit, OnMetroExit) IPC_MESSAGE_HANDLER(MetroViewerHostMsg_OpenURLOnDesktop, OnOpenURLOnDesktop) IPC_MESSAGE_HANDLER(MetroViewerHostMsg_SetCursor, OnSetCursor) @@ -193,8 +195,12 @@ class ChromeChannelListener : public IPC::Listener { shortcut, ash_exit)); } + void OnMetroExit() { + MetroExit(app_view_->core_window_hwnd()); + } + void OnOpenURLOnDesktop(const base::FilePath& shortcut, - const string16& url) { + const base::string16& url) { ui_proxy_->PostTask(FROM_HERE, base::Bind(&ChromeAppViewAsh::OnOpenURLOnDesktop, base::Unretained(app_view_), @@ -208,8 +214,8 @@ class ChromeChannelListener : public IPC::Listener { reinterpret_cast<HCURSOR>(cursor))); } - void OnDisplayFileOpenDialog(const string16& title, - const string16& filter, + void OnDisplayFileOpenDialog(const base::string16& title, + const base::string16& filter, const base::FilePath& default_path, bool allow_multiple_files) { ui_proxy_->PostTask(FROM_HERE, @@ -230,7 +236,7 @@ class ChromeChannelListener : public IPC::Listener { params)); } - void OnDisplayFolderPicker(const string16& title) { + void OnDisplayFolderPicker(const base::string16& title) { ui_proxy_->PostTask( FROM_HERE, base::Bind(&ChromeAppViewAsh::OnDisplayFolderPicker, @@ -279,8 +285,86 @@ bool WaitForChromeIPCConnection(const std::string& channel_name) { return IPC::Channel::IsNamedServerInitialized(channel_name); } +void RunMessageLoop(winui::Core::ICoreDispatcher* dispatcher) { + // We're entering a nested message loop, let's allow dispatching + // tasks while we're in there. + base::MessageLoop::current()->SetNestableTasksAllowed(true); + + // Enter main core message loop. There are several ways to exit it + // Nicely: + // 1 - User action like ALT-F4. + // 2 - Calling ICoreApplicationExit::Exit(). + // 3- Posting WM_CLOSE to the core window. + HRESULT hr = dispatcher->ProcessEvents( + winui::Core::CoreProcessEventsOption + ::CoreProcessEventsOption_ProcessUntilQuit); + + // Wind down the thread's chrome message loop. + base::MessageLoop::current()->Quit(); +} + +// Helper to return the state of the shift/control/alt keys. +uint32 GetKeyboardEventFlags() { + uint32 flags = 0; + if (base::win::IsShiftPressed()) + flags |= ui::EF_SHIFT_DOWN; + if (base::win::IsCtrlPressed()) + flags |= ui::EF_CONTROL_DOWN; + if (base::win::IsAltPressed()) + flags |= ui::EF_ALT_DOWN; + return flags; +} + +bool LaunchChromeBrowserProcess(const wchar_t* additional_parameters, + winapp::Activation::IActivatedEventArgs* args) { + if (args) { + DVLOG(1) << __FUNCTION__ << ":" << ::GetCommandLineW(); + winapp::Activation::ActivationKind activation_kind; + CheckHR(args->get_Kind(&activation_kind)); + + DVLOG(1) << __FUNCTION__ << ", activation_kind=" << activation_kind; + + if (activation_kind == winapp::Activation::ActivationKind_Launch) { + mswr::ComPtr<winapp::Activation::ILaunchActivatedEventArgs> launch_args; + if (args->QueryInterface( + winapp::Activation::IID_ILaunchActivatedEventArgs, + &launch_args) == S_OK) { + DVLOG(1) << "Activate: ActivationKind_Launch"; + mswrw::HString launch_args_str; + launch_args->get_Arguments(launch_args_str.GetAddressOf()); + base::string16 actual_launch_args( + MakeStdWString(launch_args_str.Get())); + if (actual_launch_args == win8::kMetroViewerConnectVerb) { + DVLOG(1) << __FUNCTION__ << "Not launching chrome server"; + return true; + } + } + } + } + + DVLOG(1) << "Launching chrome server"; + base::FilePath chrome_exe_path; + + if (!PathService::Get(base::FILE_EXE, &chrome_exe_path)) + return false; + + base::string16 parameters = L"--silent-launch --viewer-connect "; + if (additional_parameters) + parameters += additional_parameters; + + SHELLEXECUTEINFO sei = { sizeof(sei) }; + sei.nShow = SW_SHOWNORMAL; + sei.lpFile = chrome_exe_path.value().c_str(); + sei.lpDirectory = L""; + sei.lpParameters = parameters.c_str(); + ::ShellExecuteEx(&sei); + return true; +} + +} // namespace + // This class helps decoding the pointer properties of an event. -class PointerInfoHandler { +class ChromeAppViewAsh::PointerInfoHandler { public: PointerInfoHandler() : x_(0), @@ -288,7 +372,9 @@ class PointerInfoHandler { wheel_delta_(0), update_kind_(winui::Input::PointerUpdateKind_Other), timestamp_(0), - pointer_id_(0) {} + pointer_id_(0), + mouse_down_flags_(0), + is_horizontal_wheel_(0) {} HRESULT Init(winui::Core::IPointerEventArgs* args) { HRESULT hr = args->get_CurrentPoint(&pointer_point_); @@ -312,13 +398,40 @@ class PointerInfoHandler { hr = properties->get_MouseWheelDelta(&wheel_delta_); if (FAILED(hr)) return hr; + + is_horizontal_wheel_ = 0; + properties->get_IsHorizontalMouseWheel(&is_horizontal_wheel_); + x_ = point.X; y_ = point.Y; + pointer_point_->get_Timestamp(×tamp_); pointer_point_->get_PointerId(&pointer_id_); // Map the OS touch event id to a range allowed by the gesture recognizer. if (IsTouch()) pointer_id_ %= ui::GestureSequence::kMaxGesturePoints; + + boolean left_button_state; + hr = properties->get_IsLeftButtonPressed(&left_button_state); + if (FAILED(hr)) + return hr; + if (left_button_state) + mouse_down_flags_ |= ui::EF_LEFT_MOUSE_BUTTON; + + boolean right_button_state; + hr = properties->get_IsRightButtonPressed(&right_button_state); + if (FAILED(hr)) + return hr; + if (right_button_state) + mouse_down_flags_ |= ui::EF_RIGHT_MOUSE_BUTTON; + + boolean middle_button_state; + hr = properties->get_IsMiddleButtonPressed(&middle_button_state); + if (FAILED(hr)) + return hr; + if (middle_button_state) + mouse_down_flags_ |= ui::EF_MIDDLE_MOUSE_BUTTON; + return S_OK; } @@ -342,7 +455,8 @@ class PointerInfoHandler { return wheel_delta_; } - ui::EventFlags flags() { + // Identifies the button that changed. + ui::EventFlags changed_button() const { switch (update_kind_) { case winui::Input::PointerUpdateKind_LeftButtonPressed: return ui::EF_LEFT_MOUSE_BUTTON; @@ -358,9 +472,11 @@ class PointerInfoHandler { return ui::EF_MIDDLE_MOUSE_BUTTON; default: return ui::EF_NONE; - }; + } } + uint32 mouse_down_flags() const { return mouse_down_flags_; } + int x() const { return x_; } int y() const { return y_; } @@ -370,6 +486,10 @@ class PointerInfoHandler { uint64 timestamp() const { return timestamp_; } + winui::Input::PointerUpdateKind update_kind() const { return update_kind_; } + + bool is_horizontal_wheel() const { return !!is_horizontal_wheel_; } + private: int x_; int y_; @@ -378,90 +498,21 @@ class PointerInfoHandler { winui::Input::PointerUpdateKind update_kind_; mswr::ComPtr<winui::Input::IPointerPoint> pointer_point_; uint64 timestamp_; -}; - -void RunMessageLoop(winui::Core::ICoreDispatcher* dispatcher) { - // We're entering a nested message loop, let's allow dispatching - // tasks while we're in there. - base::MessageLoop::current()->SetNestableTasksAllowed(true); - - // Enter main core message loop. There are several ways to exit it - // Nicely: - // 1 - User action like ALT-F4. - // 2 - Calling ICoreApplicationExit::Exit(). - // 3- Posting WM_CLOSE to the core window. - HRESULT hr = dispatcher->ProcessEvents( - winui::Core::CoreProcessEventsOption - ::CoreProcessEventsOption_ProcessUntilQuit); - - // Wind down the thread's chrome message loop. - base::MessageLoop::current()->Quit(); -} - -// Helper to return the state of the shift/control/alt keys. -uint32 GetKeyboardEventFlags() { - uint32 flags = 0; - if (base::win::IsShiftPressed()) - flags |= ui::EF_SHIFT_DOWN; - if (base::win::IsCtrlPressed()) - flags |= ui::EF_CONTROL_DOWN; - if (base::win::IsAltPressed()) - flags |= ui::EF_ALT_DOWN; - return flags; -} - -bool LaunchChromeBrowserProcess(const wchar_t* additional_parameters, - winapp::Activation::IActivatedEventArgs* args) { - if (args) { - DVLOG(1) << __FUNCTION__ << ":" << ::GetCommandLineW(); - winapp::Activation::ActivationKind activation_kind; - CheckHR(args->get_Kind(&activation_kind)); - - DVLOG(1) << __FUNCTION__ << ", activation_kind=" << activation_kind; - - if (activation_kind == winapp::Activation::ActivationKind_Launch) { - mswr::ComPtr<winapp::Activation::ILaunchActivatedEventArgs> launch_args; - if (args->QueryInterface( - winapp::Activation::IID_ILaunchActivatedEventArgs, - &launch_args) == S_OK) { - DVLOG(1) << "Activate: ActivationKind_Launch"; - mswrw::HString launch_args_str; - launch_args->get_Arguments(launch_args_str.GetAddressOf()); - string16 actual_launch_args(MakeStdWString(launch_args_str.Get())); - if (actual_launch_args == win8::kMetroViewerConnectVerb) { - DVLOG(1) << __FUNCTION__ << "Not launching chrome server"; - return true; - } - } - } - } - - DVLOG(1) << "Launching chrome server"; - base::FilePath chrome_exe_path; - if (!PathService::Get(base::FILE_EXE, &chrome_exe_path)) - return false; + // Bitmask of ui::EventFlags corresponding to the buttons that are currently + // down. + uint32 mouse_down_flags_; - string16 parameters = L"--silent-launch --viewer-connect "; - if (additional_parameters) - parameters += additional_parameters; + // Set to true for a horizontal wheel message. + boolean is_horizontal_wheel_; - SHELLEXECUTEINFO sei = { sizeof(sei) }; - sei.nShow = SW_SHOWNORMAL; - sei.lpFile = chrome_exe_path.value().c_str(); - sei.lpDirectory = L""; - sei.lpParameters = parameters.c_str(); - ::ShellExecuteEx(&sei); - return true; -} - -} // namespace + DISALLOW_COPY_AND_ASSIGN(PointerInfoHandler); +}; ChromeAppViewAsh::ChromeAppViewAsh() : mouse_down_flags_(ui::EF_NONE), ui_channel_(nullptr), - core_window_hwnd_(NULL), - ui_loop_(base::MessageLoop::TYPE_UI) { + core_window_hwnd_(NULL) { DVLOG(1) << __FUNCTION__; globals.previous_state = winapp::Activation::ApplicationExecutionState_NotRunning; @@ -639,6 +690,9 @@ ChromeAppViewAsh::Run() { OnInputSourceChanged(); } + // Start receiving IME popup window notifications. + metro_driver::AddImePopupObserver(this); + // And post the task that'll do the inner Metro message pumping to it. ui_loop_.PostTask(FROM_HERE, base::Bind(&RunMessageLoop, dispatcher.Get())); ui_loop_.Run(); @@ -650,6 +704,7 @@ ChromeAppViewAsh::Run() { IFACEMETHODIMP ChromeAppViewAsh::Uninitialize() { DVLOG(1) << __FUNCTION__; + metro_driver::RemoveImePopupObserver(this); input_source_.reset(); text_service_.reset(); window_ = nullptr; @@ -713,11 +768,13 @@ void ChromeAppViewAsh::OnActivateDesktop(const base::FilePath& file_path, ::TerminateProcess(sei.hProcess, 0); ::CloseHandle(sei.hProcess); } - ui_channel_->Send(new MetroViewerHostMsg_ActivateDesktopDone()); + + if (ash_exit) + ui_channel_->Close(); } void ChromeAppViewAsh::OnOpenURLOnDesktop(const base::FilePath& shortcut, - const string16& url) { + const base::string16& url) { base::FilePath::StringType file = shortcut.value(); SHELLEXECUTEINFO sei = { sizeof(sei) }; sei.fMask = SEE_MASK_FLAG_LOG_USAGE; @@ -733,8 +790,8 @@ void ChromeAppViewAsh::OnSetCursor(HCURSOR cursor) { } void ChromeAppViewAsh::OnDisplayFileOpenDialog( - const string16& title, - const string16& filter, + const base::string16& title, + const base::string16& filter, const base::FilePath& default_path, bool allow_multiple_files) { DVLOG(1) << __FUNCTION__; @@ -763,7 +820,7 @@ void ChromeAppViewAsh::OnDisplayFileSaveAsDialog( file_picker_->Run(); } -void ChromeAppViewAsh::OnDisplayFolderPicker(const string16& title) { +void ChromeAppViewAsh::OnDisplayFolderPicker(const base::string16& title) { DVLOG(1) << __FUNCTION__; // The FolderPickerSession instance is deleted when we receive a // callback from the FolderPickerSession class about the completion of the @@ -843,6 +900,26 @@ void ChromeAppViewAsh::OnImeUpdateTextInputClient( text_service_->OnDocumentChanged(input_scopes, character_bounds); } +void ChromeAppViewAsh::OnImePopupChanged(ImePopupObserver::EventType event) { + if (!ui_channel_) + return; + switch (event) { + case ImePopupObserver::kPopupShown: + ui_channel_->Send(new MetroViewerHostMsg_ImeCandidatePopupChanged(true)); + return; + case ImePopupObserver::kPopupHidden: + ui_channel_->Send(new MetroViewerHostMsg_ImeCandidatePopupChanged(false)); + return; + case ImePopupObserver::kPopupUpdated: + // TODO(kochi): Support this event for W3C IME API proposal. + // See crbug.com/238585. + return; + default: + NOTREACHED() << "unknown event type: " << event; + return; + } +} + void ChromeAppViewAsh::OnInputSourceChanged() { if (!input_source_) return; @@ -858,7 +935,7 @@ void ChromeAppViewAsh::OnInputSourceChanged() { } void ChromeAppViewAsh::OnCompositionChanged( - const string16& text, + const base::string16& text, int32 selection_start, int32 selection_end, const std::vector<metro_viewer::UnderlineInfo>& underlines) { @@ -866,10 +943,54 @@ void ChromeAppViewAsh::OnCompositionChanged( text, selection_start, selection_end, underlines)); } -void ChromeAppViewAsh::OnTextCommitted(const string16& text) { +void ChromeAppViewAsh::OnTextCommitted(const base::string16& text) { ui_channel_->Send(new MetroViewerHostMsg_ImeTextCommitted(text)); } +void ChromeAppViewAsh::SendMouseButton(int x, + int y, + int extra, + ui::EventType event_type, + uint32 flags, + ui::EventFlags changed_button, + bool is_horizontal_wheel) { + MetroViewerHostMsg_MouseButtonParams params; + params.x = static_cast<int32>(x); + params.y = static_cast<int32>(y); + params.extra = static_cast<int32>(extra); + params.event_type = event_type; + params.flags = static_cast<int32>(flags); + params.changed_button = changed_button; + params.is_horizontal_wheel = is_horizontal_wheel; + ui_channel_->Send(new MetroViewerHostMsg_MouseButton(params)); +} + +void ChromeAppViewAsh::GenerateMouseEventFromMoveIfNecessary( + const PointerInfoHandler& pointer) { + ui::EventType event_type; + // For aura we want the flags to include the button that was released, thus + // we or the old and new. + uint32 mouse_down_flags = pointer.mouse_down_flags() | mouse_down_flags_; + mouse_down_flags_ = pointer.mouse_down_flags(); + switch (pointer.update_kind()) { + case winui::Input::PointerUpdateKind_LeftButtonPressed: + case winui::Input::PointerUpdateKind_RightButtonPressed: + case winui::Input::PointerUpdateKind_MiddleButtonPressed: + event_type = ui::ET_MOUSE_PRESSED; + break; + case winui::Input::PointerUpdateKind_LeftButtonReleased: + case winui::Input::PointerUpdateKind_RightButtonReleased: + case winui::Input::PointerUpdateKind_MiddleButtonReleased: + event_type = ui::ET_MOUSE_RELEASED; + break; + default: + return; + } + SendMouseButton(pointer.x(), pointer.y(), 0, event_type, + mouse_down_flags | GetKeyboardEventFlags(), + pointer.changed_button(), pointer.is_horizontal_wheel()); +} + HRESULT ChromeAppViewAsh::OnActivate( winapp::Core::ICoreApplicationView*, winapp::Activation::IActivatedEventArgs* args) { @@ -908,6 +1029,7 @@ HRESULT ChromeAppViewAsh::OnPointerMoved(winui::Core::ICoreWindow* sender, return hr; if (pointer.IsMouse()) { + GenerateMouseEventFromMoveIfNecessary(pointer); ui_channel_->Send(new MetroViewerHostMsg_MouseMoved( pointer.x(), pointer.y(), @@ -926,7 +1048,8 @@ HRESULT ChromeAppViewAsh::OnPointerMoved(winui::Core::ICoreWindow* sender, // event for the first button pressed and the last button released in a sequence // of mouse events. // For example, a sequence of LEFT_DOWN, RIGHT_DOWN, LEFT_UP, RIGHT_UP results -// only in PointerPressed(LEFT)/PointerReleased(RIGHT) events. +// only in PointerPressed(LEFT)/PointerReleased(RIGHT) events. Intermediary +// presses and releases are tracked in OnPointMoved(). HRESULT ChromeAppViewAsh::OnPointerPressed( winui::Core::ICoreWindow* sender, winui::Core::IPointerEventArgs* args) { @@ -936,15 +1059,10 @@ HRESULT ChromeAppViewAsh::OnPointerPressed( return hr; if (pointer.IsMouse()) { - // TODO: this is wrong, more than one pointer may be down at a time. - mouse_down_flags_ = pointer.flags(); - ui_channel_->Send(new MetroViewerHostMsg_MouseButton( - pointer.x(), - pointer.y(), - 0, - ui::ET_MOUSE_PRESSED, - static_cast<ui::EventFlags>( - mouse_down_flags_ | GetKeyboardEventFlags()))); + mouse_down_flags_ = pointer.mouse_down_flags(); + SendMouseButton(pointer.x(), pointer.y(), 0, ui::ET_MOUSE_PRESSED, + mouse_down_flags_ | GetKeyboardEventFlags(), + pointer.changed_button(), pointer.is_horizontal_wheel()); } else { DCHECK(pointer.IsTouch()); ui_channel_->Send(new MetroViewerHostMsg_TouchDown(pointer.x(), @@ -964,15 +1082,12 @@ HRESULT ChromeAppViewAsh::OnPointerReleased( return hr; if (pointer.IsMouse()) { - // TODO: this is wrong, more than one pointer may be down at a time. mouse_down_flags_ = ui::EF_NONE; - ui_channel_->Send(new MetroViewerHostMsg_MouseButton( - pointer.x(), - pointer.y(), - 0, - ui::ET_MOUSE_RELEASED, - static_cast<ui::EventFlags>( - pointer.flags() | GetKeyboardEventFlags()))); + SendMouseButton(pointer.x(), pointer.y(), 0, ui::ET_MOUSE_RELEASED, + static_cast<uint32>(pointer.changed_button()) | + GetKeyboardEventFlags(), + pointer.changed_button(), + pointer.is_horizontal_wheel()); } else { DCHECK(pointer.IsTouch()); ui_channel_->Send(new MetroViewerHostMsg_TouchUp(pointer.x(), @@ -991,10 +1106,9 @@ HRESULT ChromeAppViewAsh::OnWheel( if (FAILED(hr)) return hr; DCHECK(pointer.IsMouse()); - ui_channel_->Send(new MetroViewerHostMsg_MouseButton(pointer.x(), pointer.y(), - pointer.wheel_delta(), - ui::ET_MOUSEWHEEL, - ui::EF_NONE)); + SendMouseButton(pointer.x(), pointer.y(), pointer.wheel_delta(), + ui::ET_MOUSEWHEEL, ui::EF_NONE, ui::EF_NONE, + pointer.is_horizontal_wheel()); return S_OK; } @@ -1136,7 +1250,7 @@ HRESULT ChromeAppViewAsh::HandleSearchRequest( mswrw::HString search_string; CheckHR(search_args->get_QueryText(search_string.GetAddressOf())); - string16 search_text(MakeStdWString(search_string.Get())); + base::string16 search_text(MakeStdWString(search_string.Get())); ui_loop_.PostTask(FROM_HERE, base::Bind(&ChromeAppViewAsh::OnSearchRequest, @@ -1161,7 +1275,7 @@ HRESULT ChromeAppViewAsh::HandleProtocolRequest( protocol_args->get_Uri(&uri); mswrw::HString url; uri->get_AbsoluteUri(url.GetAddressOf()); - string16 actual_url(MakeStdWString(url.Get())); + base::string16 actual_url(MakeStdWString(url.Get())); DVLOG(1) << "Received url request: " << actual_url; ui_loop_.PostTask(FROM_HERE, @@ -1174,20 +1288,16 @@ HRESULT ChromeAppViewAsh::HandleProtocolRequest( HRESULT ChromeAppViewAsh::OnEdgeGestureCompleted( winui::Input::IEdgeGesture* gesture, winui::Input::IEdgeGestureEventArgs* args) { - // Swipe from edge gesture (and win+z) is equivalent to pressing F11. - // TODO(cpu): Make this cleaner for m33. - ui_channel_->Send(new MetroViewerHostMsg_KeyDown(VK_F11, 1, 0, 0)); - ::Sleep(15); - ui_channel_->Send(new MetroViewerHostMsg_KeyUp(VK_F11, 1, 0, 0)); + ui_channel_->Send(new MetroViewerHostMsg_EdgeGesture()); return S_OK; } -void ChromeAppViewAsh::OnSearchRequest(const string16& search_string) { +void ChromeAppViewAsh::OnSearchRequest(const base::string16& search_string) { DCHECK(ui_channel_); ui_channel_->Send(new MetroViewerHostMsg_SearchRequest(search_string)); } -void ChromeAppViewAsh::OnNavigateToUrl(const string16& url) { +void ChromeAppViewAsh::OnNavigateToUrl(const base::string16& url) { DCHECK(ui_channel_); ui_channel_->Send(new MetroViewerHostMsg_OpenURL(url)); } diff --git a/win8/metro_driver/chrome_app_view_ash.h b/win8/metro_driver/chrome_app_view_ash.h index 7517502f30..d3472054e0 100644 --- a/win8/metro_driver/chrome_app_view_ash.h +++ b/win8/metro_driver/chrome_app_view_ash.h @@ -15,6 +15,7 @@ #include "base/strings/string16.h" #include "ui/events/event_constants.h" #include "win8/metro_driver/direct3d_helper.h" +#include "win8/metro_driver/ime/ime_popup_observer.h" #include "win8/metro_driver/ime/input_source_observer.h" #include "win8/metro_driver/ime/text_service_delegate.h" @@ -46,6 +47,7 @@ struct MetroViewerHostMsg_SaveAsDialogParams; class ChromeAppViewAsh : public mswr::RuntimeClass<winapp::Core::IFrameworkView>, + public metro_driver::ImePopupObserver, public metro_driver::InputSourceObserver, public metro_driver::TextServiceDelegate { public: @@ -64,15 +66,16 @@ class ChromeAppViewAsh static HRESULT Unsnap(); void OnActivateDesktop(const base::FilePath& file_path, bool ash_exit); - void OnOpenURLOnDesktop(const base::FilePath& shortcut, const string16& url); + void OnOpenURLOnDesktop(const base::FilePath& shortcut, + const base::string16& url); void OnSetCursor(HCURSOR cursor); - void OnDisplayFileOpenDialog(const string16& title, - const string16& filter, + void OnDisplayFileOpenDialog(const base::string16& title, + const base::string16& filter, const base::FilePath& default_path, bool allow_multiple_files); void OnDisplayFileSaveAsDialog( const MetroViewerHostMsg_SaveAsDialogParams& params); - void OnDisplayFolderPicker(const string16& title); + void OnDisplayFolderPicker(const base::string16& title); void OnSetCursorPos(int x, int y); // This function is invoked when the open file operation completes. The @@ -105,16 +108,39 @@ class ChromeAppViewAsh private: + class PointerInfoHandler; + + // ImePopupObserver overrides. + virtual void OnImePopupChanged(ImePopupObserver::EventType event) OVERRIDE; + // InputSourceObserver overrides. virtual void OnInputSourceChanged() OVERRIDE; // TextServiceDelegate overrides. virtual void OnCompositionChanged( - const string16& text, + const base::string16& text, int32 selection_start, int32 selection_end, const std::vector<metro_viewer::UnderlineInfo>& underlines) OVERRIDE; - virtual void OnTextCommitted(const string16& text) OVERRIDE; + virtual void OnTextCommitted(const base::string16& text) OVERRIDE; + + // Convenience for sending a MetroViewerHostMsg_MouseButton with the specified + // parameters. + void SendMouseButton(int x, + int y, + int extra, + ui::EventType event_type, + uint32 flags, + ui::EventFlags changed_button, + bool is_horizontal_wheel); + + // Win8 only generates a mouse press for the initial button that goes down and + // a release when the last button is released. Any intermediary presses (or + // releases) do not result in a new press/release event. Instead a move is + // generated with the winui::Input::PointerUpdateKind identifying what + // changed. This function generates the necessary intermediary events (as + // necessary). + void GenerateMouseEventFromMoveIfNecessary(const PointerInfoHandler& pointer); HRESULT OnActivate(winapp::Core::ICoreApplicationView* view, winapp::Activation::IActivatedEventArgs* args); @@ -157,8 +183,8 @@ class ChromeAppViewAsh // Tasks posted to the UI thread to initiate the search/url navigation // requests. - void OnSearchRequest(const string16& search_string); - void OnNavigateToUrl(const string16& url); + void OnSearchRequest(const base::string16& search_string); + void OnNavigateToUrl(const base::string16& url); HRESULT OnSizeChanged(winui::Core::ICoreWindow* sender, winui::Core::IWindowSizeChangedEventArgs* args); @@ -180,8 +206,9 @@ class ChromeAppViewAsh EventRegistrationToken edgeevent_token_; // Keep state about which button is currently down, if any, as PointerMoved - // events do not contain that state, but Ash's MouseEvents need it. - ui::EventFlags mouse_down_flags_; + // events do not contain that state, but Ash's MouseEvents need it. Value is + // as a bitmask of ui::EventFlags. + uint32 mouse_down_flags_; // Set the D3D swap chain and nothing else. metro_driver::Direct3DHelper direct3d_helper_; @@ -193,7 +220,7 @@ class ChromeAppViewAsh HWND core_window_hwnd_; // UI message loop to allow message passing into this thread. - base::MessageLoop ui_loop_; + base::MessageLoopForUI ui_loop_; // For IME support. scoped_ptr<metro_driver::InputSource> input_source_; diff --git a/win8/metro_driver/chrome_url_launch_handler.cc b/win8/metro_driver/chrome_url_launch_handler.cc index 897276a9b1..7c99b13f91 100644 --- a/win8/metro_driver/chrome_url_launch_handler.cc +++ b/win8/metro_driver/chrome_url_launch_handler.cc @@ -72,7 +72,7 @@ void ChromeUrlLaunchHandler::HandleSearchRequest(T* args) { DVLOG(1) << __FUNCTION__; mswrw::HString search_string; args->get_QueryText(search_string.GetAddressOf()); - string16 search_text(MakeStdWString(search_string.Get())); + base::string16 search_text(MakeStdWString(search_string.Get())); globals.search_string = search_text; DVLOG(1) << search_text.c_str(); // If this is the initial activation then we wait for Chrome to initiate the @@ -88,7 +88,7 @@ void ChromeUrlLaunchHandler::HandleProtocolLaunch( args->get_Uri(&uri); mswrw::HString url; uri->get_AbsoluteUri(url.GetAddressOf()); - string16 actual_url(MakeStdWString(url.Get())); + base::string16 actual_url(MakeStdWString(url.Get())); globals.navigation_url = actual_url; // If this is the initial activation then we wait for Chrome to initiate the @@ -100,27 +100,27 @@ void ChromeUrlLaunchHandler::HandleProtocolLaunch( // |launch_args| is an encoded command line, minus the executable name. To // find the URL to launch the first argument is used. If any other parameters // are encoded in |launch_args| they are ignored. -string16 ChromeUrlLaunchHandler::GetUrlFromLaunchArgs( - const string16& launch_args) { +base::string16 ChromeUrlLaunchHandler::GetUrlFromLaunchArgs( + const base::string16& launch_args) { if (launch_args == L"opennewwindow") { VLOG(1) << "Returning new tab url"; return L"chrome://newtab"; } - string16 dummy_command_line(L"dummy.exe "); + base::string16 dummy_command_line(L"dummy.exe "); dummy_command_line.append(launch_args); CommandLine command_line = CommandLine::FromString(dummy_command_line); CommandLine::StringVector args = command_line.GetArgs(); if (args.size() > 0) return args[0]; - return string16(); + return base::string16(); } void ChromeUrlLaunchHandler::HandleLaunch( winapp::Activation::ILaunchActivatedEventArgs* args) { mswrw::HString launch_args; args->get_Arguments(launch_args.GetAddressOf()); - string16 actual_launch_args(MakeStdWString(launch_args.Get())); + base::string16 actual_launch_args(MakeStdWString(launch_args.Get())); globals.navigation_url = GetUrlFromLaunchArgs(actual_launch_args); DVLOG(1) << __FUNCTION__ << ", launch_args=" << actual_launch_args << ", url=" << globals.navigation_url diff --git a/win8/metro_driver/chrome_url_launch_handler.h b/win8/metro_driver/chrome_url_launch_handler.h index d8c7ed01b7..093b57b932 100644 --- a/win8/metro_driver/chrome_url_launch_handler.h +++ b/win8/metro_driver/chrome_url_launch_handler.h @@ -37,7 +37,7 @@ class ChromeUrlLaunchHandler { winapp::Search::ISearchPane* search_pane, winapp::Search::ISearchPaneQuerySubmittedEventArgs* args); - string16 GetUrlFromLaunchArgs(const string16& launch_args); + base::string16 GetUrlFromLaunchArgs(const base::string16& launch_args); // Invoked when a url is navigated from a metro app or in the metro // shelf. diff --git a/win8/metro_driver/display_properties.cc b/win8/metro_driver/display_properties.cc index a7cf42794b..f1653fdbd7 100644 --- a/win8/metro_driver/display_properties.cc +++ b/win8/metro_driver/display_properties.cc @@ -16,7 +16,7 @@ extern "C" { - __declspec(dllexport) float GetModernUIScale() { +__declspec(dllexport) float GetModernUIScale() { base::win::ScopedCOMInitializer com_init; Microsoft::WRL::ComPtr< ABI::Windows::Graphics::Display::IDisplayPropertiesStatics> diff --git a/win8/metro_driver/display_properties.h b/win8/metro_driver/display_properties.h new file mode 100644 index 0000000000..1491b3fbb8 --- /dev/null +++ b/win8/metro_driver/display_properties.h @@ -0,0 +1,11 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_UI_METRO_DRIVER_DISPLAY_PROPERTIES_H_ +#define CHROME_BROWSER_UI_METRO_DRIVER_DISPLAY_PROPERTIES_H_ + +// Determines the scale factor used in the modern/metro ui. 1.0 means unscaled. +extern "C" __declspec(dllexport) float GetModernUIScale(); + +#endif // CHROME_BROWSER_UI_METRO_DRIVER_DISPLAY_PROPERTIES_H_ diff --git a/win8/metro_driver/file_picker.cc b/win8/metro_driver/file_picker.cc index cf1c878b1f..f824869f7c 100644 --- a/win8/metro_driver/file_picker.cc +++ b/win8/metro_driver/file_picker.cc @@ -30,7 +30,7 @@ class StringVectorImpl : public mswr::RuntimeClass<StringVectorItf> { std::for_each(strings_.begin(), strings_.end(), ::WindowsDeleteString); } - HRESULT RuntimeClassInitialize(const std::vector<string16>& list) { + HRESULT RuntimeClassInitialize(const std::vector<base::string16>& list) { for (size_t i = 0; i < list.size(); ++i) strings_.push_back(MakeHString(list[i])); @@ -132,7 +132,7 @@ class OpenFilePickerSession : public FilePickerSessionBase { // Composes a multi-file result string suitable for returning to a // from a storage file collection. static HRESULT ComposeMultiFileResult(StorageFileVectorCollection* files, - string16* result); + base::string16* result); private: DISALLOW_COPY_AND_ASSIGN(OpenFilePickerSession); }; @@ -243,7 +243,7 @@ HRESULT OpenFilePickerSession::MultiPickerDone(MultiFileAsyncOp* async, HRESULT hr = async->GetResults(files.GetAddressOf()); if (files) { - string16 result; + base::string16 result; if (SUCCEEDED(hr)) hr = ComposeMultiFileResult(files.Get(), &result); @@ -305,7 +305,7 @@ HRESULT OpenFilePickerSession::StartFilePicker() { break; // There can be a single extension, or a list of semicolon-separated ones. - std::vector<string16> extensions_win32_style; + std::vector<base::string16> extensions_win32_style; size_t extension_count = Tokenize(walk, L";", &extensions_win32_style); DCHECK_EQ(extension_count, extensions_win32_style.size()); @@ -318,9 +318,10 @@ HRESULT OpenFilePickerSession::StartFilePicker() { hr = extension.Set(L"*"); } else { // Metro wants suffixes only, not patterns. - string16 ext = base::FilePath(extensions_win32_style[i]).Extension(); + base::string16 ext = + base::FilePath(extensions_win32_style[i]).Extension(); if ((ext.size() < 2) || - (ext.find_first_of(L"*?") != string16::npos)) { + (ext.find_first_of(L"*?") != base::string16::npos)) { continue; } hr = extension.Set(ext.c_str()); @@ -371,7 +372,7 @@ HRESULT OpenFilePickerSession::StartFilePicker() { } HRESULT OpenFilePickerSession::ComposeMultiFileResult( - StorageFileVectorCollection* files, string16* result) { + StorageFileVectorCollection* files, base::string16* result) { DCHECK(files != NULL); DCHECK(result != NULL); @@ -475,17 +476,18 @@ HRESULT SaveFilePickerSession::StartFilePicker() { break; // There can be a single extension, or a list of semicolon-separated ones. - std::vector<string16> extensions_win32_style; + std::vector<base::string16> extensions_win32_style; size_t extension_count = Tokenize(walk, L";", &extensions_win32_style); DCHECK_EQ(extension_count, extensions_win32_style.size()); // Metro wants suffixes only, not patterns. Also, metro does not support // the all files ("*") pattern in the save picker. - std::vector<string16> extensions; + std::vector<base::string16> extensions; for (size_t i = 0; i < extensions_win32_style.size(); ++i) { - string16 ext = base::FilePath(extensions_win32_style[i]).Extension(); + base::string16 ext = + base::FilePath(extensions_win32_style[i]).Extension(); if ((ext.size() < 2) || - (ext.find_first_of(L"*?") != string16::npos)) + (ext.find_first_of(L"*?") != base::string16::npos)) continue; extensions.push_back(ext); } @@ -530,7 +532,7 @@ HRESULT SaveFilePickerSession::StartFilePicker() { mswr::ComPtr<StringVectorItf> list; hr = mswr::MakeAndInitialize<StringVectorImpl>( - list.GetAddressOf(), std::vector<string16>(1, L".dat")); + list.GetAddressOf(), std::vector<base::string16>(1, L".dat")); if (FAILED(hr)) return hr; @@ -581,7 +583,7 @@ HRESULT SaveFilePickerSession::FilePickerDone(SaveFileAsyncOp* async, hr = storage_item->get_Path(file_path.GetAddressOf()); if (SUCCEEDED(hr)) { - string16 path_str = MakeStdWString(file_path.Get()); + base::string16 path_str = MakeStdWString(file_path.Get()); // If the selected file name is longer than the supplied buffer, // we return false as per GetOpenFileName documentation. diff --git a/win8/metro_driver/file_picker_ash.cc b/win8/metro_driver/file_picker_ash.cc index 343d7b4f99..902ee782d6 100644 --- a/win8/metro_driver/file_picker_ash.cc +++ b/win8/metro_driver/file_picker_ash.cc @@ -28,7 +28,7 @@ class StringVectorImpl : public mswr::RuntimeClass<StringVectorItf> { std::for_each(strings_.begin(), strings_.end(), ::WindowsDeleteString); } - HRESULT RuntimeClassInitialize(const std::vector<string16>& list) { + HRESULT RuntimeClassInitialize(const std::vector<base::string16>& list) { for (size_t i = 0; i < list.size(); ++i) strings_.push_back(MakeHString(list[i])); @@ -82,8 +82,8 @@ class StringVectorImpl : public mswr::RuntimeClass<StringVectorItf> { } // namespace FilePickerSessionBase::FilePickerSessionBase(ChromeAppViewAsh* app_view, - const string16& title, - const string16& filter, + const base::string16& title, + const base::string16& filter, const base::FilePath& default_path) : app_view_(app_view), title_(title), @@ -117,8 +117,8 @@ bool FilePickerSessionBase::DoFilePicker() { OpenFilePickerSession::OpenFilePickerSession( ChromeAppViewAsh* app_view, - const string16& title, - const string16& filter, + const base::string16& title, + const base::string16& filter, const base::FilePath& default_path, bool allow_multi_select) : FilePickerSessionBase(app_view, title, filter, default_path), @@ -165,7 +165,7 @@ HRESULT OpenFilePickerSession::MultiPickerDone(MultiFileAsyncOp* async, HRESULT hr = async->GetResults(files.GetAddressOf()); if (files) { - string16 result; + base::string16 result; if (SUCCEEDED(hr)) hr = ComposeMultiFileResult(files.Get(), &result); @@ -243,7 +243,7 @@ HRESULT OpenFilePickerSession::StartFilePicker() { break; // There can be a single extension, or a list of semicolon-separated ones. - std::vector<string16> extensions_win32_style; + std::vector<base::string16> extensions_win32_style; size_t extension_count = Tokenize(walk, L";", &extensions_win32_style); DCHECK_EQ(extension_count, extensions_win32_style.size()); @@ -256,9 +256,10 @@ HRESULT OpenFilePickerSession::StartFilePicker() { hr = extension.Set(L"*"); } else { // Metro wants suffixes only, not patterns. - string16 ext = base::FilePath(extensions_win32_style[i]).Extension(); + base::string16 ext = + base::FilePath(extensions_win32_style[i]).Extension(); if ((ext.size() < 2) || - (ext.find_first_of(L"*?") != string16::npos)) { + (ext.find_first_of(L"*?") != base::string16::npos)) { continue; } hr = extension.Set(ext.c_str()); @@ -309,7 +310,7 @@ HRESULT OpenFilePickerSession::StartFilePicker() { } HRESULT OpenFilePickerSession::ComposeMultiFileResult( - StorageFileVectorCollection* files, string16* result) { + StorageFileVectorCollection* files, base::string16* result) { DCHECK(files != NULL); DCHECK(result != NULL); @@ -424,17 +425,18 @@ HRESULT SaveFilePickerSession::StartFilePicker() { break; // There can be a single extension, or a list of semicolon-separated ones. - std::vector<string16> extensions_win32_style; + std::vector<base::string16> extensions_win32_style; size_t extension_count = Tokenize(walk, L";", &extensions_win32_style); DCHECK_EQ(extension_count, extensions_win32_style.size()); // Metro wants suffixes only, not patterns. Also, metro does not support // the all files ("*") pattern in the save picker. - std::vector<string16> extensions; + std::vector<base::string16> extensions; for (size_t i = 0; i < extensions_win32_style.size(); ++i) { - string16 ext = base::FilePath(extensions_win32_style[i]).Extension(); + base::string16 ext = + base::FilePath(extensions_win32_style[i]).Extension(); if ((ext.size() < 2) || - (ext.find_first_of(L"*?") != string16::npos)) + (ext.find_first_of(L"*?") != base::string16::npos)) continue; extensions.push_back(ext); } @@ -479,7 +481,7 @@ HRESULT SaveFilePickerSession::StartFilePicker() { mswr::ComPtr<StringVectorItf> list; hr = mswr::MakeAndInitialize<StringVectorImpl>( - list.GetAddressOf(), std::vector<string16>(1, L".dat")); + list.GetAddressOf(), std::vector<base::string16>(1, L".dat")); if (FAILED(hr)) return hr; @@ -491,7 +493,7 @@ HRESULT SaveFilePickerSession::StartFilePicker() { } if (!default_path_.empty()) { - string16 file_part = default_path_.BaseName().value(); + base::string16 file_part = default_path_.BaseName().value(); // If the suggested_name is a root directory, then don't set it as the // suggested name. if (file_part.size() == 1 && file_part[0] == L'\\') @@ -534,7 +536,7 @@ HRESULT SaveFilePickerSession::FilePickerDone(SaveFileAsyncOp* async, hr = storage_item->get_Path(file_path.GetAddressOf()); if (SUCCEEDED(hr)) { - string16 path_str = MakeStdWString(file_path.Get()); + base::string16 path_str = MakeStdWString(file_path.Get()); result_ = path_str; success_ = true; } @@ -549,7 +551,7 @@ HRESULT SaveFilePickerSession::FilePickerDone(SaveFileAsyncOp* async, } FolderPickerSession::FolderPickerSession(ChromeAppViewAsh* app_view, - const string16& title) + const base::string16& title) : FilePickerSessionBase(app_view, title, L"", base::FilePath()) {} HRESULT FolderPickerSession::StartFilePicker() { @@ -603,7 +605,7 @@ HRESULT FolderPickerSession::FolderPickerDone(FolderPickerAsyncOp* async, hr = storage_item->get_Path(file_path.GetAddressOf()); if (SUCCEEDED(hr)) { - string16 path_str = MakeStdWString(file_path.Get()); + base::string16 path_str = MakeStdWString(file_path.Get()); result_ = path_str; success_ = true; } diff --git a/win8/metro_driver/file_picker_ash.h b/win8/metro_driver/file_picker_ash.h index b08115698d..d3de43c069 100644 --- a/win8/metro_driver/file_picker_ash.h +++ b/win8/metro_driver/file_picker_ash.h @@ -23,8 +23,8 @@ class FilePickerSessionBase { public: // Creates a file picker for open_file_name. explicit FilePickerSessionBase(ChromeAppViewAsh* app_view, - const string16& title, - const string16& filter, + const base::string16& title, + const base::string16& filter, const base::FilePath& default_path); virtual ~FilePickerSessionBase() { @@ -33,7 +33,7 @@ class FilePickerSessionBase { // Runs the picker, returns true on success. bool Run(); - const string16& result() const { + const base::string16& result() const { return result_; } @@ -51,10 +51,10 @@ class FilePickerSessionBase { bool success_; // The title of the file picker. - string16 title_; + base::string16 title_; // The file type filter. - string16 filter_; + base::string16 filter_; // The starting directory/file name. base::FilePath default_path_; @@ -63,7 +63,7 @@ class FilePickerSessionBase { // instance when the file open/save operations complete. ChromeAppViewAsh* app_view_; - string16 result_; + base::string16 result_; private: // Initiate a file picker, must be called on the main metro thread. @@ -78,8 +78,8 @@ class FilePickerSessionBase { class OpenFilePickerSession : public FilePickerSessionBase { public: explicit OpenFilePickerSession(ChromeAppViewAsh* app_view, - const string16& title, - const string16& filter, + const base::string16& title, + const base::string16& filter, const base::FilePath& default_path, bool allow_multi_select); @@ -110,7 +110,7 @@ class OpenFilePickerSession : public FilePickerSessionBase { // Composes a multi-file result string suitable for returning to a // from a storage file collection. static HRESULT ComposeMultiFileResult(StorageFileVectorCollection* files, - string16* result); + base::string16* result); private: // True if the multi file picker is to be displayed. @@ -149,7 +149,7 @@ class SaveFilePickerSession : public FilePickerSessionBase { class FolderPickerSession : public FilePickerSessionBase { public: explicit FolderPickerSession(ChromeAppViewAsh* app_view, - const string16& title); + const base::string16& title); private: virtual HRESULT StartFilePicker() OVERRIDE; diff --git a/win8/metro_driver/ime/ime.gypi b/win8/metro_driver/ime/ime.gypi index f787f2a545..ba9db464b7 100644 --- a/win8/metro_driver/ime/ime.gypi +++ b/win8/metro_driver/ime/ime.gypi @@ -1,9 +1,12 @@ -# Copyright 2013 The Chromium Authors. All rights reserved. +# Copyright (c) 2013 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. { 'sources': [ + 'ime_popup_monitor.cc', + 'ime_popup_monitor.h', + 'ime_popup_observer.h', 'input_scope.cc', 'input_scope.h', 'input_source.cc', diff --git a/win8/metro_driver/ime/ime_popup_monitor.cc b/win8/metro_driver/ime/ime_popup_monitor.cc new file mode 100644 index 0000000000..a478607aad --- /dev/null +++ b/win8/metro_driver/ime/ime_popup_monitor.cc @@ -0,0 +1,82 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "win8/metro_driver/ime/ime_popup_monitor.h" + +#include <windows.h> + +#include "base/logging.h" +#include "base/message_loop/message_loop.h" +#include "win8/metro_driver/ime/ime_popup_observer.h" + +namespace metro_driver { +namespace { + +ImePopupObserver* g_observer_ = NULL; +HWINEVENTHOOK g_hook_handle_ = NULL; + +void CALLBACK ImeEventCallback(HWINEVENTHOOK win_event_hook_handle, + DWORD event, + HWND window_handle, + LONG object_id, + LONG child_id, + DWORD event_thread, + DWORD event_time) { + // This function is registered to SetWinEventHook to be called back on the UI + // thread. + DCHECK(base::MessageLoopForUI::IsCurrent()); + + if (!g_observer_) + return; + switch (event) { + case EVENT_OBJECT_IME_SHOW: + g_observer_->OnImePopupChanged(ImePopupObserver::kPopupShown); + return; + case EVENT_OBJECT_IME_HIDE: + g_observer_->OnImePopupChanged(ImePopupObserver::kPopupHidden); + return; + case EVENT_OBJECT_IME_CHANGE: + g_observer_->OnImePopupChanged(ImePopupObserver::kPopupUpdated); + return; + } +} + +} // namespace + +void AddImePopupObserver(ImePopupObserver* observer) { + CHECK(g_observer_ == NULL) + << "Currently only one observer is supported at the same time."; + g_observer_ = observer; + + // IMEs running under immersive mode are supposed to generate WinEvent + // whenever their popup UI such as candidate window is shown, updated, and + // hidden to support accessibility applications. + // http://msdn.microsoft.com/en-us/library/windows/apps/hh967425.aspx#accessibility + // Note that there is another mechanism in TSF, called ITfUIElementSink, to + // subscribe when the visibility of an IME's UI element is changed. However, + // MS-IME running under immersive mode does not fully support this API. + // Thus, WinEvent is more reliable for this purpose. + g_hook_handle_ = SetWinEventHook( + EVENT_OBJECT_IME_SHOW, + EVENT_OBJECT_IME_CHANGE, + NULL, + ImeEventCallback, + GetCurrentProcessId(), // monitor the metro_driver process only + 0, // hook all threads because MS-IME emits WinEvent in a worker thread + WINEVENT_OUTOFCONTEXT); // allows us to receive message in the UI thread + LOG_IF(ERROR, !g_hook_handle_) << "SetWinEventHook failed."; +} + +void RemoveImePopupObserver(ImePopupObserver* observer) { + if (g_observer_ != observer) + return; + g_observer_ = NULL; + if (!g_hook_handle_) + return; + const bool unhook_succeeded = !!UnhookWinEvent(g_hook_handle_); + LOG_IF(ERROR, !unhook_succeeded) << "UnhookWinEvent failed."; + g_hook_handle_ = NULL; +} + +} // namespace metro_driver diff --git a/win8/metro_driver/ime/ime_popup_monitor.h b/win8/metro_driver/ime/ime_popup_monitor.h new file mode 100644 index 0000000000..3bf65580e9 --- /dev/null +++ b/win8/metro_driver/ime/ime_popup_monitor.h @@ -0,0 +1,19 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef WIN8_METRO_DRIVER_IME_IME_POPUP_MONITOR_H_ +#define WIN8_METRO_DRIVER_IME_IME_POPUP_MONITOR_H_ + +namespace metro_driver { + +class ImePopupObserver; + +// Adds/Removes ImePopupObserver. Currently only one observer is supported at +// the same time. +void AddImePopupObserver(ImePopupObserver* observer); +void RemoveImePopupObserver(ImePopupObserver* observer); + +} // namespace metro_driver + +#endif // WIN8_METRO_DRIVER_IME_IME_POPUP_MONITOR_H_ diff --git a/win8/metro_driver/ime/ime_popup_observer.h b/win8/metro_driver/ime/ime_popup_observer.h new file mode 100644 index 0000000000..b871084a8c --- /dev/null +++ b/win8/metro_driver/ime/ime_popup_observer.h @@ -0,0 +1,27 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef WIN8_METRO_DRIVER_IME_IME_POPUP_OBSERVER_H_ +#define WIN8_METRO_DRIVER_IME_IME_POPUP_OBSERVER_H_ + +namespace metro_driver { + +// An observer interface implemented by objects that want to be informed when +// an IME shows or hides its popup window. +class ImePopupObserver { + public: + enum EventType { + kPopupShown, + kPopupHidden, + kPopupUpdated, + }; + virtual ~ImePopupObserver() {} + + // Called whenever an IME's popup window is changed. + virtual void OnImePopupChanged(EventType type) = 0; +}; + +} // namespace metro_driver + +#endif // WIN8_METRO_DRIVER_IME_IME_POPUP_OBSERVER_H_ diff --git a/win8/metro_driver/ime/text_service.cc b/win8/metro_driver/ime/text_service.cc index ecb7ddf344..de82a78969 100644 --- a/win8/metro_driver/ime/text_service.cc +++ b/win8/metro_driver/ime/text_service.cc @@ -46,7 +46,7 @@ // TextServiceImpl // -> ChromeAppViewAsh // -- (process boundary) -- -// -> RemoteRootWindowHostWin +// -> RemoteWindowTreeHostWin // -> RemoteInputMethodWin // // browser process -> metro_driver process @@ -55,7 +55,7 @@ // - MetroViewerHostMsg_ImeTextInputClientUpdated // Message Routing: // RemoteInputMethodWin -// -> RemoteRootWindowHostWin +// -> RemoteWindowTreeHostWin // -- (process boundary) -- // -> ChromeAppViewAsh // -> TextServiceImpl @@ -87,7 +87,6 @@ namespace metro_driver { namespace { -typedef TSFTextStore TextStore; // Japanese IME expects the default value of this compartment is // TF_SENTENCEMODE_PHRASEPREDICT to emulate IMM32 behavior. This value is @@ -375,7 +374,7 @@ class TextServiceImpl : public TextService, } virtual void OnCompositionChanged( - const string16& text, + const base::string16& text, int32 selection_start, int32 selection_end, const std::vector<metro_viewer::UnderlineInfo>& underlines) OVERRIDE { @@ -387,7 +386,7 @@ class TextServiceImpl : public TextService, underlines); } - virtual void OnTextCommitted(const string16& text) OVERRIDE { + virtual void OnTextCommitted(const base::string16& text) OVERRIDE { if (!delegate_) return; delegate_->OnTextCommitted(text); diff --git a/win8/metro_driver/ime/text_service_delegate.h b/win8/metro_driver/ime/text_service_delegate.h index ea9cde72ec..9b22a8238e 100644 --- a/win8/metro_driver/ime/text_service_delegate.h +++ b/win8/metro_driver/ime/text_service_delegate.h @@ -26,13 +26,13 @@ class TextServiceDelegate { // Called when on-going composition is updated. An empty |text| represents // that the composition is canceled. virtual void OnCompositionChanged( - const string16& text, + const base::string16& text, int32 selection_start, int32 selection_end, const std::vector<metro_viewer::UnderlineInfo>& underlines) = 0; // Called when |text| is committed. - virtual void OnTextCommitted(const string16& text) = 0; + virtual void OnTextCommitted(const base::string16& text) = 0; }; } // namespace metro_driver diff --git a/win8/metro_driver/ime/text_store.cc b/win8/metro_driver/ime/text_store.cc index 4652a7f4c6..e406e1b611 100644 --- a/win8/metro_driver/ime/text_store.cc +++ b/win8/metro_driver/ime/text_store.cc @@ -19,7 +19,7 @@ const TsViewCookie kViewCookie = 1; } // namespace -TSFTextStore::TSFTextStore() +TextStore::TextStore() : text_store_acp_sink_mask_(0), window_handle_(NULL), delegate_(NULL), @@ -33,58 +33,58 @@ TSFTextStore::TSFTextStore() input_scope_(NULL) { } -TSFTextStore::~TSFTextStore() { +TextStore::~TextStore() { } // static -scoped_refptr<TSFTextStore> TSFTextStore::Create( +scoped_refptr<TextStore> TextStore::Create( HWND window_handle, const std::vector<InputScope>& input_scopes, TextStoreDelegate* delegate) { if (!delegate) { LOG(ERROR) << "|delegate| must be non-NULL."; - return scoped_refptr<TSFTextStore>(); + return scoped_refptr<TextStore>(); } base::win::ScopedComPtr<ITfCategoryMgr> category_manager; HRESULT hr = category_manager.CreateInstance(CLSID_TF_CategoryMgr); if (FAILED(hr)) { LOG(ERROR) << "Failed to initialize CategoryMgr. hr = " << hr; - return scoped_refptr<TSFTextStore>(); + return scoped_refptr<TextStore>(); } base::win::ScopedComPtr<ITfDisplayAttributeMgr> display_attribute_manager; hr = display_attribute_manager.CreateInstance(CLSID_TF_DisplayAttributeMgr); if (FAILED(hr)) { LOG(ERROR) << "Failed to initialize DisplayAttributeMgr. hr = " << hr; - return scoped_refptr<TSFTextStore>(); + return scoped_refptr<TextStore>(); } base::win::ScopedComPtr<ITfInputScope> input_scope = CreteInputScope(input_scopes); if (!input_scope) { LOG(ERROR) << "Failed to initialize InputScope."; - return scoped_refptr<TSFTextStore>(); + return scoped_refptr<TextStore>(); } ui::win::CreateATLModuleIfNeeded(); - CComObject<TSFTextStore>* object = NULL; - hr = CComObject<TSFTextStore>::CreateInstance(&object); + CComObject<TextStore>* object = NULL; + hr = CComObject<TextStore>::CreateInstance(&object); if (FAILED(hr)) { - LOG(ERROR) << "CComObject<TSFTextStore>::CreateInstance failed. hr = " + LOG(ERROR) << "CComObject<TextStore>::CreateInstance failed. hr = " << hr; - return scoped_refptr<TSFTextStore>(); + return scoped_refptr<TextStore>(); } object->Initialize(window_handle, category_manager, display_attribute_manager, input_scope, delegate); - return scoped_refptr<TSFTextStore>(object); + return scoped_refptr<TextStore>(object); } -void TSFTextStore::Initialize(HWND window_handle, - ITfCategoryMgr* category_manager, - ITfDisplayAttributeMgr* display_attribute_manager, - ITfInputScope* input_scope, - TextStoreDelegate* delegate) { +void TextStore::Initialize(HWND window_handle, + ITfCategoryMgr* category_manager, + ITfDisplayAttributeMgr* display_attribute_manager, + ITfInputScope* input_scope, + TextStoreDelegate* delegate) { window_handle_ = window_handle; category_manager_ = category_manager; display_attribute_manager_ = display_attribute_manager; @@ -93,9 +93,9 @@ void TSFTextStore::Initialize(HWND window_handle, } -STDMETHODIMP TSFTextStore::AdviseSink(REFIID iid, - IUnknown* unknown, - DWORD mask) { +STDMETHODIMP TextStore::AdviseSink(REFIID iid, + IUnknown* unknown, + DWORD mask) { if (!IsEqualGUID(iid, IID_ITextStoreACPSink)) return E_INVALIDARG; if (text_store_acp_sink_) { @@ -113,7 +113,7 @@ STDMETHODIMP TSFTextStore::AdviseSink(REFIID iid, return S_OK; } -STDMETHODIMP TSFTextStore::FindNextAttrTransition( +STDMETHODIMP TextStore::FindNextAttrTransition( LONG acp_start, LONG acp_halt, ULONG num_filter_attributes, @@ -132,17 +132,17 @@ STDMETHODIMP TSFTextStore::FindNextAttrTransition( return S_OK; } -STDMETHODIMP TSFTextStore::GetACPFromPoint(TsViewCookie view_cookie, - const POINT* point, - DWORD flags, - LONG* acp) { +STDMETHODIMP TextStore::GetACPFromPoint(TsViewCookie view_cookie, + const POINT* point, + DWORD flags, + LONG* acp) { NOTIMPLEMENTED(); if (view_cookie != kViewCookie) return E_INVALIDARG; return E_NOTIMPL; } -STDMETHODIMP TSFTextStore::GetActiveView(TsViewCookie* view_cookie) { +STDMETHODIMP TextStore::GetActiveView(TsViewCookie* view_cookie) { if (!view_cookie) return E_INVALIDARG; // We support only one view. @@ -150,10 +150,10 @@ STDMETHODIMP TSFTextStore::GetActiveView(TsViewCookie* view_cookie) { return S_OK; } -STDMETHODIMP TSFTextStore::GetEmbedded(LONG acp_pos, - REFGUID service, - REFIID iid, - IUnknown** unknown) { +STDMETHODIMP TextStore::GetEmbedded(LONG acp_pos, + REFGUID service, + REFIID iid, + IUnknown** unknown) { // We don't support any embedded objects. NOTIMPLEMENTED(); if (!unknown) @@ -162,7 +162,7 @@ STDMETHODIMP TSFTextStore::GetEmbedded(LONG acp_pos, return E_NOTIMPL; } -STDMETHODIMP TSFTextStore::GetEndACP(LONG* acp) { +STDMETHODIMP TextStore::GetEndACP(LONG* acp) { if (!acp) return E_INVALIDARG; if (!HasReadLock()) @@ -171,13 +171,14 @@ STDMETHODIMP TSFTextStore::GetEndACP(LONG* acp) { return S_OK; } -STDMETHODIMP TSFTextStore::GetFormattedText(LONG acp_start, LONG acp_end, - IDataObject** data_object) { +STDMETHODIMP TextStore::GetFormattedText(LONG acp_start, + LONG acp_end, + IDataObject** data_object) { NOTIMPLEMENTED(); return E_NOTIMPL; } -STDMETHODIMP TSFTextStore::GetScreenExt(TsViewCookie view_cookie, RECT* rect) { +STDMETHODIMP TextStore::GetScreenExt(TsViewCookie view_cookie, RECT* rect) { if (view_cookie != kViewCookie) return E_INVALIDARG; if (!rect) @@ -203,10 +204,10 @@ STDMETHODIMP TSFTextStore::GetScreenExt(TsViewCookie view_cookie, RECT* rect) { return S_OK; } -STDMETHODIMP TSFTextStore::GetSelection(ULONG selection_index, - ULONG selection_buffer_size, - TS_SELECTION_ACP* selection_buffer, - ULONG* fetched_count) { +STDMETHODIMP TextStore::GetSelection(ULONG selection_index, + ULONG selection_buffer_size, + TS_SELECTION_ACP* selection_buffer, + ULONG* fetched_count) { if (!selection_buffer) return E_INVALIDARG; if (!fetched_count) @@ -225,7 +226,7 @@ STDMETHODIMP TSFTextStore::GetSelection(ULONG selection_index, return S_OK; } -STDMETHODIMP TSFTextStore::GetStatus(TS_STATUS* status) { +STDMETHODIMP TextStore::GetStatus(TS_STATUS* status) { if (!status) return E_INVALIDARG; @@ -236,15 +237,15 @@ STDMETHODIMP TSFTextStore::GetStatus(TS_STATUS* status) { return S_OK; } -STDMETHODIMP TSFTextStore::GetText(LONG acp_start, - LONG acp_end, - wchar_t* text_buffer, - ULONG text_buffer_size, - ULONG* text_buffer_copied, - TS_RUNINFO* run_info_buffer, - ULONG run_info_buffer_size, - ULONG* run_info_buffer_copied, - LONG* next_acp) { +STDMETHODIMP TextStore::GetText(LONG acp_start, + LONG acp_end, + wchar_t* text_buffer, + ULONG text_buffer_size, + ULONG* text_buffer_copied, + TS_RUNINFO* run_info_buffer, + ULONG run_info_buffer_size, + ULONG* run_info_buffer_copied, + LONG* next_acp) { if (!text_buffer_copied || !run_info_buffer_copied) return E_INVALIDARG; if (!text_buffer && text_buffer_size != 0) @@ -266,7 +267,7 @@ STDMETHODIMP TSFTextStore::GetText(LONG acp_start, acp_end = std::min(acp_end, acp_start + static_cast<LONG>(text_buffer_size)); *text_buffer_copied = acp_end - acp_start; - const string16& result = + const base::string16& result = string_buffer_.substr(acp_start, *text_buffer_copied); for (size_t i = 0; i < result.size(); ++i) text_buffer[i] = result[i]; @@ -281,11 +282,11 @@ STDMETHODIMP TSFTextStore::GetText(LONG acp_start, return S_OK; } -STDMETHODIMP TSFTextStore::GetTextExt(TsViewCookie view_cookie, - LONG acp_start, - LONG acp_end, - RECT* rect, - BOOL* clipped) { +STDMETHODIMP TextStore::GetTextExt(TsViewCookie view_cookie, + LONG acp_start, + LONG acp_end, + RECT* rect, + BOOL* clipped) { if (!rect || !clipped) return E_INVALIDARG; if (view_cookie != kViewCookie) @@ -356,8 +357,8 @@ STDMETHODIMP TSFTextStore::GetTextExt(TsViewCookie view_cookie, return S_OK; } -STDMETHODIMP TSFTextStore::GetWnd(TsViewCookie view_cookie, - HWND* window_handle) { +STDMETHODIMP TextStore::GetWnd(TsViewCookie view_cookie, + HWND* window_handle) { if (!window_handle) return E_INVALIDARG; if (view_cookie != kViewCookie) @@ -366,32 +367,32 @@ STDMETHODIMP TSFTextStore::GetWnd(TsViewCookie view_cookie, return S_OK; } -STDMETHODIMP TSFTextStore::InsertEmbedded(DWORD flags, - LONG acp_start, - LONG acp_end, - IDataObject* data_object, - TS_TEXTCHANGE* change) { +STDMETHODIMP TextStore::InsertEmbedded(DWORD flags, + LONG acp_start, + LONG acp_end, + IDataObject* data_object, + TS_TEXTCHANGE* change) { // We don't support any embedded objects. NOTIMPLEMENTED(); return E_NOTIMPL; } -STDMETHODIMP TSFTextStore::InsertEmbeddedAtSelection(DWORD flags, - IDataObject* data_object, - LONG* acp_start, - LONG* acp_end, - TS_TEXTCHANGE* change) { +STDMETHODIMP TextStore::InsertEmbeddedAtSelection(DWORD flags, + IDataObject* data_object, + LONG* acp_start, + LONG* acp_end, + TS_TEXTCHANGE* change) { // We don't support any embedded objects. NOTIMPLEMENTED(); return E_NOTIMPL; } -STDMETHODIMP TSFTextStore::InsertTextAtSelection(DWORD flags, - const wchar_t* text_buffer, - ULONG text_buffer_size, - LONG* acp_start, - LONG* acp_end, - TS_TEXTCHANGE* text_change) { +STDMETHODIMP TextStore::InsertTextAtSelection(DWORD flags, + const wchar_t* text_buffer, + ULONG text_buffer_size, + LONG* acp_start, + LONG* acp_end, + TS_TEXTCHANGE* text_change) { const LONG start_pos = selection_start_; const LONG end_pos = selection_end_; const LONG new_end_pos = start_pos + text_buffer_size; @@ -413,7 +414,7 @@ STDMETHODIMP TSFTextStore::InsertTextAtSelection(DWORD flags, DCHECK_LE(start_pos, end_pos); string_buffer_ = string_buffer_.substr(0, start_pos) + - string16(text_buffer, text_buffer + text_buffer_size) + + base::string16(text_buffer, text_buffer + text_buffer_size) + string_buffer_.substr(end_pos); if (acp_start) *acp_start = start_pos; @@ -429,7 +430,7 @@ STDMETHODIMP TSFTextStore::InsertTextAtSelection(DWORD flags, return S_OK; } -STDMETHODIMP TSFTextStore::QueryInsert( +STDMETHODIMP TextStore::QueryInsert( LONG acp_test_start, LONG acp_test_end, ULONG text_size, @@ -446,7 +447,7 @@ STDMETHODIMP TSFTextStore::QueryInsert( return S_OK; } -STDMETHODIMP TSFTextStore::QueryInsertEmbedded(const GUID* service, +STDMETHODIMP TextStore::QueryInsertEmbedded(const GUID* service, const FORMATETC* format, BOOL* insertable) { if (!format) @@ -457,7 +458,7 @@ STDMETHODIMP TSFTextStore::QueryInsertEmbedded(const GUID* service, return S_OK; } -STDMETHODIMP TSFTextStore::RequestAttrsAtPosition( +STDMETHODIMP TextStore::RequestAttrsAtPosition( LONG acp_pos, ULONG attribute_buffer_size, const TS_ATTRID* attribute_buffer, @@ -468,7 +469,7 @@ STDMETHODIMP TSFTextStore::RequestAttrsAtPosition( return S_OK; } -STDMETHODIMP TSFTextStore::RequestAttrsTransitioningAtPosition( +STDMETHODIMP TextStore::RequestAttrsTransitioningAtPosition( LONG acp_pos, ULONG attribute_buffer_size, const TS_ATTRID* attribute_buffer, @@ -479,7 +480,7 @@ STDMETHODIMP TSFTextStore::RequestAttrsTransitioningAtPosition( return S_OK; } -STDMETHODIMP TSFTextStore::RequestLock(DWORD lock_flags, HRESULT* result) { +STDMETHODIMP TextStore::RequestLock(DWORD lock_flags, HRESULT* result) { if (!text_store_acp_sink_.get()) return E_FAIL; if (!result) @@ -524,10 +525,10 @@ STDMETHODIMP TSFTextStore::RequestLock(DWORD lock_flags, HRESULT* result) { // TextStoreDelegate::ConfirmComposition() or // TextStoreDelegate::SetComposition(). const uint32 new_committed_size = committed_size_; - const string16& new_committed_string = + const base::string16& new_committed_string = string_buffer_.substr(last_committed_size, new_committed_size - last_committed_size); - const string16& composition_string = + const base::string16& composition_string = string_buffer_.substr(new_committed_size); // If there is new committed string, calls @@ -574,7 +575,7 @@ STDMETHODIMP TSFTextStore::RequestLock(DWORD lock_flags, HRESULT* result) { return S_OK; } -STDMETHODIMP TSFTextStore::RequestSupportedAttrs( +STDMETHODIMP TextStore::RequestSupportedAttrs( DWORD /* flags */, // Seems that we should ignore this. ULONG attribute_buffer_size, const TS_ATTRID* attribute_buffer) { @@ -590,7 +591,7 @@ STDMETHODIMP TSFTextStore::RequestSupportedAttrs( return E_FAIL; } -STDMETHODIMP TSFTextStore::RetrieveRequestedAttrs( +STDMETHODIMP TextStore::RetrieveRequestedAttrs( ULONG attribute_buffer_size, TS_ATTRVAL* attribute_buffer, ULONG* attribute_buffer_copied) { @@ -615,7 +616,7 @@ STDMETHODIMP TSFTextStore::RetrieveRequestedAttrs( return S_OK; } -STDMETHODIMP TSFTextStore::SetSelection( +STDMETHODIMP TextStore::SetSelection( ULONG selection_buffer_size, const TS_SELECTION_ACP* selection_buffer) { if (!HasReadWriteLock()) @@ -634,12 +635,12 @@ STDMETHODIMP TSFTextStore::SetSelection( return S_OK; } -STDMETHODIMP TSFTextStore::SetText(DWORD flags, - LONG acp_start, - LONG acp_end, - const wchar_t* text_buffer, - ULONG text_buffer_size, - TS_TEXTCHANGE* text_change) { +STDMETHODIMP TextStore::SetText(DWORD flags, + LONG acp_start, + LONG acp_end, + const wchar_t* text_buffer, + ULONG text_buffer_size, + TS_TEXTCHANGE* text_change) { if (!HasReadWriteLock()) return TS_E_NOLOCK; if (!((static_cast<LONG>(committed_size_) <= acp_start) && @@ -671,7 +672,7 @@ STDMETHODIMP TSFTextStore::SetText(DWORD flags, return S_OK; } -STDMETHODIMP TSFTextStore::UnadviseSink(IUnknown* unknown) { +STDMETHODIMP TextStore::UnadviseSink(IUnknown* unknown) { if (!text_store_acp_sink_.IsSameObject(unknown)) return CONNECT_E_NOCONNECTION; text_store_acp_sink_.Release(); @@ -679,7 +680,7 @@ STDMETHODIMP TSFTextStore::UnadviseSink(IUnknown* unknown) { return S_OK; } -STDMETHODIMP TSFTextStore::OnStartComposition( +STDMETHODIMP TextStore::OnStartComposition( ITfCompositionView* composition_view, BOOL* ok) { if (ok) @@ -687,18 +688,18 @@ STDMETHODIMP TSFTextStore::OnStartComposition( return S_OK; } -STDMETHODIMP TSFTextStore::OnUpdateComposition( +STDMETHODIMP TextStore::OnUpdateComposition( ITfCompositionView* composition_view, ITfRange* range) { return S_OK; } -STDMETHODIMP TSFTextStore::OnEndComposition( +STDMETHODIMP TextStore::OnEndComposition( ITfCompositionView* composition_view) { return S_OK; } -STDMETHODIMP TSFTextStore::OnEndEdit(ITfContext* context, +STDMETHODIMP TextStore::OnEndEdit(ITfContext* context, TfEditCookie read_only_edit_cookie, ITfEditRecord* edit_record) { if (!context || !edit_record) @@ -711,8 +712,8 @@ STDMETHODIMP TSFTextStore::OnEndEdit(ITfContext* context, return S_OK; } -bool TSFTextStore::GetDisplayAttribute(TfGuidAtom guid_atom, - TF_DISPLAYATTRIBUTE* attribute) { +bool TextStore::GetDisplayAttribute(TfGuidAtom guid_atom, + TF_DISPLAYATTRIBUTE* attribute) { GUID guid; if (FAILED(category_manager_->GetGUID(guid_atom, &guid))) return false; @@ -725,7 +726,7 @@ bool TSFTextStore::GetDisplayAttribute(TfGuidAtom guid_atom, return SUCCEEDED(display_attribute_info->GetAttributeInfo(attribute)); } -bool TSFTextStore::GetCompositionStatus( +bool TextStore::GetCompositionStatus( ITfContext* context, const TfEditCookie read_only_edit_cookie, uint32* committed_size, @@ -808,7 +809,7 @@ bool TSFTextStore::GetCompositionStatus( return true; } -bool TSFTextStore::CancelComposition() { +bool TextStore::CancelComposition() { // If there is an on-going document lock, we must not edit the text. if (edit_flag_) return false; @@ -844,7 +845,7 @@ bool TSFTextStore::CancelComposition() { return true; } -bool TSFTextStore::ConfirmComposition() { +bool TextStore::ConfirmComposition() { // If there is an on-going document lock, we must not edit the text. if (edit_flag_) return false; @@ -852,11 +853,12 @@ bool TSFTextStore::ConfirmComposition() { if (string_buffer_.empty()) return true; - // See the comment in TSFTextStore::CancelComposition. + // See the comment in TextStore::CancelComposition. // This logic is based on the observation about how to emulate // ImmNotifyIME(NI_COMPOSITIONSTR, CPS_COMPLETE, 0) by CUAS. - const string16& composition_text = string_buffer_.substr(committed_size_); + const base::string16& composition_text = + string_buffer_.substr(committed_size_); if (!composition_text.empty()) delegate_->OnTextCommitted(composition_text); @@ -880,16 +882,16 @@ bool TSFTextStore::ConfirmComposition() { return true; } -void TSFTextStore::SendOnLayoutChange() { +void TextStore::SendOnLayoutChange() { if (text_store_acp_sink_ && (text_store_acp_sink_mask_ & TS_AS_LAYOUT_CHANGE)) text_store_acp_sink_->OnLayoutChange(TS_LC_CHANGE, 0); } -bool TSFTextStore::HasReadLock() const { +bool TextStore::HasReadLock() const { return (current_lock_type_ & TS_LF_READ) == TS_LF_READ; } -bool TSFTextStore::HasReadWriteLock() const { +bool TextStore::HasReadWriteLock() const { return (current_lock_type_ & TS_LF_READWRITE) == TS_LF_READWRITE; } diff --git a/win8/metro_driver/ime/text_store.h b/win8/metro_driver/ime/text_store.h index 19860959d4..975592c351 100644 --- a/win8/metro_driver/ime/text_store.h +++ b/win8/metro_driver/ime/text_store.h @@ -25,61 +25,61 @@ namespace metro_driver { class TextStoreDelegate; -// TSFTextStore is used to interact with the input method via TSF manager. -// TSFTextStore have a string buffer which is manipulated by TSF manager through +// TextStore is used to interact with the input method via TSF manager. +// TextStore have a string buffer which is manipulated by TSF manager through // ITextStoreACP interface methods such as SetText(). -// When the input method updates the composition, TSFTextStore calls +// When the input method updates the composition, TextStore calls // TextInputClient::SetCompositionText(). And when the input method finishes the -// composition, TSFTextStore calls TextInputClient::InsertText() and clears the +// composition, TextStore calls TextInputClient::InsertText() and clears the // buffer. // -// How TSFTextStore works: +// How TextStore works: // - The user enters "a". // - The input method set composition as "a". -// - TSF manager calls TSFTextStore::RequestLock(). -// - TSFTextStore callbacks ITextStoreACPSink::OnLockGranted(). +// - TSF manager calls TextStore::RequestLock(). +// - TextStore callbacks ITextStoreACPSink::OnLockGranted(). // - In OnLockGranted(), TSF manager calls -// - TSFTextStore::OnStartComposition() -// - TSFTextStore::SetText() +// - TextStore::OnStartComposition() +// - TextStore::SetText() // The string buffer is set as "a". -// - TSFTextStore::OnUpdateComposition() -// - TSFTextStore::OnEndEdit() -// TSFTextStore can get the composition information such as underlines. -// - TSFTextStore calls TextInputClient::SetCompositionText(). +// - TextStore::OnUpdateComposition() +// - TextStore::OnEndEdit() +// TextStore can get the composition information such as underlines. +// - TextStore calls TextInputClient::SetCompositionText(). // "a" is shown with an underline as composition string. // - The user enters <space>. // - The input method set composition as "A". -// - TSF manager calls TSFTextStore::RequestLock(). -// - TSFTextStore callbacks ITextStoreACPSink::OnLockGranted(). +// - TSF manager calls TextStore::RequestLock(). +// - TextStore callbacks ITextStoreACPSink::OnLockGranted(). // - In OnLockGranted(), TSF manager calls -// - TSFTextStore::SetText() +// - TextStore::SetText() // The string buffer is set as "A". -// - TSFTextStore::OnUpdateComposition() -// - TSFTextStore::OnEndEdit() -// - TSFTextStore calls TextInputClient::SetCompositionText(). +// - TextStore::OnUpdateComposition() +// - TextStore::OnEndEdit() +// - TextStore calls TextInputClient::SetCompositionText(). // "A" is shown with an underline as composition string. // - The user enters <enter>. // - The input method commits "A". -// - TSF manager calls TSFTextStore::RequestLock(). -// - TSFTextStore callbacks ITextStoreACPSink::OnLockGranted(). +// - TSF manager calls TextStore::RequestLock(). +// - TextStore callbacks ITextStoreACPSink::OnLockGranted(). // - In OnLockGranted(), TSF manager calls -// - TSFTextStore::OnEndComposition() -// - TSFTextStore::OnEndEdit() -// TSFTextStore knows "A" is committed. -// - TSFTextStore calls TextInputClient::InsertText(). +// - TextStore::OnEndComposition() +// - TextStore::OnEndEdit() +// TextStore knows "A" is committed. +// - TextStore calls TextInputClient::InsertText(). // "A" is shown as committed string. -// - TSFTextStore clears the string buffer. -// - TSFTextStore calls OnSelectionChange(), OnLayoutChange() and +// - TextStore clears the string buffer. +// - TextStore calls OnSelectionChange(), OnLayoutChange() and // OnTextChange() of ITextStoreACPSink to let TSF manager know that the // string buffer has been changed. // // About the locking scheme: // When TSF manager manipulates the string buffer it calls RequestLock() to get -// the lock of the document. If TSFTextStore can grant the lock request, it +// the lock of the document. If TextStore can grant the lock request, it // callbacks ITextStoreACPSink::OnLockGranted(). // RequestLock() is called from only one thread, but called recursively in // OnLockGranted() or OnSelectionChange() or OnLayoutChange() or OnTextChange(). -// If the document is locked and the lock request is asynchronous, TSFTextStore +// If the document is locked and the lock request is asynchronous, TextStore // queues the request. The queued requests will be handled after the current // lock is removed. // More information about document locks can be found here: @@ -87,16 +87,15 @@ class TextStoreDelegate; // // More information about TSF can be found here: // http://msdn.microsoft.com/en-us/library/ms629032 -// TODO(yukawa): Rename TSFTextStore to TextStore. -class ATL_NO_VTABLE TSFTextStore +class ATL_NO_VTABLE TextStore : public CComObjectRootEx<CComMultiThreadModel>, public ITextStoreACP, public ITfContextOwnerCompositionSink, public ITfTextEditSink { public: - virtual ~TSFTextStore(); + virtual ~TextStore(); - BEGIN_COM_MAP(TSFTextStore) + BEGIN_COM_MAP(TextStore) COM_INTERFACE_ENTRY(ITextStoreACP) COM_INTERFACE_ENTRY(ITfContextOwnerCompositionSink) COM_INTERFACE_ENTRY(ITfTextEditSink) @@ -216,15 +215,15 @@ class ATL_NO_VTABLE TSFTextStore // Sends OnLayoutChange() via |text_store_acp_sink_|. void SendOnLayoutChange(); - // Creates an instance of TSFTextStore. Returns NULL if fails. - static scoped_refptr<TSFTextStore> Create( + // Creates an instance of TextStore. Returns NULL if fails. + static scoped_refptr<TextStore> Create( HWND window_handle, const std::vector<InputScope>& input_scopes, TextStoreDelegate* delegate); private: - friend CComObject<TSFTextStore>; - TSFTextStore(); + friend CComObject<TextStore>; + TextStore(); void Initialize(HWND window_handle, ITfCategoryMgr* category_manager, @@ -262,7 +261,7 @@ class ATL_NO_VTABLE TSFTextStore // Example: "aoi" is committed, and "umi" is under composition. // |string_buffer_|: "aoiumi" // |committed_size_|: 3 - string16 string_buffer_; + base::string16 string_buffer_; uint32 committed_size_; // |selection_start_| and |selection_end_| indicates the selection range. @@ -308,7 +307,7 @@ class ATL_NO_VTABLE TSFTextStore // The delegate attached to this text store. TextStoreDelegate* delegate_; - DISALLOW_COPY_AND_ASSIGN(TSFTextStore); + DISALLOW_COPY_AND_ASSIGN(TextStore); }; } // namespace metro_driver diff --git a/win8/metro_driver/ime/text_store_delegate.h b/win8/metro_driver/ime/text_store_delegate.h index af06516471..153d664f4e 100644 --- a/win8/metro_driver/ime/text_store_delegate.h +++ b/win8/metro_driver/ime/text_store_delegate.h @@ -30,13 +30,13 @@ class TextStoreDelegate { // Called when on-going composition is updated. An empty |text| represents // that the composition is canceled. virtual void OnCompositionChanged( - const string16& text, + const base::string16& text, int32 selection_start, int32 selection_end, const std::vector<metro_viewer::UnderlineInfo>& underlines) = 0; // Called when |text| is committed. - virtual void OnTextCommitted(const string16& text) = 0; + virtual void OnTextCommitted(const base::string16& text) = 0; // Called when an IME requests the caret position. Objects that implement // this method must return the caret position in screen coordinates. diff --git a/win8/metro_driver/metro_dialog_box.cc b/win8/metro_driver/metro_dialog_box.cc index 25e7082771..1217fed86e 100644 --- a/win8/metro_driver/metro_dialog_box.cc +++ b/win8/metro_driver/metro_dialog_box.cc @@ -141,7 +141,7 @@ HRESULT STDMETHODCALLTYPE MetroDialogBox::Invoke( mswrw::HString label; command->get_Label(label.GetAddressOf()); - string16 button_label = MakeStdWString(label.Get()); + base::string16 button_label = MakeStdWString(label.Get()); DVLOG(1) << "Clicked button label is : " << button_label; if (button_label == dialog_box_info_.button1_label) { DVLOG(1) << "Button1 clicked"; diff --git a/win8/metro_driver/metro_dialog_box.h b/win8/metro_driver/metro_dialog_box.h index 5a6a94dbc6..a8ee5b6604 100644 --- a/win8/metro_driver/metro_dialog_box.h +++ b/win8/metro_driver/metro_dialog_box.h @@ -16,10 +16,10 @@ class MetroDialogBox : public winui::Popups::IUICommandInvokedHandler { public: struct DialogBoxInfo { - string16 title; - string16 content; - string16 button1_label; - string16 button2_label; + base::string16 title; + base::string16 content; + base::string16 button1_label; + base::string16 button2_label; base::win::MetroDialogButtonPressedHandler button1_handler; base::win::MetroDialogButtonPressedHandler button2_handler; }; diff --git a/win8/metro_driver/metro_driver.cc b/win8/metro_driver/metro_driver.cc index 940b5b141d..846a71fbfb 100644 --- a/win8/metro_driver/metro_driver.cc +++ b/win8/metro_driver/metro_driver.cc @@ -30,10 +30,10 @@ LONG WINAPI ErrorReportingHandler(EXCEPTION_POINTERS* ex_info) { DWORD code = ex_info->ExceptionRecord->ExceptionCode; ULONG_PTR* info = ex_info->ExceptionRecord->ExceptionInformation; if (code == EXCEPTION_RO_ORIGINATEERROR) { - string16 msg(reinterpret_cast<wchar_t*>(info[2]), info[1]); + base::string16 msg(reinterpret_cast<wchar_t*>(info[2]), info[1]); LOG(ERROR) << "VEH: Metro error 0x" << std::hex << info[0] << ": " << msg; } else if (code == EXCEPTION_RO_TRANSFORMERROR) { - string16 msg(reinterpret_cast<wchar_t*>(info[3]), info[2]); + base::string16 msg(reinterpret_cast<wchar_t*>(info[3]), info[2]); LOG(ERROR) << "VEH: Metro old error 0x" << std::hex << info[0] << " new error 0x" << info[1] << ": " << msg; } diff --git a/win8/metro_driver/metro_driver.gyp b/win8/metro_driver/metro_driver.gyp index cc572d84eb..6debc33bb0 100644 --- a/win8/metro_driver/metro_driver.gyp +++ b/win8/metro_driver/metro_driver.gyp @@ -12,13 +12,21 @@ '../../chrome/version.gypi', ], 'target_defaults': { + # This and the force include below is a workaround for intsafe.h in + # VS 2010. + 'msvs_system_include_dirs': [ + '<(DEPTH)/build', + ], 'msvs_settings': { - 'VCLinkerTool': { - 'AdditionalDependencies': [ - 'D2D1.lib', - 'D3D11.lib', - ], - }, + 'VCLinkerTool': { + 'AdditionalDependencies': [ + 'D2D1.lib', + 'D3D11.lib', + ], + }, + 'VCCLCompilerTool': { + 'ForcedIncludeFiles': [ 'intsafe_workaround.h', ], + }, }, }, 'targets': [ @@ -65,6 +73,7 @@ ], 'sources': [ 'display_properties.cc', + 'display_properties.h', 'metro_driver.cc', 'metro_driver.h', 'stdafx.h', diff --git a/win8/metro_driver/print_document_source.cc b/win8/metro_driver/print_document_source.cc index 91842b78c6..34ce2279df 100644 --- a/win8/metro_driver/print_document_source.cc +++ b/win8/metro_driver/print_document_source.cc @@ -8,7 +8,7 @@ #include <windows.graphics.display.h> #include "base/logging.h" -#include "base/safe_numerics.h" +#include "base/numerics/safe_conversions.h" namespace { @@ -253,7 +253,7 @@ STDMETHODIMP PrintDocumentSource::Paginate(uint32 page, return S_FALSE; hr = dxgi_preview_target_->SetJobPageCount( PageCountType::FinalPageCount, - base::checked_numeric_cast<UINT32>(page_count)); + base::checked_cast<UINT32>(page_count)); if (FAILED(hr)) { LOG(ERROR) << "Failed to SetJobPageCount " << std::hex << hr; return hr; diff --git a/win8/metro_driver/print_handler.cc b/win8/metro_driver/print_handler.cc index 3539c9ed2f..c409fcd57a 100644 --- a/win8/metro_driver/print_handler.cc +++ b/win8/metro_driver/print_handler.cc @@ -9,7 +9,7 @@ #include "base/bind.h" #include "base/logging.h" -#include "base/safe_numerics.h" +#include "base/numerics/safe_conversions.h" #include "chrome/app/chrome_command_ids.h" #include "win8/metro_driver/chrome_app_view.h" #include "win8/metro_driver/winrt_utils.h" @@ -474,7 +474,7 @@ void MetroSetPrintPageContent(size_t page_number, if (metafile_stream.Get() != NULL) { ULONG bytes_written = 0; hr = metafile_stream->Write(data, - base::checked_numeric_cast<ULONG>(data_size), + base::checked_cast<ULONG>(data_size), &bytes_written); LOG_IF(ERROR, FAILED(hr)) << "Failed to Write to Stream " << std::hex << hr; DCHECK(bytes_written == data_size); diff --git a/win8/metro_driver/resources/Logo.png b/win8/metro_driver/resources/Logo.png Binary files differindex 49d67e4fde..16d18e315a 100644 --- a/win8/metro_driver/resources/Logo.png +++ b/win8/metro_driver/resources/Logo.png diff --git a/win8/metro_driver/secondary_tile.cc b/win8/metro_driver/secondary_tile.cc index 97ff63d1f7..f04aacc36e 100644 --- a/win8/metro_driver/secondary_tile.cc +++ b/win8/metro_driver/secondary_tile.cc @@ -89,7 +89,7 @@ HRESULT TileRequestCompleter::Respond(winfoundtn::IAsyncOperation<bool>* async, return S_OK; } -void DeleteTileFromStartScreen(const string16& tile_id, +void DeleteTileFromStartScreen(const base::string16& tile_id, const MetroPinUmaResultCallback& callback) { DVLOG(1) << __FUNCTION__; mswr::ComPtr<winui::StartScreen::ISecondaryTileFactory> tile_factory; @@ -121,9 +121,9 @@ void DeleteTileFromStartScreen(const string16& tile_id, completer->Complete(completion); } -void CreateTileOnStartScreen(const string16& tile_id, - const string16& title_str, - const string16& url_str, +void CreateTileOnStartScreen(const base::string16& tile_id, + const base::string16& title_str, + const base::string16& url_str, const base::FilePath& logo_path, const MetroPinUmaResultCallback& callback) { VLOG(1) << __FUNCTION__; @@ -147,7 +147,7 @@ void CreateTileOnStartScreen(const string16& tile_id, // chrome will see the arguments as command line parameters. // A GURL is used to ensure any spaces are properly escaped. GURL url(url_str); - args.Attach(MakeHString(UTF8ToUTF16(url.spec()))); + args.Attach(MakeHString(base::UTF8ToUTF16(url.spec()))); mswr::ComPtr<winfoundtn::IUriRuntimeClassFactory> uri_factory; hr = winrt_utils::CreateActivationFactory( @@ -156,7 +156,8 @@ void CreateTileOnStartScreen(const string16& tile_id, CheckHR(hr, "Failed to create URIFactory"); mswrw::HString logo_url; - logo_url.Attach(MakeHString(string16(L"file:///").append(logo_path.value()))); + logo_url.Attach( + MakeHString(base::string16(L"file:///").append(logo_path.value()))); mswr::ComPtr<winfoundtn::IUriRuntimeClass> uri; hr = uri_factory->CreateUri(logo_url.Get(), &uri); CheckHR(hr, "Failed to create URI"); @@ -192,7 +193,7 @@ void CreateTileOnStartScreen(const string16& tile_id, } // namespace -BOOL MetroIsPinnedToStartScreen(const string16& tile_id) { +BOOL MetroIsPinnedToStartScreen(const base::string16& tile_id) { mswr::ComPtr<winui::StartScreen::ISecondaryTileStatics> tile_statics; HRESULT hr = winrt_utils::CreateActivationFactory( RuntimeClass_Windows_UI_StartScreen_SecondaryTile, @@ -205,7 +206,7 @@ BOOL MetroIsPinnedToStartScreen(const string16& tile_id) { return exists; } -void MetroUnPinFromStartScreen(const string16& tile_id, +void MetroUnPinFromStartScreen(const base::string16& tile_id, const MetroPinUmaResultCallback& callback) { globals.appview_msg_loop->PostTask( FROM_HERE, base::Bind(&DeleteTileFromStartScreen, @@ -213,9 +214,9 @@ void MetroUnPinFromStartScreen(const string16& tile_id, callback)); } -void MetroPinToStartScreen(const string16& tile_id, - const string16& title, - const string16& url, +void MetroPinToStartScreen(const base::string16& tile_id, + const base::string16& title, + const base::string16& url, const base::FilePath& logo_path, const MetroPinUmaResultCallback& callback) { globals.appview_msg_loop->PostTask( diff --git a/win8/metro_driver/secondary_tile.h b/win8/metro_driver/secondary_tile.h index 9740864bbd..1166e1313c 100644 --- a/win8/metro_driver/secondary_tile.h +++ b/win8/metro_driver/secondary_tile.h @@ -9,18 +9,18 @@ #include "base/win/metro.h" extern "C" __declspec(dllexport) -BOOL MetroIsPinnedToStartScreen(const string16& tile_id); +BOOL MetroIsPinnedToStartScreen(const base::string16& tile_id); extern "C" __declspec(dllexport) void MetroUnPinFromStartScreen( - const string16& tile_id, + const base::string16& tile_id, const base::win::MetroPinUmaResultCallback& callback); extern "C" __declspec(dllexport) void MetroPinToStartScreen( - const string16& tile_id, - const string16& title, - const string16& url, + const base::string16& tile_id, + const base::string16& title, + const base::string16& url, const base::FilePath& logo_path, const base::win::MetroPinUmaResultCallback& callback); diff --git a/win8/metro_driver/toast_notification_handler.cc b/win8/metro_driver/toast_notification_handler.cc index ab014d4ff0..fb44b11dc2 100644 --- a/win8/metro_driver/toast_notification_handler.cc +++ b/win8/metro_driver/toast_notification_handler.cc @@ -64,7 +64,7 @@ HRESULT GetTextNodeRoot( // The index parameter identifies which text node we append to. HRESULT CreateTextNode(winxml::Dom::IXmlDocument* xml_doc, int index, - const string16& text_string) { + const base::string16& text_string) { DCHECK(xml_doc); mswr::ComPtr<winxml::Dom::IXmlElement> document_element; @@ -206,7 +206,8 @@ void ToastNotificationHandler::DisplayNotification( BrowserDistribution* dist = BrowserDistribution::GetDistribution(); bool is_per_user_install = InstallUtil::IsPerUserInstall( chrome_path.value().c_str()); - string16 appid = ShellUtil::GetBrowserModelId(dist, is_per_user_install); + base::string16 appid = + ShellUtil::GetBrowserModelId(dist, is_per_user_install); DVLOG(1) << "Chrome Appid is " << appid.c_str(); mswrw::HString app_user_model_id; diff --git a/win8/metro_driver/toast_notification_handler.h b/win8/metro_driver/toast_notification_handler.h index 8f3587dc75..f30aee8107 100644 --- a/win8/metro_driver/toast_notification_handler.h +++ b/win8/metro_driver/toast_notification_handler.h @@ -17,12 +17,12 @@ class ToastNotificationHandler { struct DesktopNotification { std::string origin_url; std::string icon_url; - string16 title; - string16 body; - string16 display_source; + base::string16 title; + base::string16 body; + base::string16 display_source; std::string id; base::win::MetroNotificationClickedHandler notification_handler; - string16 notification_context; + base::string16 notification_context; DesktopNotification(const char* notification_origin, const char* notification_icon, diff --git a/win8/metro_driver/winrt_utils.cc b/win8/metro_driver/winrt_utils.cc index 6d66cec232..26da18a226 100644 --- a/win8/metro_driver/winrt_utils.cc +++ b/win8/metro_driver/winrt_utils.cc @@ -23,7 +23,7 @@ void CheckHR(HRESULT hr, const char* message) { } } -HSTRING MakeHString(const string16& str) { +HSTRING MakeHString(const base::string16& str) { HSTRING hstr; if (FAILED(::WindowsCreateString(str.c_str(), static_cast<UINT32>(str.size()), &hstr))) { @@ -32,13 +32,13 @@ HSTRING MakeHString(const string16& str) { return hstr; } -string16 MakeStdWString(HSTRING hstring) { +base::string16 MakeStdWString(HSTRING hstring) { const wchar_t* str; UINT32 size = 0; str = ::WindowsGetStringRawBuffer(hstring, &size); if (!size) - return string16(); - return string16(str, size); + return base::string16(); + return base::string16(str, size); } namespace { @@ -170,7 +170,7 @@ HRESULT CompareProperties(winfoundtn::IPropertyValue* lhs, } bool GetArgumentsFromShortcut(const base::FilePath& shortcut, - string16* arguments) { + base::string16* arguments) { HRESULT result; base::win::ScopedComPtr<IShellLink> i_shell_link; bool is_resolved = false; @@ -200,7 +200,7 @@ bool GetArgumentsFromShortcut(const base::FilePath& shortcut, return is_resolved; } -string16 ReadArgumentsFromPinnedTaskbarShortcut() { +base::string16 ReadArgumentsFromPinnedTaskbarShortcut() { wchar_t path_buffer[MAX_PATH] = {}; if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, @@ -214,7 +214,7 @@ string16 ReadArgumentsFromPinnedTaskbarShortcut() { BrowserDistribution::SHORTCUT_CHROME) + installer::kLnkExt; shortcut = shortcut.Append(link_name); - string16 arguments; + base::string16 arguments; if (GetArgumentsFromShortcut(shortcut, &arguments)) { return arguments; } diff --git a/win8/metro_driver/winrt_utils.h b/win8/metro_driver/winrt_utils.h index 3016c852e8..e3a777f9bc 100644 --- a/win8/metro_driver/winrt_utils.h +++ b/win8/metro_driver/winrt_utils.h @@ -14,9 +14,9 @@ void CheckHR(HRESULT hr, const char* str = nullptr); -HSTRING MakeHString(const string16& str); +HSTRING MakeHString(const base::string16& str); -string16 MakeStdWString(HSTRING hstring); +base::string16 MakeStdWString(HSTRING hstring); namespace winrt_utils { @@ -53,7 +53,7 @@ HRESULT CompareProperties( // shortcut's command line. This is intended for scenarios where those shortcut // parameters are ordinarily ignored (i.e. metro apps on win8). Returns an // empty string on failure. -string16 ReadArgumentsFromPinnedTaskbarShortcut(); +base::string16 ReadArgumentsFromPinnedTaskbarShortcut(); } // namespace winrt_utils diff --git a/win8/test/metro_registration_helper.cc b/win8/test/metro_registration_helper.cc index 75319a97a4..cd4a772920 100644 --- a/win8/test/metro_registration_helper.cc +++ b/win8/test/metro_registration_helper.cc @@ -98,7 +98,7 @@ bool IsTestDefaultForProtocol(const wchar_t* protocol) { return false; } - return string16(win8::test::kDefaultTestProgId).compare(current_app) == 0; + return !base::string16(win8::test::kDefaultTestProgId).compare(current_app); } } // namespace diff --git a/win8/test/open_with_dialog_async.cc b/win8/test/open_with_dialog_async.cc index f491149766..2308b55235 100644 --- a/win8/test/open_with_dialog_async.cc +++ b/win8/test/open_with_dialog_async.cc @@ -27,8 +27,8 @@ namespace { struct OpenWithContext { OpenWithContext( HWND parent_window_in, - const string16& file_name_in, - const string16& file_type_class_in, + const base::string16& file_name_in, + const base::string16& file_type_class_in, int open_as_info_flags_in, const scoped_refptr<base::SingleThreadTaskRunner>& client_runner_in, const OpenWithDialogCallback& callback_in); @@ -36,8 +36,8 @@ struct OpenWithContext { base::Thread thread; HWND parent_window; - string16 file_name; - string16 file_type_class; + base::string16 file_name; + base::string16 file_type_class; int open_as_info_flags; scoped_refptr<base::SingleThreadTaskRunner> client_runner; OpenWithDialogCallback callback; @@ -45,8 +45,8 @@ struct OpenWithContext { OpenWithContext::OpenWithContext( HWND parent_window_in, - const string16& file_name_in, - const string16& file_type_class_in, + const base::string16& file_name_in, + const base::string16& file_type_class_in, int open_as_info_flags_in, const scoped_refptr<base::SingleThreadTaskRunner>& client_runner_in, const OpenWithDialogCallback& callback_in) @@ -104,8 +104,8 @@ void OpenWithDialogTask(OpenWithContext* context) { void OpenWithDialogAsync( HWND parent_window, - const string16& file_name, - const string16& file_type_class, + const base::string16& file_name, + const base::string16& file_type_class, int open_as_info_flags, const OpenWithDialogCallback& callback) { DCHECK_GE(base::win::GetVersion(), base::win::VERSION_VISTA); diff --git a/win8/test/open_with_dialog_async.h b/win8/test/open_with_dialog_async.h index 9f926454b0..62ddbed01c 100644 --- a/win8/test/open_with_dialog_async.h +++ b/win8/test/open_with_dialog_async.h @@ -25,8 +25,8 @@ typedef base::Callback<void(HRESULT)> OpenWithDialogCallback; // the dedicated thread will be leaked if the calling thread's message loop goes // away before the interaction completes. void OpenWithDialogAsync(HWND parent_window, - const string16& file_name, - const string16& file_type_class, + const base::string16& file_name, + const base::string16& file_type_class, int open_as_info_flags, const OpenWithDialogCallback& callback); diff --git a/win8/test/open_with_dialog_controller.cc b/win8/test/open_with_dialog_controller.cc index 86b8161561..5a454ef4d5 100644 --- a/win8/test/open_with_dialog_controller.cc +++ b/win8/test/open_with_dialog_controller.cc @@ -31,9 +31,9 @@ const wchar_t kShellFlyoutClassName[] = L"Shell_Flyout"; void OnMakeDefaultComplete( const base::Closure& closure, HRESULT* result_out, - std::vector<string16>* choices_out, + std::vector<base::string16>* choices_out, HRESULT hr, - std::vector<string16> choices) { + std::vector<base::string16> choices) { *result_out = hr; *choices_out = choices; closure.Run(); @@ -53,8 +53,8 @@ class OpenWithDialogController::Context { void Orphan(); void Begin(HWND parent_window, - const string16& url_protocol, - const string16& program_name, + const base::string16& url_protocol, + const base::string16& program_name, const OpenWithDialogController::SetDefaultCallback& callback); private: @@ -75,20 +75,20 @@ class OpenWithDialogController::Context { void OnTimeout(); void OnInitialized(HRESULT result); - void OnAutomationResult(HRESULT result, std::vector<string16> choices); + void OnAutomationResult(HRESULT result, std::vector<base::string16> choices); void OnOpenWithComplete(HRESULT result); base::ThreadChecker thread_checker_; State state_; internal::UIAutomationClient automation_client_; HWND parent_window_; - string16 file_name_; - string16 file_type_class_; + base::string16 file_name_; + base::string16 file_type_class_; int open_as_info_flags_; OpenWithDialogController::SetDefaultCallback callback_; HRESULT open_with_result_; HRESULT automation_result_; - std::vector<string16> automation_choices_; + std::vector<base::string16> automation_choices_; base::WeakPtrFactory<Context> weak_ptr_factory_; DISALLOW_COPY_AND_ASSIGN(OpenWithDialogController::Context); }; @@ -124,8 +124,8 @@ void OpenWithDialogController::Context::Orphan() { void OpenWithDialogController::Context::Begin( HWND parent_window, - const string16& url_protocol, - const string16& program_name, + const base::string16& url_protocol, + const base::string16& program_name, const OpenWithDialogController::SetDefaultCallback& callback) { DCHECK(thread_checker_.CalledOnValidThread()); @@ -191,7 +191,7 @@ void OpenWithDialogController::Context::OnInitialized(HRESULT result) { void OpenWithDialogController::Context::OnAutomationResult( HRESULT result, - std::vector<string16> choices) { + std::vector<base::string16> choices) { DCHECK(thread_checker_.CalledOnValidThread()); DCHECK_EQ(automation_result_, E_FAIL); @@ -244,8 +244,8 @@ OpenWithDialogController::~OpenWithDialogController() { void OpenWithDialogController::Begin( HWND parent_window, - const string16& url_protocol, - const string16& program, + const base::string16& url_protocol, + const base::string16& program, const SetDefaultCallback& callback) { DCHECK_EQ(context_.get(), static_cast<Context*>(NULL)); if (base::win::GetVersion() < base::win::VERSION_WIN8) { @@ -254,7 +254,7 @@ void OpenWithDialogController::Begin( // to this thread's task runner to call it. base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, - base::Bind(callback, E_FAIL, std::vector<string16>())); + base::Bind(callback, E_FAIL, std::vector<base::string16>())); return; } @@ -264,9 +264,9 @@ void OpenWithDialogController::Begin( HRESULT OpenWithDialogController::RunSynchronously( HWND parent_window, - const string16& protocol, - const string16& program, - std::vector<string16>* choices) { + const base::string16& protocol, + const base::string16& program, + std::vector<base::string16>* choices) { DCHECK_EQ(base::MessageLoop::current(), static_cast<base::MessageLoop*>(NULL)); if (base::win::GetVersion() < base::win::VERSION_WIN8) { diff --git a/win8/test/open_with_dialog_controller.h b/win8/test/open_with_dialog_controller.h index 4354a56d16..18ac9e91fc 100644 --- a/win8/test/open_with_dialog_controller.h +++ b/win8/test/open_with_dialog_controller.h @@ -24,8 +24,8 @@ class OpenWithDialogController { // interaction. If the HRESULT indicates success, the interaction completed // successfully. Otherwise, the vector of strings may contain the list of // possible choices if the desired program could not be selected. - typedef base::Callback<void(HRESULT, - std::vector<string16>)> SetDefaultCallback; + typedef base::Callback<void(HRESULT, std::vector<base::string16>)> + SetDefaultCallback; OpenWithDialogController(); ~OpenWithDialogController(); @@ -38,8 +38,8 @@ class OpenWithDialogController { // since |program| will not show up verbatim in the dialog (e.g., in EN-US, it // will be prefixed by "Keep using "). void Begin(HWND parent_window, - const string16& url_protocol, - const string16& program, + const base::string16& url_protocol, + const base::string16& program, const SetDefaultCallback& callback); // Sychronously drives the dialog by running a message loop. Do not by any @@ -47,9 +47,9 @@ class OpenWithDialogController { // on success. Otherwise, |choices| may contain the list of possible choices // if the desired program could not be selected. HRESULT RunSynchronously(HWND parent_window, - const string16& url_protocol, - const string16& program, - std::vector<string16>* choices); + const base::string16& url_protocol, + const base::string16& program, + std::vector<base::string16>* choices); private: class Context; diff --git a/win8/test/test_registrar.cc b/win8/test/test_registrar.cc index 25445c91e7..b5cec10333 100644 --- a/win8/test/test_registrar.cc +++ b/win8/test/test_registrar.cc @@ -92,18 +92,18 @@ class TestDelegateExecuteModule command_line.GetSwitchValueNative( win8::test::kTestProgId).c_str()); - string16 exe_path( + base::string16 exe_path( command_line.GetSwitchValueNative(win8::test::kTestExePath)); - string16 exe_open_command(base::StringPrintf(L"\"%ls\" -- %%*", - exe_path.c_str())); + base::string16 exe_open_command( + base::StringPrintf(L"\"%ls\" -- %%*", exe_path.c_str())); registrar->AddReplacement(L"EXE_OPEN_COMMAND", exe_open_command.c_str()); - string16 exe_icon(base::StringPrintf(L"%ls,0", exe_path.c_str())); + base::string16 exe_icon(base::StringPrintf(L"%ls,0", exe_path.c_str())); registrar->AddReplacement(L"EXE_ICON", exe_icon.c_str()); - string16 prog_id_open_command(base::StringPrintf(L"\"%ls\" -- \"%%1\"", - exe_path.c_str())); + base::string16 prog_id_open_command( + base::StringPrintf(L"\"%ls\" -- \"%%1\"", exe_path.c_str())); registrar->AddReplacement(L"PROG_ID_OPEN_COMMAND", prog_id_open_command.c_str()); diff --git a/win8/test/ui_automation_client.cc b/win8/test/ui_automation_client.cc index ef2d9babcb..6af9bc402e 100644 --- a/win8/test/ui_automation_client.cc +++ b/win8/test/ui_automation_client.cc @@ -40,8 +40,8 @@ class UIAutomationClient::Context { // posting |init_callback|. void Initialize( scoped_refptr<base::SingleThreadTaskRunner> client_runner, - string16 class_name, - string16 item_name, + base::string16 class_name, + base::string16 item_name, UIAutomationClient::InitializedCallback init_callback, UIAutomationClient::ResultCallback result_callback); @@ -69,7 +69,7 @@ class UIAutomationClient::Context { const base::win::ScopedComPtr<IUIAutomationElement>& element); HRESULT GetInvokableItems( const base::win::ScopedComPtr<IUIAutomationElement>& element, - std::vector<string16>* choices); + std::vector<base::string16>* choices); void CloseWindow(const base::win::ScopedComPtr<IUIAutomationElement>& window); base::ThreadChecker thread_checker_; @@ -78,10 +78,10 @@ class UIAutomationClient::Context { scoped_refptr<base::SingleThreadTaskRunner> client_runner_; // The class name of the window for which the client waits. - string16 class_name_; + base::string16 class_name_; // The name of the item to invoke. - string16 item_name_; + base::string16 item_name_; // The consumer's result callback. ResultCallback result_callback_; @@ -180,8 +180,8 @@ UIAutomationClient::Context::~Context() { void UIAutomationClient::Context::Initialize( scoped_refptr<base::SingleThreadTaskRunner> client_runner, - string16 class_name, - string16 item_name, + base::string16 class_name, + base::string16 item_name, UIAutomationClient::InitializedCallback init_callback, UIAutomationClient::ResultCallback result_callback) { // This and all other methods must be called on the automation thread. @@ -325,7 +325,7 @@ void UIAutomationClient::Context::HandleWindowOpen( return; } - string16 class_name(V_BSTR(&var)); + base::string16 class_name(V_BSTR(&var)); // Window class names are atoms, which are case-insensitive. if (class_name.size() == class_name_.size() && @@ -345,7 +345,7 @@ void UIAutomationClient::Context::ProcessWindow( DCHECK(thread_checker_.CalledOnValidThread()); HRESULT result = S_OK; - std::vector<string16> choices; + std::vector<base::string16> choices; result = InvokeDesiredItem(window); if (FAILED(result)) { GetInvokableItems(window, &choices); @@ -457,7 +457,7 @@ HRESULT UIAutomationClient::Context::InvokeDesiredItem( // Populates |choices| with the names of all invokable children of |element|. HRESULT UIAutomationClient::Context::GetInvokableItems( const base::win::ScopedComPtr<IUIAutomationElement>& element, - std::vector<string16>* choices) { + std::vector<base::string16>* choices) { DCHECK(choices); DCHECK(thread_checker_.CalledOnValidThread()); @@ -545,7 +545,7 @@ HRESULT UIAutomationClient::Context::GetInvokableItems( LOG(ERROR) << __FUNCTION__ " name is not a BSTR: " << V_VT(&var); continue; } - choices->push_back(string16(V_BSTR(&var))); + choices->push_back(base::string16(V_BSTR(&var))); var.Reset(); } @@ -602,7 +602,7 @@ UIAutomationClient::~UIAutomationClient() { } void UIAutomationClient::Begin(const wchar_t* class_name, - const string16& item_name, + const base::string16& item_name, const InitializedCallback& init_callback, const ResultCallback& result_callback) { DCHECK(thread_checker_.CalledOnValidThread()); @@ -617,7 +617,7 @@ void UIAutomationClient::Begin(const wchar_t* class_name, base::Bind(&UIAutomationClient::Context::Initialize, context_, base::ThreadTaskRunnerHandle::Get(), - string16(class_name), + base::string16(class_name), item_name, init_callback, result_callback)); diff --git a/win8/test/ui_automation_client.h b/win8/test/ui_automation_client.h index 7e9832968a..e8b89f7516 100644 --- a/win8/test/ui_automation_client.h +++ b/win8/test/ui_automation_client.h @@ -36,7 +36,8 @@ class UIAutomationClient { // If the HRESULT argument indicates success, the desired item in the window // was invoked. Otherwise, the string vector (if not empty) contains the list // of possible items in the window. - typedef base::Callback<void(HRESULT, std::vector<string16>)> ResultCallback; + typedef base::Callback<void(HRESULT, std::vector<base::string16>)> + ResultCallback; UIAutomationClient(); ~UIAutomationClient(); @@ -46,7 +47,7 @@ class UIAutomationClient { // Otherwise, |result_callback| will be invoked once |item_name| has been // invoked. void Begin(const wchar_t* class_name, - const string16& item_name, + const base::string16& item_name, const InitializedCallback& init_callback, const ResultCallback& result_callback); diff --git a/win8/viewer/metro_viewer_process_host.cc b/win8/viewer/metro_viewer_process_host.cc index 6832dbae6b..4fa519405c 100644 --- a/win8/viewer/metro_viewer_process_host.cc +++ b/win8/viewer/metro_viewer_process_host.cc @@ -17,7 +17,7 @@ #include "base/win/scoped_comptr.h" #include "ipc/ipc_message.h" #include "ipc/ipc_message_macros.h" -#include "ui/aura/remote_root_window_host_win.h" +#include "ui/aura/remote_window_tree_host_win.h" #include "ui/metro_viewer/metro_viewer_messages.h" #include "win8/viewer/metro_viewer_constants.h" @@ -102,7 +102,7 @@ bool MetroViewerProcessHost::OnMessageReceived( IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() return handled ? true : - aura::RemoteRootWindowHostWin::Instance()->OnMessageReceived(message); + aura::RemoteWindowTreeHostWin::Instance()->OnMessageReceived(message); } void MetroViewerProcessHost::NotifyChannelConnected() { diff --git a/win8/viewer/metro_viewer_process_host.h b/win8/viewer/metro_viewer_process_host.h index ad034ada07..e156226e86 100644 --- a/win8/viewer/metro_viewer_process_host.h +++ b/win8/viewer/metro_viewer_process_host.h @@ -66,12 +66,12 @@ class MetroViewerProcessHost : public IPC::Listener, // Called over IPC by the viewer process to request that the url passed in be // opened. - virtual void OnOpenURL(const string16& url) = 0; + virtual void OnOpenURL(const base::string16& url) = 0; // Called over IPC by the viewer process to request that the search string // passed in is passed to the default search provider and a URL navigation be // performed. - virtual void OnHandleSearchRequest(const string16& search_string) = 0; + virtual void OnHandleSearchRequest(const base::string16& search_string) = 0; // Called over IPC by the viewer process when the window size has changed. virtual void OnWindowSizeChanged(uint32 width, uint32 height) = 0; |