Commit a2357244 authored by Wei Lee's avatar Wei Lee Committed by Commit Bot

Adds CloseCameraApp in intent_helper.mojom

To better bind the lifetime of the camera proxy activity with CCA,
we should close CCA when camera proxy activity is manually destroyed.

The corresponding CL on ARC++ side is:
http://ag/9481116

Bug: 980812, 967611, b/131809655, b/134635999
Test: Tested with Hangouts app and CCA is closed as Hangouts closed.
Change-Id: I0050ba69ec8771c3064308131cdfdbc123adca4b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1835072
Commit-Queue: Wei Lee <wtlee@chromium.org>
Reviewed-by: default avatarSteven Bennetts <stevenjb@chromium.org>
Reviewed-by: default avatarDavid Jacobo <djacobo@chromium.org>
Reviewed-by: default avatarRobert Sesek <rsesek@chromium.org>
Reviewed-by: default avatarAhmed Fakhry <afakhry@chromium.org>
Cr-Commit-Position: refs/heads/master@{#709372}
parent c53fce1b
...@@ -57,6 +57,9 @@ class ASH_PUBLIC_EXPORT NewWindowDelegate { ...@@ -57,6 +57,9 @@ class ASH_PUBLIC_EXPORT NewWindowDelegate {
// information as url |queries|. // information as url |queries|.
virtual void LaunchCameraApp(const std::string& queries) = 0; virtual void LaunchCameraApp(const std::string& queries) = 0;
// Closes the camera app.
virtual void CloseCameraApp() = 0;
protected: protected:
NewWindowDelegate(); NewWindowDelegate();
virtual ~NewWindowDelegate(); virtual ~NewWindowDelegate();
......
...@@ -21,5 +21,6 @@ void TestNewWindowDelegate::ShowKeyboardShortcutViewer() {} ...@@ -21,5 +21,6 @@ void TestNewWindowDelegate::ShowKeyboardShortcutViewer() {}
void TestNewWindowDelegate::ShowTaskManager() {} void TestNewWindowDelegate::ShowTaskManager() {}
void TestNewWindowDelegate::OpenFeedbackPage(bool from_assistant) {} void TestNewWindowDelegate::OpenFeedbackPage(bool from_assistant) {}
void TestNewWindowDelegate::LaunchCameraApp(const std::string& queries) {} void TestNewWindowDelegate::LaunchCameraApp(const std::string& queries) {}
void TestNewWindowDelegate::CloseCameraApp() {}
} // namespace ash } // namespace ash
...@@ -29,6 +29,7 @@ class ASH_PUBLIC_EXPORT TestNewWindowDelegate : public NewWindowDelegate { ...@@ -29,6 +29,7 @@ class ASH_PUBLIC_EXPORT TestNewWindowDelegate : public NewWindowDelegate {
void ShowTaskManager() override; void ShowTaskManager() override;
void OpenFeedbackPage(bool from_assistant) override; void OpenFeedbackPage(bool from_assistant) override;
void LaunchCameraApp(const std::string& queries) override; void LaunchCameraApp(const std::string& queries) override;
void CloseCameraApp() override;
DISALLOW_COPY_AND_ASSIGN(TestNewWindowDelegate); DISALLOW_COPY_AND_ASSIGN(TestNewWindowDelegate);
}; };
......
...@@ -50,5 +50,7 @@ void ShellNewWindowDelegate::OpenFeedbackPage(bool from_assistant) {} ...@@ -50,5 +50,7 @@ void ShellNewWindowDelegate::OpenFeedbackPage(bool from_assistant) {}
void ShellNewWindowDelegate::LaunchCameraApp(const std::string& queries) {} void ShellNewWindowDelegate::LaunchCameraApp(const std::string& queries) {}
void ShellNewWindowDelegate::CloseCameraApp() {}
} // namespace shell } // namespace shell
} // namespace ash } // namespace ash
...@@ -33,6 +33,7 @@ class ShellNewWindowDelegate : public ash::NewWindowDelegate { ...@@ -33,6 +33,7 @@ class ShellNewWindowDelegate : public ash::NewWindowDelegate {
void ShowTaskManager() override; void ShowTaskManager() override;
void OpenFeedbackPage(bool from_assistant) override; void OpenFeedbackPage(bool from_assistant) override;
void LaunchCameraApp(const std::string& queries) override; void LaunchCameraApp(const std::string& queries) override;
void CloseCameraApp() override;
private: private:
DISALLOW_COPY_AND_ASSIGN(ShellNewWindowDelegate); DISALLOW_COPY_AND_ASSIGN(ShellNewWindowDelegate);
......
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
#include "ash/public/cpp/arc_custom_tab.h" #include "ash/public/cpp/arc_custom_tab.h"
#include "ash/public/cpp/ash_features.h" #include "ash/public/cpp/ash_features.h"
#include "ash/public/cpp/keyboard_shortcut_viewer.h" #include "ash/public/cpp/keyboard_shortcut_viewer.h"
#include "ash/public/cpp/shelf_model.h"
#include "ash/public/cpp/shelf_types.h"
#include "ash/public/mojom/constants.mojom.h" #include "ash/public/mojom/constants.mojom.h"
#include "base/macros.h" #include "base/macros.h"
#include "chrome/browser/apps/launch_service/launch_service.h" #include "chrome/browser/apps/launch_service/launch_service.h"
...@@ -25,6 +27,7 @@ ...@@ -25,6 +27,7 @@
#include "chrome/browser/prefs/incognito_mode_prefs.h" #include "chrome/browser/prefs/incognito_mode_prefs.h"
#include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/sessions/tab_restore_service_factory.h" #include "chrome/browser/sessions/tab_restore_service_factory.h"
#include "chrome/browser/ui/ash/launcher/app_window_launcher_item_controller.h"
#include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h"
#include "chrome/browser/ui/ash/multi_user/multi_user_util.h" #include "chrome/browser/ui/ash/multi_user/multi_user_util.h"
#include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser.h"
...@@ -56,6 +59,7 @@ ...@@ -56,6 +59,7 @@
#include "extensions/common/extension.h" #include "extensions/common/extension.h"
#include "services/service_manager/public/cpp/connector.h" #include "services/service_manager/public/cpp/connector.h"
#include "ui/aura/window.h" #include "ui/aura/window.h"
#include "ui/base/base_window.h"
#include "ui/base/page_transition_types.h" #include "ui/base/page_transition_types.h"
#include "ui/base/window_open_disposition.h" #include "ui/base/window_open_disposition.h"
#include "url/url_constants.h" #include "url/url_constants.h"
...@@ -345,6 +349,20 @@ void ChromeNewWindowClient::LaunchCameraApp(const std::string& queries) { ...@@ -345,6 +349,20 @@ void ChromeNewWindowClient::LaunchCameraApp(const std::string& queries) {
/*referrer_url=*/GURL()); /*referrer_url=*/GURL());
} }
void ChromeNewWindowClient::CloseCameraApp() {
const ash::ShelfID shelf_id(ash::kInternalAppIdCamera);
AppWindowLauncherItemController* const app_controller =
ChromeLauncherController::instance()
->shelf_model()
->GetAppWindowLauncherItemController(shelf_id);
if (!app_controller)
return;
DCHECK_LE(app_controller->window_count(), 1lu);
if (app_controller->window_count() > 0)
app_controller->windows().front()->Close();
}
void ChromeNewWindowClient::OpenUrlFromArc(const GURL& url) { void ChromeNewWindowClient::OpenUrlFromArc(const GURL& url) {
if (!url.is_valid()) if (!url.is_valid())
return; return;
......
...@@ -47,6 +47,7 @@ class ChromeNewWindowClient : public ash::NewWindowDelegate, ...@@ -47,6 +47,7 @@ class ChromeNewWindowClient : public ash::NewWindowDelegate,
void ShowTaskManager() override; void ShowTaskManager() override;
void OpenFeedbackPage(bool from_assistant) override; void OpenFeedbackPage(bool from_assistant) override;
void LaunchCameraApp(const std::string& queries) override; void LaunchCameraApp(const std::string& queries) override;
void CloseCameraApp() override;
// arc::OpenUrlDelegate: // arc::OpenUrlDelegate:
void OpenUrlFromArc(const GURL& url) override; void OpenUrlFromArc(const GURL& url) override;
......
...@@ -242,6 +242,12 @@ void ArcIntentHelperBridge::LaunchCameraApp(uint32_t intent_id, ...@@ -242,6 +242,12 @@ void ArcIntentHelperBridge::LaunchCameraApp(uint32_t intent_id,
ash::NewWindowDelegate::GetInstance()->LaunchCameraApp(queries.str()); ash::NewWindowDelegate::GetInstance()->LaunchCameraApp(queries.str());
} }
void ArcIntentHelperBridge::CloseCameraApp() {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
ash::NewWindowDelegate::GetInstance()->CloseCameraApp();
}
void ArcIntentHelperBridge::HandleCameraResult( void ArcIntentHelperBridge::HandleCameraResult(
uint32_t intent_id, uint32_t intent_id,
arc::mojom::CameraIntentAction action, arc::mojom::CameraIntentAction action,
......
...@@ -84,6 +84,7 @@ class ArcIntentHelperBridge : public KeyedService, ...@@ -84,6 +84,7 @@ class ArcIntentHelperBridge : public KeyedService,
bool should_handle_result, bool should_handle_result,
bool should_down_scale, bool should_down_scale,
bool is_secure) override; bool is_secure) override;
void CloseCameraApp() override;
void HandleCameraResult( void HandleCameraResult(
uint32_t intent_id, uint32_t intent_id,
arc::mojom::CameraIntentAction action, arc::mojom::CameraIntentAction action,
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// //
// Next MinVersion: 31 // Next MinVersion: 32
module arc.mojom; module arc.mojom;
...@@ -184,7 +184,7 @@ interface CustomTabSession { ...@@ -184,7 +184,7 @@ interface CustomTabSession {
// Handles intents from ARC in Chrome. // Handles intents from ARC in Chrome.
// Deprecated method ID: 4 // Deprecated method ID: 4
// Next method ID: 14 // Next method ID: 15
interface IntentHelperHost { interface IntentHelperHost {
// Called when icons associated with the package are no longer up to date. // Called when icons associated with the package are no longer up to date.
[MinVersion=3] OnIconInvalidated@1(string package_name); [MinVersion=3] OnIconInvalidated@1(string package_name);
...@@ -254,6 +254,9 @@ interface IntentHelperHost { ...@@ -254,6 +254,9 @@ interface IntentHelperHost {
// called when apps are installed, uninstalled or updated. // called when apps are installed, uninstalled or updated.
[MinVersion=29] OnIntentFiltersUpdatedForPackage@13( [MinVersion=29] OnIntentFiltersUpdatedForPackage@13(
string package_name, array<IntentFilter> intent_filters); string package_name, array<IntentFilter> intent_filters);
// Closes Chrome camera app.
[MinVersion=31] CloseCameraApp@14();
}; };
// Sends intents to ARC on behalf of Chrome. // Sends intents to ARC on behalf of Chrome.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment