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

Side by Side Diff: extensions/browser/app_window/app_window.cc

Issue 297123002: API proposal for chrome.app.window to intercept all keys. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix class comments based on Sadrul's comments Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "extensions/browser/app_window/app_window.h" 5 #include "extensions/browser/app_window/app_window.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 window_type_(WINDOW_TYPE_DEFAULT), 235 window_type_(WINDOW_TYPE_DEFAULT),
236 app_delegate_(app_delegate), 236 app_delegate_(app_delegate),
237 image_loader_ptr_factory_(this), 237 image_loader_ptr_factory_(this),
238 fullscreen_types_(FULLSCREEN_TYPE_NONE), 238 fullscreen_types_(FULLSCREEN_TYPE_NONE),
239 show_on_first_paint_(false), 239 show_on_first_paint_(false),
240 first_paint_complete_(false), 240 first_paint_complete_(false),
241 has_been_shown_(false), 241 has_been_shown_(false),
242 can_send_events_(false), 242 can_send_events_(false),
243 is_hidden_(false), 243 is_hidden_(false),
244 cached_always_on_top_(false), 244 cached_always_on_top_(false),
245 requested_alpha_enabled_(false) { 245 requested_alpha_enabled_(false),
246 cached_want_all_keys_(false) {
246 ExtensionsBrowserClient* client = ExtensionsBrowserClient::Get(); 247 ExtensionsBrowserClient* client = ExtensionsBrowserClient::Get();
247 CHECK(!client->IsGuestSession(context) || context->IsOffTheRecord()) 248 CHECK(!client->IsGuestSession(context) || context->IsOffTheRecord())
248 << "Only off the record window may be opened in the guest mode."; 249 << "Only off the record window may be opened in the guest mode.";
249 } 250 }
250 251
251 void AppWindow::Init(const GURL& url, 252 void AppWindow::Init(const GURL& url,
252 AppWindowContents* app_window_contents, 253 AppWindowContents* app_window_contents,
253 const CreateParams& params) { 254 const CreateParams& params) {
254 // Initialize the render interface and web contents 255 // Initialize the render interface and web contents
255 app_window_contents_.reset(app_window_contents); 256 app_window_contents_.reset(app_window_contents);
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 // that to happen, we need to define a size for the content, otherwise the 342 // that to happen, we need to define a size for the content, otherwise the
342 // layout will happen in a 0x0 area. 343 // layout will happen in a 0x0 area.
343 gfx::Insets frame_insets = native_app_window_->GetFrameInsets(); 344 gfx::Insets frame_insets = native_app_window_->GetFrameInsets();
344 gfx::Rect initial_bounds = new_params.GetInitialWindowBounds(frame_insets); 345 gfx::Rect initial_bounds = new_params.GetInitialWindowBounds(frame_insets);
345 initial_bounds.Inset(frame_insets); 346 initial_bounds.Inset(frame_insets);
346 app_delegate_->ResizeWebContents(web_contents, initial_bounds.size()); 347 app_delegate_->ResizeWebContents(web_contents, initial_bounds.size());
347 } 348 }
348 } 349 }
349 350
350 AppWindow::~AppWindow() { 351 AppWindow::~AppWindow() {
352 if (cached_want_all_keys_) {
353 native_app_window_->SetInterceptAllKeys(false);
354 cached_want_all_keys_ = false;
355 }
351 } 356 }
352 357
353 void AppWindow::RequestMediaAccessPermission( 358 void AppWindow::RequestMediaAccessPermission(
354 content::WebContents* web_contents, 359 content::WebContents* web_contents,
355 const content::MediaStreamRequest& request, 360 const content::MediaStreamRequest& request,
356 const content::MediaResponseCallback& callback) { 361 const content::MediaResponseCallback& callback) {
357 DCHECK_EQ(AppWindow::web_contents(), web_contents); 362 DCHECK_EQ(AppWindow::web_contents(), web_contents);
358 helper_->RequestMediaAccessPermission(request, callback); 363 helper_->RequestMediaAccessPermission(request, callback);
359 } 364 }
360 365
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
704 // overlap the taskbar to be on top. The property will be applied when the 709 // overlap the taskbar to be on top. The property will be applied when the
705 // window exits fullscreen and moves away from the taskbar. 710 // window exits fullscreen and moves away from the taskbar.
706 if (!IsFullscreen() && !IntersectsWithTaskbar()) 711 if (!IsFullscreen() && !IntersectsWithTaskbar())
707 native_app_window_->SetAlwaysOnTop(always_on_top); 712 native_app_window_->SetAlwaysOnTop(always_on_top);
708 713
709 OnNativeWindowChanged(); 714 OnNativeWindowChanged();
710 } 715 }
711 716
712 bool AppWindow::IsAlwaysOnTop() const { return cached_always_on_top_; } 717 bool AppWindow::IsAlwaysOnTop() const { return cached_always_on_top_; }
713 718
719 void AppWindow::SetInterceptAllKeys(bool want_all_keys) {
720 if (cached_want_all_keys_ != want_all_keys) {
721 native_app_window_->SetInterceptAllKeys(want_all_keys);
722 cached_want_all_keys_ = want_all_keys;
723 }
724 }
725
714 void AppWindow::WindowEventsReady() { 726 void AppWindow::WindowEventsReady() {
715 can_send_events_ = true; 727 can_send_events_ = true;
716 SendOnWindowShownIfShown(); 728 SendOnWindowShownIfShown();
717 } 729 }
718 730
719 void AppWindow::GetSerializedState(base::DictionaryValue* properties) const { 731 void AppWindow::GetSerializedState(base::DictionaryValue* properties) const {
720 DCHECK(properties); 732 DCHECK(properties);
721 733
722 properties->SetBoolean("fullscreen", 734 properties->SetBoolean("fullscreen",
723 native_app_window_->IsFullscreenOrPending()); 735 native_app_window_->IsFullscreenOrPending());
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
1089 region.bounds.x(), 1101 region.bounds.x(),
1090 region.bounds.y(), 1102 region.bounds.y(),
1091 region.bounds.right(), 1103 region.bounds.right(),
1092 region.bounds.bottom(), 1104 region.bounds.bottom(),
1093 region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op); 1105 region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op);
1094 } 1106 }
1095 return sk_region; 1107 return sk_region;
1096 } 1108 }
1097 1109
1098 } // namespace extensions 1110 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698