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

Side by Side Diff: apps/app_window.cc

Issue 486153002: Move AppWindow related classes to extensions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « apps/app_window.h ('k') | apps/app_window_geometry_cache.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "apps/app_window.h" 5 #include "apps/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
11 #include "apps/app_delegate.h"
12 #include "apps/app_web_contents_helper.h"
13 #include "apps/app_window_geometry_cache.h"
14 #include "apps/app_window_registry.h" 11 #include "apps/app_window_registry.h"
15 #include "apps/ui/apps_client.h" 12 #include "apps/ui/apps_client.h"
16 #include "apps/ui/web_contents_sizer.h" 13 #include "apps/ui/web_contents_sizer.h"
17 #include "base/command_line.h" 14 #include "base/command_line.h"
18 #include "base/strings/string_util.h" 15 #include "base/strings/string_util.h"
19 #include "base/strings/utf_string_conversions.h" 16 #include "base/strings/utf_string_conversions.h"
20 #include "base/values.h" 17 #include "base/values.h"
21 #include "chrome/browser/chrome_notification_types.h" 18 #include "chrome/browser/chrome_notification_types.h"
22 #include "components/web_modal/web_contents_modal_dialog_manager.h" 19 #include "components/web_modal/web_contents_modal_dialog_manager.h"
23 #include "content/public/browser/browser_context.h" 20 #include "content/public/browser/browser_context.h"
24 #include "content/public/browser/invalidate_type.h" 21 #include "content/public/browser/invalidate_type.h"
25 #include "content/public/browser/navigation_entry.h" 22 #include "content/public/browser/navigation_entry.h"
26 #include "content/public/browser/notification_details.h" 23 #include "content/public/browser/notification_details.h"
27 #include "content/public/browser/notification_service.h" 24 #include "content/public/browser/notification_service.h"
28 #include "content/public/browser/notification_source.h" 25 #include "content/public/browser/notification_source.h"
29 #include "content/public/browser/notification_types.h" 26 #include "content/public/browser/notification_types.h"
30 #include "content/public/browser/render_view_host.h" 27 #include "content/public/browser/render_view_host.h"
31 #include "content/public/browser/resource_dispatcher_host.h" 28 #include "content/public/browser/resource_dispatcher_host.h"
32 #include "content/public/browser/web_contents.h" 29 #include "content/public/browser/web_contents.h"
33 #include "content/public/common/content_switches.h" 30 #include "content/public/common/content_switches.h"
34 #include "content/public/common/media_stream_request.h" 31 #include "content/public/common/media_stream_request.h"
32 #include "extensions/browser/app_window/app_delegate.h"
33 #include "extensions/browser/app_window/app_web_contents_helper.h"
34 #include "extensions/browser/app_window/app_window_geometry_cache.h"
35 #include "extensions/browser/app_window/native_app_window.h" 35 #include "extensions/browser/app_window/native_app_window.h"
36 #include "extensions/browser/app_window/size_constraints.h" 36 #include "extensions/browser/app_window/size_constraints.h"
37 #include "extensions/browser/extension_registry.h" 37 #include "extensions/browser/extension_registry.h"
38 #include "extensions/browser/extension_system.h" 38 #include "extensions/browser/extension_system.h"
39 #include "extensions/browser/extensions_browser_client.h" 39 #include "extensions/browser/extensions_browser_client.h"
40 #include "extensions/browser/notification_types.h" 40 #include "extensions/browser/notification_types.h"
41 #include "extensions/browser/process_manager.h" 41 #include "extensions/browser/process_manager.h"
42 #include "extensions/browser/suggest_permission_util.h" 42 #include "extensions/browser/suggest_permission_util.h"
43 #include "extensions/browser/view_type_utils.h" 43 #include "extensions/browser/view_type_utils.h"
44 #include "extensions/common/draggable_region.h" 44 #include "extensions/common/draggable_region.h"
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 gfx::Size AppWindow::CreateParams::GetWindowMaximumSize( 221 gfx::Size AppWindow::CreateParams::GetWindowMaximumSize(
222 const gfx::Insets& frame_insets) const { 222 const gfx::Insets& frame_insets) const {
223 return GetCombinedWindowConstraints(window_spec.maximum_size, 223 return GetCombinedWindowConstraints(window_spec.maximum_size,
224 content_spec.maximum_size, 224 content_spec.maximum_size,
225 frame_insets); 225 frame_insets);
226 } 226 }
227 227
228 // AppWindow 228 // AppWindow
229 229
230 AppWindow::AppWindow(BrowserContext* context, 230 AppWindow::AppWindow(BrowserContext* context,
231 AppDelegate* app_delegate, 231 extensions::AppDelegate* app_delegate,
232 const extensions::Extension* extension) 232 const extensions::Extension* extension)
233 : browser_context_(context), 233 : browser_context_(context),
234 extension_id_(extension->id()), 234 extension_id_(extension->id()),
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),
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 cached_always_on_top_ = new_params.always_on_top; 278 cached_always_on_top_ = new_params.always_on_top;
279 if (new_params.state == ui::SHOW_STATE_FULLSCREEN) 279 if (new_params.state == ui::SHOW_STATE_FULLSCREEN)
280 new_params.always_on_top = false; 280 new_params.always_on_top = false;
281 281
282 requested_alpha_enabled_ = new_params.alpha_enabled; 282 requested_alpha_enabled_ = new_params.alpha_enabled;
283 283
284 AppsClient* apps_client = AppsClient::Get(); 284 AppsClient* apps_client = AppsClient::Get();
285 native_app_window_.reset( 285 native_app_window_.reset(
286 apps_client->CreateNativeAppWindow(this, new_params)); 286 apps_client->CreateNativeAppWindow(this, new_params));
287 287
288 helper_.reset(new AppWebContentsHelper( 288 helper_.reset(new extensions::AppWebContentsHelper(
289 browser_context_, extension_id_, web_contents, app_delegate_.get())); 289 browser_context_, extension_id_, web_contents, app_delegate_.get()));
290 290
291 popup_manager_.reset( 291 popup_manager_.reset(
292 new web_modal::PopupManager(GetWebContentsModalDialogHost())); 292 new web_modal::PopupManager(GetWebContentsModalDialogHost()));
293 popup_manager_->RegisterWith(web_contents); 293 popup_manager_->RegisterWith(web_contents);
294 294
295 // Prevent the browser process from shutting down while this window exists. 295 // Prevent the browser process from shutting down while this window exists.
296 apps_client->IncrementKeepAliveCount(); 296 apps_client->IncrementKeepAliveCount();
297 UpdateExtensionAppIcon(); 297 UpdateExtensionAppIcon();
298 AppWindowRegistry::Get(browser_context_)->AddAppWindow(this); 298 AppWindowRegistry::Get(browser_context_)->AddAppWindow(this);
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 433
434 void AppWindow::RequestToLockMouse(WebContents* web_contents, 434 void AppWindow::RequestToLockMouse(WebContents* web_contents,
435 bool user_gesture, 435 bool user_gesture,
436 bool last_unlocked_by_target) { 436 bool last_unlocked_by_target) {
437 DCHECK_EQ(AppWindow::web_contents(), web_contents); 437 DCHECK_EQ(AppWindow::web_contents(), web_contents);
438 helper_->RequestToLockMouse(); 438 helper_->RequestToLockMouse();
439 } 439 }
440 440
441 bool AppWindow::PreHandleGestureEvent(WebContents* source, 441 bool AppWindow::PreHandleGestureEvent(WebContents* source,
442 const blink::WebGestureEvent& event) { 442 const blink::WebGestureEvent& event) {
443 return AppWebContentsHelper::ShouldSuppressGestureEvent(event); 443 return extensions::AppWebContentsHelper::ShouldSuppressGestureEvent(event);
444 } 444 }
445 445
446 void AppWindow::DidFirstVisuallyNonEmptyPaint() { 446 void AppWindow::DidFirstVisuallyNonEmptyPaint() {
447 first_paint_complete_ = true; 447 first_paint_complete_ = true;
448 if (show_on_first_paint_) { 448 if (show_on_first_paint_) {
449 DCHECK(delayed_show_type_ == SHOW_ACTIVE || 449 DCHECK(delayed_show_type_ == SHOW_ACTIVE ||
450 delayed_show_type_ == SHOW_INACTIVE); 450 delayed_show_type_ == SHOW_INACTIVE);
451 Show(delayed_show_type_); 451 Show(delayed_show_type_);
452 } 452 }
453 } 453 }
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after
982 WebContentsModalDialogHost* AppWindow::GetWebContentsModalDialogHost() { 982 WebContentsModalDialogHost* AppWindow::GetWebContentsModalDialogHost() {
983 return native_app_window_.get(); 983 return native_app_window_.get();
984 } 984 }
985 985
986 void AppWindow::SaveWindowPosition() { 986 void AppWindow::SaveWindowPosition() {
987 if (window_key_.empty()) 987 if (window_key_.empty())
988 return; 988 return;
989 if (!native_app_window_) 989 if (!native_app_window_)
990 return; 990 return;
991 991
992 AppWindowGeometryCache* cache = 992 extensions::AppWindowGeometryCache* cache =
993 AppWindowGeometryCache::Get(browser_context()); 993 extensions::AppWindowGeometryCache::Get(browser_context());
994 994
995 gfx::Rect bounds = native_app_window_->GetRestoredBounds(); 995 gfx::Rect bounds = native_app_window_->GetRestoredBounds();
996 gfx::Rect screen_bounds = 996 gfx::Rect screen_bounds =
997 gfx::Screen::GetNativeScreen()->GetDisplayMatching(bounds).work_area(); 997 gfx::Screen::GetNativeScreen()->GetDisplayMatching(bounds).work_area();
998 ui::WindowShowState window_state = native_app_window_->GetRestoredState(); 998 ui::WindowShowState window_state = native_app_window_->GetRestoredState();
999 cache->SaveGeometry( 999 cache->SaveGeometry(
1000 extension_id(), window_key_, bounds, screen_bounds, window_state); 1000 extension_id(), window_key_, bounds, screen_bounds, window_state);
1001 } 1001 }
1002 1002
1003 void AppWindow::AdjustBoundsToBeVisibleOnScreen( 1003 void AppWindow::AdjustBoundsToBeVisibleOnScreen(
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1040 if (params.content_spec.bounds.height() == 0 && 1040 if (params.content_spec.bounds.height() == 0 &&
1041 params.window_spec.bounds.height() == 0) { 1041 params.window_spec.bounds.height() == 0) {
1042 params.content_spec.bounds.set_height(kDefaultHeight); 1042 params.content_spec.bounds.set_height(kDefaultHeight);
1043 } 1043 }
1044 1044
1045 // If left and top are left undefined, the native app window will center 1045 // If left and top are left undefined, the native app window will center
1046 // the window on the main screen in a platform-defined manner. 1046 // the window on the main screen in a platform-defined manner.
1047 1047
1048 // Load cached state if it exists. 1048 // Load cached state if it exists.
1049 if (!params.window_key.empty()) { 1049 if (!params.window_key.empty()) {
1050 AppWindowGeometryCache* cache = 1050 extensions::AppWindowGeometryCache* cache =
1051 AppWindowGeometryCache::Get(browser_context()); 1051 extensions::AppWindowGeometryCache::Get(browser_context());
1052 1052
1053 gfx::Rect cached_bounds; 1053 gfx::Rect cached_bounds;
1054 gfx::Rect cached_screen_bounds; 1054 gfx::Rect cached_screen_bounds;
1055 ui::WindowShowState cached_state = ui::SHOW_STATE_DEFAULT; 1055 ui::WindowShowState cached_state = ui::SHOW_STATE_DEFAULT;
1056 if (cache->GetGeometry(extension_id(), 1056 if (cache->GetGeometry(extension_id(),
1057 params.window_key, 1057 params.window_key,
1058 &cached_bounds, 1058 &cached_bounds,
1059 &cached_screen_bounds, 1059 &cached_screen_bounds,
1060 &cached_state)) { 1060 &cached_state)) {
1061 // App window has cached screen bounds, make sure it fits on screen in 1061 // App window has cached screen bounds, make sure it fits on screen in
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1095 region.bounds.x(), 1095 region.bounds.x(),
1096 region.bounds.y(), 1096 region.bounds.y(),
1097 region.bounds.right(), 1097 region.bounds.right(),
1098 region.bounds.bottom(), 1098 region.bounds.bottom(),
1099 region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op); 1099 region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op);
1100 } 1100 }
1101 return sk_region; 1101 return sk_region;
1102 } 1102 }
1103 1103
1104 } // namespace apps 1104 } // namespace apps
OLDNEW
« no previous file with comments | « apps/app_window.h ('k') | apps/app_window_geometry_cache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698