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

Side by Side Diff: mandoline/ui/desktop_ui/browser_window.cc

Issue 1351013002: Revert of Mandoline UI Process: Update namespaces and file names (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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
« no previous file with comments | « mandoline/ui/desktop_ui/browser_window.h ('k') | mandoline/ui/omnibox/omnibox_application.cc » ('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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "mandoline/ui/desktop_ui/browser_window.h" 5 #include "mandoline/ui/desktop_ui/browser_window.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/strings/string16.h" 8 #include "base/strings/string16.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 host_client_binding_(this), 73 host_client_binding_(this),
74 manager_(manager), 74 manager_(manager),
75 toolbar_view_(nullptr), 75 toolbar_view_(nullptr),
76 progress_bar_(nullptr), 76 progress_bar_(nullptr),
77 root_(nullptr), 77 root_(nullptr),
78 content_(nullptr), 78 content_(nullptr),
79 omnibox_view_(nullptr), 79 omnibox_view_(nullptr),
80 web_view_(this) { 80 web_view_(this) {
81 mojo::ViewTreeHostClientPtr host_client; 81 mojo::ViewTreeHostClientPtr host_client;
82 host_client_binding_.Bind(GetProxy(&host_client)); 82 host_client_binding_.Bind(GetProxy(&host_client));
83 mus::CreateViewTreeHost(host_factory, host_client.Pass(), this, &host_); 83 mojo::CreateViewTreeHost(host_factory, host_client.Pass(), this, &host_);
84 } 84 }
85 85
86 void BrowserWindow::LoadURL(const GURL& url) { 86 void BrowserWindow::LoadURL(const GURL& url) {
87 // Haven't been embedded yet, can't embed. 87 // Haven't been embedded yet, can't embed.
88 // TODO(beng): remove this. 88 // TODO(beng): remove this.
89 if (!root_) { 89 if (!root_) {
90 default_url_ = url; 90 default_url_ = url;
91 return; 91 return;
92 } 92 }
93 93
94 if (!url.is_valid()) { 94 if (!url.is_valid()) {
95 ShowOmnibox(); 95 ShowOmnibox();
96 return; 96 return;
97 } 97 }
98 98
99 mojo::URLRequestPtr request(mojo::URLRequest::New()); 99 mojo::URLRequestPtr request(mojo::URLRequest::New());
100 request->url = url.spec(); 100 request->url = url.spec();
101 Embed(request.Pass()); 101 Embed(request.Pass());
102 } 102 }
103 103
104 void BrowserWindow::Close() { 104 void BrowserWindow::Close() {
105 if (root_) 105 if (root_)
106 mus::ScopedViewPtr::DeleteViewOrViewManager(root_); 106 mojo::ScopedViewPtr::DeleteViewOrViewManager(root_);
107 else 107 else
108 delete this; 108 delete this;
109 } 109 }
110 110
111 void BrowserWindow::ShowOmnibox() { 111 void BrowserWindow::ShowOmnibox() {
112 if (!omnibox_.get()) { 112 if (!omnibox_.get()) {
113 mojo::URLRequestPtr request(mojo::URLRequest::New()); 113 mojo::URLRequestPtr request(mojo::URLRequest::New());
114 request->url = mojo::String::From("mojo:omnibox"); 114 request->url = mojo::String::From("mojo:omnibox");
115 omnibox_connection_ = app_->ConnectToApplication(request.Pass()); 115 omnibox_connection_ = app_->ConnectToApplication(request.Pass());
116 omnibox_connection_->AddService<ViewEmbedder>(this); 116 omnibox_connection_->AddService<ViewEmbedder>(this);
(...skipping 19 matching lines...) Expand all
136 BrowserWindow::~BrowserWindow() { 136 BrowserWindow::~BrowserWindow() {
137 DCHECK(!root_); 137 DCHECK(!root_);
138 manager_->BrowserWindowClosed(this); 138 manager_->BrowserWindowClosed(this);
139 } 139 }
140 140
141 float BrowserWindow::DIPSToPixels(float value) const { 141 float BrowserWindow::DIPSToPixels(float value) const {
142 return value * root_->viewport_metrics().device_pixel_ratio; 142 return value * root_->viewport_metrics().device_pixel_ratio;
143 } 143 }
144 144
145 //////////////////////////////////////////////////////////////////////////////// 145 ////////////////////////////////////////////////////////////////////////////////
146 // BrowserWindow, mus::ViewTreeDelegate implementation: 146 // BrowserWindow, mojo::ViewTreeDelegate implementation:
147 147
148 void BrowserWindow::OnEmbed(mus::View* root) { 148 void BrowserWindow::OnEmbed(mojo::View* root) {
149 // BrowserWindow does not support being embedded more than once. 149 // BrowserWindow does not support being embedded more than once.
150 CHECK(!root_); 150 CHECK(!root_);
151 151
152 // Record when the browser window was displayed, used for performance testing. 152 // Record when the browser window was displayed, used for performance testing.
153 const base::Time display_time = base::Time::Now(); 153 const base::Time display_time = base::Time::Now();
154 154
155 root_ = root; 155 root_ = root;
156 156
157 host_->SetTitle("Mandoline"); 157 host_->SetTitle("Mandoline");
158 158
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 tracing::StartupPerformanceDataCollectorPtr collector; 193 tracing::StartupPerformanceDataCollectorPtr collector;
194 app_->ConnectToService(request.Pass(), &collector); 194 app_->ConnectToService(request.Pass(), &collector);
195 collector->SetBrowserWindowDisplayTime(display_time.ToInternalValue()); 195 collector->SetBrowserWindowDisplayTime(display_time.ToInternalValue());
196 collector->SetBrowserOpenTabsTimeDelta(open_tabs_delta.ToInternalValue()); 196 collector->SetBrowserOpenTabsTimeDelta(open_tabs_delta.ToInternalValue());
197 collector->SetBrowserMessageLoopStartTime( 197 collector->SetBrowserMessageLoopStartTime(
198 manager_->startup_time().ToInternalValue()); 198 manager_->startup_time().ToInternalValue());
199 recorded_browser_startup_metrics = true; 199 recorded_browser_startup_metrics = true;
200 } 200 }
201 } 201 }
202 202
203 void BrowserWindow::OnConnectionLost(mus::ViewTreeConnection* connection) { 203 void BrowserWindow::OnConnectionLost(mojo::ViewTreeConnection* connection) {
204 root_ = nullptr; 204 root_ = nullptr;
205 delete this; 205 delete this;
206 } 206 }
207 207
208 //////////////////////////////////////////////////////////////////////////////// 208 ////////////////////////////////////////////////////////////////////////////////
209 // BrowserWindow, mus::ViewTreeHostClient implementation: 209 // BrowserWindow, mojo::ViewTreeHostClient implementation:
210 210
211 void BrowserWindow::OnAccelerator(uint32_t id, mojo::EventPtr event) { 211 void BrowserWindow::OnAccelerator(uint32_t id, mojo::EventPtr event) {
212 switch (static_cast<BrowserCommand>(id)) { 212 switch (static_cast<BrowserCommand>(id)) {
213 case BrowserCommand::CLOSE: 213 case BrowserCommand::CLOSE:
214 Close(); 214 Close();
215 break; 215 break;
216 case BrowserCommand::NEW_WINDOW: 216 case BrowserCommand::NEW_WINDOW:
217 manager_->CreateBrowser(GURL()); 217 manager_->CreateBrowser(GURL());
218 break; 218 break;
219 case BrowserCommand::FOCUS_OMNIBOX: 219 case BrowserCommand::FOCUS_OMNIBOX:
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 321
322 // The omnibox view bounds are in physical pixels. 322 // The omnibox view bounds are in physical pixels.
323 omnibox_view_->SetBounds( 323 omnibox_view_->SetBounds(
324 mojo::TypeConverter<mojo::Rect, gfx::Rect>::Convert( 324 mojo::TypeConverter<mojo::Rect, gfx::Rect>::Convert(
325 bounds_in_physical_pixels)); 325 bounds_in_physical_pixels));
326 } 326 }
327 327
328 //////////////////////////////////////////////////////////////////////////////// 328 ////////////////////////////////////////////////////////////////////////////////
329 // BrowserWindow, private: 329 // BrowserWindow, private:
330 330
331 void BrowserWindow::Init(mus::View* root) { 331 void BrowserWindow::Init(mojo::View* root) {
332 DCHECK_GT(root->viewport_metrics().device_pixel_ratio, 0); 332 DCHECK_GT(root->viewport_metrics().device_pixel_ratio, 0);
333 if (!aura_init_) 333 if (!aura_init_)
334 aura_init_.reset(new AuraInit(root, app_->shell())); 334 aura_init_.reset(new AuraInit(root, app_->shell()));
335 335
336 root_ = root; 336 root_ = root;
337 omnibox_view_ = root_->connection()->CreateView(); 337 omnibox_view_ = root_->connection()->CreateView();
338 root_->AddChild(omnibox_view_); 338 root_->AddChild(omnibox_view_);
339 339
340 views::WidgetDelegateView* widget_delegate = new views::WidgetDelegateView; 340 views::WidgetDelegateView* widget_delegate = new views::WidgetDelegateView;
341 widget_delegate->GetContentsView()->set_background( 341 widget_delegate->GetContentsView()->set_background(
(...skipping 22 matching lines...) Expand all
364 omnibox_view_->Embed(view_tree_client.Pass()); 364 omnibox_view_->Embed(view_tree_client.Pass());
365 365
366 // TODO(beng): This should be handled sufficiently by 366 // TODO(beng): This should be handled sufficiently by
367 // OmniboxImpl::ShowWindow() but unfortunately view manager policy 367 // OmniboxImpl::ShowWindow() but unfortunately view manager policy
368 // currently prevents the embedded app from changing window z for 368 // currently prevents the embedded app from changing window z for
369 // its own window. 369 // its own window.
370 omnibox_view_->MoveToFront(); 370 omnibox_view_->MoveToFront();
371 } 371 }
372 372
373 } // namespace mandoline 373 } // namespace mandoline
OLDNEW
« no previous file with comments | « mandoline/ui/desktop_ui/browser_window.h ('k') | mandoline/ui/omnibox/omnibox_application.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698