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

Unified Diff: chrome/browser/ui/views/apps/chrome_native_app_window_views.cc

Issue 949553002: Start using the controller in app's view. Base URL: https://chromium.googlesource.com/chromium/src.git@fsRefactor
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/views/apps/chrome_native_app_window_views.cc
diff --git a/chrome/browser/ui/views/apps/chrome_native_app_window_views.cc b/chrome/browser/ui/views/apps/chrome_native_app_window_views.cc
index cb150261b2e9a0bce1ba8018bf80c04f7dc8a2fc..24ca1ba876d52b25833abfefba7b36f1459d015c 100644
--- a/chrome/browser/ui/views/apps/chrome_native_app_window_views.cc
+++ b/chrome/browser/ui/views/apps/chrome_native_app_window_views.cc
@@ -10,15 +10,19 @@
#include "chrome/browser/app_mode/app_mode_utils.h"
#include "chrome/browser/favicon/favicon_tab_helper.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/exclusive_access/exclusive_access_manager.h"
+#include "chrome/browser/ui/exclusive_access/mouse_lock_controller.h"
#include "chrome/browser/ui/host_desktop.h"
#include "chrome/browser/ui/views/apps/desktop_keyboard_capture.h"
#include "chrome/browser/ui/views/apps/shaped_app_window_targeter.h"
+#include "chrome/browser/ui/views/exclusive_access_bubble_views.h"
#include "chrome/browser/ui/views/extensions/extension_keybinding_registry_views.h"
#include "chrome/browser/ui/views/frame/taskbar_decorator.h"
#include "chrome/browser/web_applications/web_app.h"
#include "chrome/common/chrome_switches.h"
#include "components/ui/zoom/page_zoom.h"
#include "components/ui/zoom/zoom_controller.h"
+#include "content/public/browser/native_web_keyboard_event.h"
#include "extensions/common/extension.h"
#include "ui/aura/window.h"
#include "ui/base/hit_test.h"
@@ -199,7 +203,9 @@ ChromeNativeAppWindowViews::ChromeNativeAppWindowViews()
: is_fullscreen_(false),
has_frame_color_(false),
active_frame_color_(SK_ColorBLACK),
- inactive_frame_color_(SK_ColorBLACK) {
+ inactive_frame_color_(SK_ColorBLACK),
+ key_capture_requested_(false) {
+ exclusive_access_manager_.reset(new ExclusiveAccessManager(this));
}
ChromeNativeAppWindowViews::~ChromeNativeAppWindowViews() {}
@@ -385,6 +391,28 @@ ChromeNativeAppWindowViews::CreateNonStandardAppFrame() {
return frame;
}
+void ChromeNativeAppWindowViews::Activate() {
+ NativeAppWindowViews::Activate();
+ exclusive_access_manager_->OnTabDetachedFromView(GetActiveWebContents());
+}
+
+void ChromeNativeAppWindowViews::Deactivate() {
+ NativeAppWindowViews::Deactivate();
+ exclusive_access_manager_->OnTabDeactivated(GetActiveWebContents());
+}
+
+bool ChromeNativeAppWindowViews::PreHandleKeyboardEvent(
+ content::WebContents* source,
+ const content::NativeWebKeyboardEvent& event,
+ bool* is_keyboard_shortcut) {
+ if (event.windowsKeyCode == ui::VKEY_ESCAPE &&
+ exclusive_access_manager_->HandleUserPressedEscape()) {
+ return true;
+ }
+ return NativeAppWindowViews::PreHandleKeyboardEvent(source, event,
+ is_keyboard_shortcut);
+}
+
// ui::BaseWindow implementation.
gfx::Rect ChromeNativeAppWindowViews::GetRestoredBounds() const {
@@ -685,10 +713,18 @@ SkColor ChromeNativeAppWindowViews::InactiveFrameColor() const {
}
void ChromeNativeAppWindowViews::SetInterceptAllKeys(bool want_all_keys) {
- if (want_all_keys && (desktop_keyboard_capture_.get() == NULL)) {
- desktop_keyboard_capture_.reset(new DesktopKeyboardCapture(widget()));
- } else if (!want_all_keys) {
- desktop_keyboard_capture_.reset(NULL);
+ // Noop if there is no state change.
+ if (want_all_keys == key_capture_requested_) {
+ return;
+ }
+
+ key_capture_requested_ = want_all_keys;
+ if (want_all_keys) {
+ exclusive_access_manager_->mouse_lock_controller()->RequestToLockMouse(
+ GetActiveWebContents(), true, true);
+ } else {
+ desktop_keyboard_capture_.reset(nullptr);
+ exclusive_access_manager_->mouse_lock_controller()->LostMouseLock();
}
}
@@ -713,3 +749,103 @@ void ChromeNativeAppWindowViews::InitializeWindow(
extensions::ExtensionKeybindingRegistry::PLATFORM_APPS_ONLY,
NULL));
}
+
+// ExclusiveAccessContext implementation
+
+Profile* ChromeNativeAppWindowViews::GetProfile() {
+ return Profile::FromBrowserContext(app_window()->browser_context());
+}
+
+bool ChromeNativeAppWindowViews::IsFullscreen() const {
+ return NativeAppWindowViews::IsFullscreen();
+}
+
+bool ChromeNativeAppWindowViews::IsFullscreenWithToolbar() {
+ return false;
+}
+
+bool ChromeNativeAppWindowViews::SupportsFullscreenWithToolbar() {
+ return false;
+}
+
+void ChromeNativeAppWindowViews::EnterFullscreen(
+ const GURL& url,
+ ExclusiveAccessBubbleType bubble_type,
+ bool with_toolbar) {
+ app_window()->Fullscreen();
+ UpdateExclusiveAccessExitBubbleContent(url, bubble_type);
+}
+
+void ChromeNativeAppWindowViews::ExitFullscreen() {
+ app_window()->Restore();
+ UpdateExclusiveAccessExitBubbleContent(GURL(),
+ EXCLUSIVE_ACCESS_BUBBLE_TYPE_NONE);
+}
+
+void ChromeNativeAppWindowViews::UpdateExclusiveAccessExitBubbleContent(
+ GURL url,
+ ExclusiveAccessBubbleType bubble_type) {
+ if (bubble_type == EXCLUSIVE_ACCESS_BUBBLE_TYPE_NONE || url.is_empty()) {
+ exclusive_access_bubble_views_.reset();
+ } else if (exclusive_access_bubble_views_.get()) {
+ exclusive_access_bubble_views_->UpdateContent(url, bubble_type);
+ } else {
+ exclusive_access_bubble_views_.reset(
+ new ExclusiveAccessBubbleViews(this, url, bubble_type));
+ }
+}
+
+content::WebContents* ChromeNativeAppWindowViews::GetActiveWebContents() {
+ return web_view()->GetWebContents();
+}
+
+void ChromeNativeAppWindowViews::UpdateFullscreenWithToolbar(
+ bool with_toolbar) {
+ // This is currently a Mac only feature.
+ NOTIMPLEMENTED();
+}
+
+void ChromeNativeAppWindowViews::SetMetroSnapMode(bool enable) {
+ // Not implemented for chrome app.
+ NOTIMPLEMENTED();
+}
+
+bool ChromeNativeAppWindowViews::IsInMetroSnapMode() {
+ return false;
+}
+
+void ChromeNativeAppWindowViews::UpdateDownloadShelf(bool unhide) {
+ // Apps don't have a download shelf and so nothing to do here.
+}
+
+bool ChromeNativeAppWindowViews::UseCallbackForMouseLock() {
+ return true;
+}
+
+bool ChromeNativeAppWindowViews::MouseLockCallback(bool acquired) {
+ if (key_capture_requested_ && acquired) {
+ desktop_keyboard_capture_.reset(new DesktopKeyboardCapture(widget()));
+ } else {
+ desktop_keyboard_capture_.reset(nullptr);
+ }
+
+ return key_capture_requested_;
+}
+
+// ExclusiveAccessBubbleViewsContext implementation
+ExclusiveAccessManager*
+ChromeNativeAppWindowViews::GetExclusiveAccessManager() {
+ return exclusive_access_manager_.get();
+}
+
+views::Widget* ChromeNativeAppWindowViews::GetWidget() {
+ return widget();
+}
+
+bool ChromeNativeAppWindowViews::IsImmersiveModeEnabled() {
+ return false;
+}
+
+gfx::Rect ChromeNativeAppWindowViews::GetTopContainerBoundsInScreen() {
+ return widget()->GetWindowBoundsInScreen();
+}
« no previous file with comments | « chrome/browser/ui/views/apps/chrome_native_app_window_views.h ('k') | extensions/browser/app_window/native_app_window.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698