OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/external_tab_container.h" | 5 #include "chrome/browser/external_tab_container.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "app/win_util.h" | 9 #include "app/win_util.h" |
10 #include "base/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 tab_contents_(NULL), | 47 tab_contents_(NULL), |
48 tab_contents_container_(NULL), | 48 tab_contents_container_(NULL), |
49 tab_handle_(0), | 49 tab_handle_(0), |
50 ignore_next_load_notification_(false), | 50 ignore_next_load_notification_(false), |
51 automation_resource_message_filter_(filter), | 51 automation_resource_message_filter_(filter), |
52 load_requests_via_automation_(false), | 52 load_requests_via_automation_(false), |
53 handle_top_level_requests_(false), | 53 handle_top_level_requests_(false), |
54 external_method_factory_(this), | 54 external_method_factory_(this), |
55 enabled_extension_automation_(false), | 55 enabled_extension_automation_(false), |
56 waiting_for_unload_event_(false), | 56 waiting_for_unload_event_(false), |
57 pending_(false) { | 57 pending_(false), |
| 58 infobars_enabled_(true) { |
58 } | 59 } |
59 | 60 |
60 ExternalTabContainer::~ExternalTabContainer() { | 61 ExternalTabContainer::~ExternalTabContainer() { |
61 Uninitialize(); | 62 Uninitialize(); |
62 } | 63 } |
63 | 64 |
64 bool ExternalTabContainer::Init(Profile* profile, | 65 bool ExternalTabContainer::Init(Profile* profile, |
65 HWND parent, | 66 HWND parent, |
66 const gfx::Rect& bounds, | 67 const gfx::Rect& bounds, |
67 DWORD style, | 68 DWORD style, |
68 bool load_requests_via_automation, | 69 bool load_requests_via_automation, |
69 bool handle_top_level_requests, | 70 bool handle_top_level_requests, |
70 TabContents* existing_contents, | 71 TabContents* existing_contents, |
71 const GURL& initial_url, | 72 const GURL& initial_url, |
72 const GURL& referrer) { | 73 const GURL& referrer, |
| 74 bool infobars_enabled) { |
73 if (IsWindow()) { | 75 if (IsWindow()) { |
74 NOTREACHED(); | 76 NOTREACHED(); |
75 return false; | 77 return false; |
76 } | 78 } |
77 | 79 |
78 load_requests_via_automation_ = load_requests_via_automation; | 80 load_requests_via_automation_ = load_requests_via_automation; |
79 handle_top_level_requests_ = handle_top_level_requests; | 81 handle_top_level_requests_ = handle_top_level_requests; |
| 82 infobars_enabled_ = infobars_enabled; |
80 | 83 |
81 set_window_style(WS_POPUP | WS_CLIPCHILDREN); | 84 set_window_style(WS_POPUP | WS_CLIPCHILDREN); |
82 views::WidgetWin::Init(NULL, bounds); | 85 views::WidgetWin::Init(NULL, bounds); |
83 if (!IsWindow()) { | 86 if (!IsWindow()) { |
84 NOTREACHED(); | 87 NOTREACHED(); |
85 return false; | 88 return false; |
86 } | 89 } |
87 | 90 |
88 // TODO(jcampan): limit focus traversal to contents. | 91 // TODO(jcampan): limit focus traversal to contents. |
89 | 92 |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 // an unwrapped Profile. | 347 // an unwrapped Profile. |
345 bool result = new_container->Init( | 348 bool result = new_container->Init( |
346 new_contents->profile()->GetOriginalProfile(), | 349 new_contents->profile()->GetOriginalProfile(), |
347 NULL, | 350 NULL, |
348 initial_pos, | 351 initial_pos, |
349 WS_CHILD, | 352 WS_CHILD, |
350 load_requests_via_automation_, | 353 load_requests_via_automation_, |
351 handle_top_level_requests_, | 354 handle_top_level_requests_, |
352 new_contents, | 355 new_contents, |
353 GURL(), | 356 GURL(), |
354 GURL()); | 357 GURL(), |
| 358 true); |
355 | 359 |
356 if (result) { | 360 if (result) { |
357 uintptr_t cookie = reinterpret_cast<uintptr_t>(new_container.get()); | 361 uintptr_t cookie = reinterpret_cast<uintptr_t>(new_container.get()); |
358 pending_tabs_[cookie] = new_container; | 362 pending_tabs_[cookie] = new_container; |
359 new_container->set_pending(true); | 363 new_container->set_pending(true); |
360 IPC::AttachExternalTabParams attach_params_; | 364 IPC::AttachExternalTabParams attach_params_; |
361 attach_params_.cookie = static_cast<uint64>(cookie); | 365 attach_params_.cookie = static_cast<uint64>(cookie); |
362 attach_params_.dimensions = initial_pos; | 366 attach_params_.dimensions = initial_pos; |
363 attach_params_.user_gesture = user_gesture; | 367 attach_params_.user_gesture = user_gesture; |
364 attach_params_.disposition = disposition; | 368 attach_params_.disposition = disposition; |
365 automation_->Send(new AutomationMsg_AttachExternalTab(0, | 369 automation_->Send(new AutomationMsg_AttachExternalTab(0, |
366 tab_handle_, attach_params_)); | 370 tab_handle_, attach_params_)); |
367 } else { | 371 } else { |
368 NOTREACHED(); | 372 NOTREACHED(); |
369 } | 373 } |
370 } | 374 } |
371 | 375 |
372 void ExternalTabContainer::TabContentsCreated(TabContents* new_contents) { | 376 void ExternalTabContainer::TabContentsCreated(TabContents* new_contents) { |
373 RenderViewHost* rvh = new_contents->render_view_host(); | 377 RenderViewHost* rvh = new_contents->render_view_host(); |
374 DCHECK(rvh != NULL); | 378 DCHECK(rvh != NULL); |
375 | 379 |
376 // Register this render view as a pending render view, i.e. any network | 380 // Register this render view as a pending render view, i.e. any network |
377 // requests initiated by this render view would be serviced when the | 381 // requests initiated by this render view would be serviced when the |
378 // external host connects to the new external tab instance. | 382 // external host connects to the new external tab instance. |
379 RegisterRenderViewHostForAutomation(rvh, true); | 383 RegisterRenderViewHostForAutomation(rvh, true); |
380 } | 384 } |
381 | 385 |
| 386 bool ExternalTabContainer::infobars_enabled() { |
| 387 return infobars_enabled_; |
| 388 } |
| 389 |
382 void ExternalTabContainer::ActivateContents(TabContents* contents) { | 390 void ExternalTabContainer::ActivateContents(TabContents* contents) { |
383 } | 391 } |
384 | 392 |
385 void ExternalTabContainer::LoadingStateChanged(TabContents* source) { | 393 void ExternalTabContainer::LoadingStateChanged(TabContents* source) { |
386 } | 394 } |
387 | 395 |
388 void ExternalTabContainer::CloseContents(TabContents* source) { | 396 void ExternalTabContainer::CloseContents(TabContents* source) { |
389 static const int kExternalTabCloseContentsDelayMS = 100; | 397 static const int kExternalTabCloseContentsDelayMS = 100; |
390 | 398 |
391 if (waiting_for_unload_event_) { | 399 if (waiting_for_unload_event_) { |
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
950 | 958 |
951 layout->StartRow(0, 0); | 959 layout->StartRow(0, 0); |
952 layout->AddView(info_bar_container); | 960 layout->AddView(info_bar_container); |
953 layout->StartRow(1, 0); | 961 layout->StartRow(1, 0); |
954 layout->AddView(tab_contents_container_); | 962 layout->AddView(tab_contents_container_); |
955 SetContentsView(external_tab_view); | 963 SetContentsView(external_tab_view); |
956 // Note that SetTabContents must be called after AddChildView is called | 964 // Note that SetTabContents must be called after AddChildView is called |
957 tab_contents_container_->ChangeTabContents(tab_contents_); | 965 tab_contents_container_->ChangeTabContents(tab_contents_); |
958 } | 966 } |
959 | 967 |
OLD | NEW |