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

Side by Side Diff: chrome/browser/ui/extensions/shell_window.cc

Issue 11222003: Remove TabContents creation from ShellWindow. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/ui/extensions/shell_window.h" 5 #include "chrome/browser/ui/extensions/shell_window.h"
6 6
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "chrome/browser/extensions/extension_process_manager.h" 8 #include "chrome/browser/extensions/extension_process_manager.h"
9 #include "chrome/browser/extensions/extension_system.h" 9 #include "chrome/browser/extensions/extension_system.h"
10 #include "chrome/browser/extensions/shell_window_geometry_cache.h" 10 #include "chrome/browser/extensions/shell_window_geometry_cache.h"
11 #include "chrome/browser/extensions/shell_window_registry.h" 11 #include "chrome/browser/extensions/shell_window_registry.h"
12 #include "chrome/browser/extensions/tab_helper.h" 12 #include "chrome/browser/extensions/tab_helper.h"
13 #include "chrome/browser/file_select_helper.h" 13 #include "chrome/browser/file_select_helper.h"
14 #include "chrome/browser/infobars/infobar_tab_helper.h"
15 #include "chrome/browser/intents/web_intents_util.h" 14 #include "chrome/browser/intents/web_intents_util.h"
16 #include "chrome/browser/lifetime/application_lifetime.h" 15 #include "chrome/browser/lifetime/application_lifetime.h"
17 #include "chrome/browser/profiles/profile.h" 16 #include "chrome/browser/profiles/profile.h"
18 #include "chrome/browser/sessions/session_id.h" 17 #include "chrome/browser/sessions/session_id.h"
19 #include "chrome/browser/ui/browser.h" 18 #include "chrome/browser/ui/browser.h"
20 #include "chrome/browser/ui/browser_finder.h" 19 #include "chrome/browser/ui/browser_finder.h"
21 #include "chrome/browser/ui/browser_tabstrip.h" 20 #include "chrome/browser/ui/browser_tabstrip.h"
22 #include "chrome/browser/ui/browser_window.h" 21 #include "chrome/browser/ui/browser_window.h"
22 #include "chrome/browser/ui/constrained_window_tab_helper.h"
23 #include "chrome/browser/ui/extensions/native_shell_window.h" 23 #include "chrome/browser/ui/extensions/native_shell_window.h"
24 #include "chrome/browser/ui/intents/web_intent_picker_controller.h" 24 #include "chrome/browser/ui/intents/web_intent_picker_controller.h"
25 #include "chrome/browser/ui/tab_contents/tab_contents.h" 25 #include "chrome/browser/ui/tab_contents/tab_contents.h"
26 #include "chrome/browser/view_type_utils.h" 26 #include "chrome/browser/view_type_utils.h"
27 #include "chrome/common/chrome_notification_types.h" 27 #include "chrome/common/chrome_notification_types.h"
28 #include "chrome/common/extensions/extension.h" 28 #include "chrome/common/extensions/extension.h"
29 #include "chrome/common/extensions/extension_messages.h" 29 #include "chrome/common/extensions/extension_messages.h"
30 #include "content/public/browser/browser_thread.h" 30 #include "content/public/browser/browser_thread.h"
31 #include "content/public/browser/invalidate_type.h" 31 #include "content/public/browser/invalidate_type.h"
32 #include "content/public/browser/navigation_entry.h" 32 #include "content/public/browser/navigation_entry.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 const extensions::Extension* extension) 91 const extensions::Extension* extension)
92 : profile_(profile), 92 : profile_(profile),
93 extension_(extension), 93 extension_(extension),
94 web_contents_(NULL), 94 web_contents_(NULL),
95 ALLOW_THIS_IN_INITIALIZER_LIST( 95 ALLOW_THIS_IN_INITIALIZER_LIST(
96 extension_function_dispatcher_(profile, this)) { 96 extension_function_dispatcher_(profile, this)) {
97 } 97 }
98 98
99 void ShellWindow::Init(const GURL& url, 99 void ShellWindow::Init(const GURL& url,
100 const ShellWindow::CreateParams& params) { 100 const ShellWindow::CreateParams& params) {
101 web_contents_ = WebContents::Create( 101 web_contents_.reset(WebContents::Create(
102 profile(), SiteInstance::CreateForURL(profile(), url), MSG_ROUTING_NONE, 102 profile(), SiteInstance::CreateForURL(profile(), url), MSG_ROUTING_NONE,
103 NULL); 103 NULL));
104 contents_.reset(TabContents::Factory::CreateTabContents(web_contents_)); 104 ConstrainedWindowTabHelper::CreateForWebContents(web_contents_.get());
105 content::WebContentsObserver::Observe(web_contents_); 105 WebIntentPickerController::CreateForWebContents(web_contents_.get());
106
107 content::WebContentsObserver::Observe(web_contents_.get());
106 web_contents_->SetDelegate(this); 108 web_contents_->SetDelegate(this);
107 chrome::SetViewType(web_contents_, chrome::VIEW_TYPE_APP_SHELL); 109 chrome::SetViewType(web_contents_.get(), chrome::VIEW_TYPE_APP_SHELL);
108 web_contents_->GetMutableRendererPrefs()-> 110 web_contents_->GetMutableRendererPrefs()->
109 browser_handles_all_top_level_requests = true; 111 browser_handles_all_top_level_requests = true;
110 web_contents_->GetRenderViewHost()->SyncRendererPrefs(); 112 web_contents_->GetRenderViewHost()->SyncRendererPrefs();
111 113
112 native_window_.reset(NativeShellWindow::Create(this, params)); 114 native_window_.reset(NativeShellWindow::Create(this, params));
113 115
114 if (!params.window_key.empty()) { 116 if (!params.window_key.empty()) {
115 window_key_ = params.window_key; 117 window_key_ = params.window_key;
116 118
117 if (params.restore_position || params.restore_size) { 119 if (params.restore_position || params.restore_size) {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 registrar_.RemoveAll(); 165 registrar_.RemoveAll();
164 166
165 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, 167 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED,
166 content::Source<Profile>(profile_)); 168 content::Source<Profile>(profile_));
167 // Close when the browser is exiting. 169 // Close when the browser is exiting.
168 // TODO(mihaip): we probably don't want this in the long run (when platform 170 // TODO(mihaip): we probably don't want this in the long run (when platform
169 // apps are no longer tied to the browser process). 171 // apps are no longer tied to the browser process).
170 registrar_.Add(this, chrome::NOTIFICATION_APP_TERMINATING, 172 registrar_.Add(this, chrome::NOTIFICATION_APP_TERMINATING,
171 content::NotificationService::AllSources()); 173 content::NotificationService::AllSources());
172 174
173 // Automatically dismiss all infobars.
174 InfoBarTabHelper* infobar_helper =
175 InfoBarTabHelper::FromWebContents(web_contents_);
176 infobar_helper->set_infobars_enabled(false);
benwells 2012/10/19 01:51:24 Will this re-enable infobars? Or does not having a
Avi (use Gerrit) 2012/10/19 01:59:01 Look at it this way. A TabContents just is a WebC
177
178 // Prevent the browser process from shutting down while this window is open. 175 // Prevent the browser process from shutting down while this window is open.
179 browser::StartKeepAlive(); 176 browser::StartKeepAlive();
180 177
181 UpdateExtensionAppIcon(); 178 UpdateExtensionAppIcon();
182 } 179 }
183 180
184 ShellWindow::~ShellWindow() { 181 ShellWindow::~ShellWindow() {
185 // Unregister now to prevent getting NOTIFICATION_APP_TERMINATING if we're the 182 // Unregister now to prevent getting NOTIFICATION_APP_TERMINATING if we're the
186 // last window open. 183 // last window open.
187 registrar_.RemoveAll(); 184 registrar_.RemoveAll();
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 return true; 359 return true;
363 } 360 }
364 361
365 void ShellWindow::WebIntentDispatch( 362 void ShellWindow::WebIntentDispatch(
366 content::WebContents* web_contents, 363 content::WebContents* web_contents,
367 content::WebIntentsDispatcher* intents_dispatcher) { 364 content::WebIntentsDispatcher* intents_dispatcher) {
368 if (!web_intents::IsWebIntentsEnabledForProfile(profile_)) 365 if (!web_intents::IsWebIntentsEnabledForProfile(profile_))
369 return; 366 return;
370 367
371 WebIntentPickerController* web_intent_picker_controller = 368 WebIntentPickerController* web_intent_picker_controller =
372 WebIntentPickerController::FromWebContents(contents_->web_contents()); 369 WebIntentPickerController::FromWebContents(web_contents_.get());
373 web_intent_picker_controller->SetIntentsDispatcher(intents_dispatcher); 370 web_intent_picker_controller->SetIntentsDispatcher(intents_dispatcher);
374 web_intent_picker_controller->ShowDialog( 371 web_intent_picker_controller->ShowDialog(
375 intents_dispatcher->GetIntent().action, 372 intents_dispatcher->GetIntent().action,
376 intents_dispatcher->GetIntent().type); 373 intents_dispatcher->GetIntent().type);
377 } 374 }
378 375
379 void ShellWindow::RunFileChooser(WebContents* tab, 376 void ShellWindow::RunFileChooser(WebContents* tab,
380 const content::FileChooserParams& params) { 377 const content::FileChooserParams& params) {
381 FileSelectHelper::RunFileChooser(tab, params); 378 FileSelectHelper::RunFileChooser(tab, params);
382 } 379 }
383 380
384 bool ShellWindow::IsPopupOrPanel(const WebContents* source) const { 381 bool ShellWindow::IsPopupOrPanel(const WebContents* source) const {
385 DCHECK(source == web_contents_); 382 DCHECK(source == web_contents_.get());
386 return true; 383 return true;
387 } 384 }
388 385
389 void ShellWindow::MoveContents(WebContents* source, const gfx::Rect& pos) { 386 void ShellWindow::MoveContents(WebContents* source, const gfx::Rect& pos) {
390 DCHECK(source == web_contents_); 387 DCHECK(source == web_contents_.get());
391 native_window_->SetBounds(pos); 388 native_window_->SetBounds(pos);
392 } 389 }
393 390
394 void ShellWindow::NavigationStateChanged( 391 void ShellWindow::NavigationStateChanged(
395 const content::WebContents* source, unsigned changed_flags) { 392 const content::WebContents* source, unsigned changed_flags) {
396 DCHECK(source == web_contents_); 393 DCHECK(source == web_contents_.get());
397 if (changed_flags & content::INVALIDATE_TYPE_TITLE) 394 if (changed_flags & content::INVALIDATE_TYPE_TITLE)
398 native_window_->UpdateWindowTitle(); 395 native_window_->UpdateWindowTitle();
399 else if (changed_flags & content::INVALIDATE_TYPE_TAB) 396 else if (changed_flags & content::INVALIDATE_TYPE_TAB)
400 native_window_->UpdateWindowIcon(); 397 native_window_->UpdateWindowIcon();
401 } 398 }
402 399
403 void ShellWindow::ToggleFullscreenModeForTab(content::WebContents* source, 400 void ShellWindow::ToggleFullscreenModeForTab(content::WebContents* source,
404 bool enter_fullscreen) { 401 bool enter_fullscreen) {
405 DCHECK(source == web_contents_); 402 DCHECK(source == web_contents_.get());
406 native_window_->SetFullscreen(enter_fullscreen); 403 native_window_->SetFullscreen(enter_fullscreen);
407 } 404 }
408 405
409 bool ShellWindow::IsFullscreenForTabOrPending( 406 bool ShellWindow::IsFullscreenForTabOrPending(
410 const content::WebContents* source) const { 407 const content::WebContents* source) const {
411 DCHECK(source == web_contents_); 408 DCHECK(source == web_contents_.get());
412 return native_window_->IsFullscreenOrPending(); 409 return native_window_->IsFullscreenOrPending();
413 } 410 }
414 411
415 void ShellWindow::Observe(int type, 412 void ShellWindow::Observe(int type,
416 const content::NotificationSource& source, 413 const content::NotificationSource& source,
417 const content::NotificationDetails& details) { 414 const content::NotificationDetails& details) {
418 switch (type) { 415 switch (type) {
419 case content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED: { 416 case content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED: {
420 // TODO(jeremya): once http://crbug.com/123007 is fixed, we'll no longer 417 // TODO(jeremya): once http://crbug.com/123007 is fixed, we'll no longer
421 // need to suspend resource requests here (the call in the constructor 418 // need to suspend resource requests here (the call in the constructor
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 const extensions::DraggableRegion& region = *iter; 485 const extensions::DraggableRegion& region = *iter;
489 sk_region->op( 486 sk_region->op(
490 region.bounds.x(), 487 region.bounds.x(),
491 region.bounds.y(), 488 region.bounds.y(),
492 region.bounds.right(), 489 region.bounds.right(),
493 region.bounds.bottom(), 490 region.bounds.bottom(),
494 region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op); 491 region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op);
495 } 492 }
496 return sk_region; 493 return sk_region;
497 } 494 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/extensions/shell_window.h ('k') | chrome/browser/ui/tab_contents/tab_contents.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698