| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "services/navigation/view_impl.h" | 5 #include "services/navigation/view_impl.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "content/public/browser/browser_context.h" | 9 #include "content/public/browser/browser_context.h" |
| 10 #include "content/public/browser/interstitial_page.h" | 10 #include "content/public/browser/interstitial_page.h" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 } // namespace | 59 } // namespace |
| 60 | 60 |
| 61 ViewImpl::ViewImpl(std::unique_ptr<shell::Connector> connector, | 61 ViewImpl::ViewImpl(std::unique_ptr<shell::Connector> connector, |
| 62 const std::string& client_user_id, | 62 const std::string& client_user_id, |
| 63 mojom::ViewClientPtr client, | 63 mojom::ViewClientPtr client, |
| 64 std::unique_ptr<shell::ServiceContextRef> ref) | 64 std::unique_ptr<shell::ServiceContextRef> ref) |
| 65 : connector_(std::move(connector)), | 65 : connector_(std::move(connector)), |
| 66 client_(std::move(client)), | 66 client_(std::move(client)), |
| 67 ref_(std::move(ref)), | 67 ref_(std::move(ref)), |
| 68 web_view_(new views::WebView( | 68 web_view_(new views::WebView( |
| 69 content::BrowserContext::GetBrowserContextForShellUserId( | 69 content::BrowserContext::GetBrowserContextForServiceUserId( |
| 70 client_user_id))) { | 70 client_user_id))) { |
| 71 web_view_->GetWebContents()->SetDelegate(this); | 71 web_view_->GetWebContents()->SetDelegate(this); |
| 72 const content::NavigationController* controller = | 72 const content::NavigationController* controller = |
| 73 &web_view_->GetWebContents()->GetController(); | 73 &web_view_->GetWebContents()->GetController(); |
| 74 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_PENDING, | 74 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_PENDING, |
| 75 content::Source<content::NavigationController>(controller)); | 75 content::Source<content::NavigationController>(controller)); |
| 76 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, | 76 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, |
| 77 content::Source<content::NavigationController>(controller)); | 77 content::Source<content::NavigationController>(controller)); |
| 78 registrar_.Add(this, content::NOTIFICATION_NAV_LIST_PRUNED, | 78 registrar_.Add(this, content::NOTIFICATION_NAV_LIST_PRUNED, |
| 79 content::Source<content::NavigationController>(controller)); | 79 content::Source<content::NavigationController>(controller)); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 bool user_gesture, | 141 bool user_gesture, |
| 142 bool* was_blocked) { | 142 bool* was_blocked) { |
| 143 mojom::ViewClientPtr client; | 143 mojom::ViewClientPtr client; |
| 144 mojom::ViewPtr view; | 144 mojom::ViewPtr view; |
| 145 mojom::ViewRequest view_request = GetProxy(&view); | 145 mojom::ViewRequest view_request = GetProxy(&view); |
| 146 client_->ViewCreated(std::move(view), GetProxy(&client), | 146 client_->ViewCreated(std::move(view), GetProxy(&client), |
| 147 disposition == WindowOpenDisposition::NEW_POPUP, | 147 disposition == WindowOpenDisposition::NEW_POPUP, |
| 148 initial_rect, user_gesture); | 148 initial_rect, user_gesture); |
| 149 | 149 |
| 150 const std::string new_user_id = | 150 const std::string new_user_id = |
| 151 content::BrowserContext::GetShellUserIdFor( | 151 content::BrowserContext::GetServiceUserIdFor( |
| 152 new_contents->GetBrowserContext()); | 152 new_contents->GetBrowserContext()); |
| 153 auto impl = base::MakeUnique<ViewImpl>(connector_->Clone(), new_user_id, | 153 auto impl = base::MakeUnique<ViewImpl>(connector_->Clone(), new_user_id, |
| 154 std::move(client), ref_->Clone()); | 154 std::move(client), ref_->Clone()); |
| 155 | 155 |
| 156 // TODO(beng): This is a bit crappy. should be able to create the ViewImpl | 156 // TODO(beng): This is a bit crappy. should be able to create the ViewImpl |
| 157 // with |new_contents| instead. | 157 // with |new_contents| instead. |
| 158 impl->web_view_->SetWebContents(new_contents); | 158 impl->web_view_->SetWebContents(new_contents); |
| 159 impl->web_view_->GetWebContents()->SetDelegate(impl.get()); | 159 impl->web_view_->GetWebContents()->SetDelegate(impl.get()); |
| 160 | 160 |
| 161 // TODO(beng): this reply is currently synchronous, figure out a fix. | 161 // TODO(beng): this reply is currently synchronous, figure out a fix. |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 | 299 |
| 300 views::Widget* ViewImpl::GetWidget() { | 300 views::Widget* ViewImpl::GetWidget() { |
| 301 return web_view_->GetWidget(); | 301 return web_view_->GetWidget(); |
| 302 } | 302 } |
| 303 | 303 |
| 304 const views::Widget* ViewImpl::GetWidget() const { | 304 const views::Widget* ViewImpl::GetWidget() const { |
| 305 return web_view_->GetWidget(); | 305 return web_view_->GetWidget(); |
| 306 } | 306 } |
| 307 | 307 |
| 308 } // navigation | 308 } // navigation |
| OLD | NEW |