OLD | NEW |
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 "athena/content/web_activity.h" | 5 #include "athena/content/web_activity.h" |
6 | 6 |
7 #include "athena/activity/public/activity_factory.h" | 7 #include "athena/activity/public/activity_factory.h" |
8 #include "athena/activity/public/activity_manager.h" | 8 #include "athena/activity/public/activity_manager.h" |
9 #include "athena/input/public/accelerator_manager.h" | 9 #include "athena/input/public/accelerator_manager.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 load_url_params.transferred_global_request_id = | 215 load_url_params.transferred_global_request_id = |
216 params.transferred_global_request_id; | 216 params.transferred_global_request_id; |
217 web_contents()->GetController().LoadURLWithParams(load_url_params); | 217 web_contents()->GetController().LoadURLWithParams(load_url_params); |
218 return web_contents(); | 218 return web_contents(); |
219 } | 219 } |
220 case NEW_FOREGROUND_TAB: | 220 case NEW_FOREGROUND_TAB: |
221 case NEW_BACKGROUND_TAB: | 221 case NEW_BACKGROUND_TAB: |
222 case NEW_POPUP: | 222 case NEW_POPUP: |
223 case NEW_WINDOW: { | 223 case NEW_WINDOW: { |
224 ActivityManager::Get()->AddActivity( | 224 ActivityManager::Get()->AddActivity( |
225 ActivityFactory::Get()->CreateWebActivity(browser_context(), | 225 ActivityFactory::Get()->CreateWebActivity( |
226 params.url)); | 226 browser_context(), base::string16(), params.url)); |
227 break; | 227 break; |
228 } | 228 } |
229 default: | 229 default: |
230 break; | 230 break; |
231 } | 231 } |
232 // NULL is returned if the URL wasn't opened immediately. | 232 // NULL is returned if the URL wasn't opened immediately. |
233 return NULL; | 233 return NULL; |
234 } | 234 } |
235 | 235 |
236 virtual bool CanOverscrollContent() const OVERRIDE { | 236 virtual bool CanOverscrollContent() const OVERRIDE { |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 scoped_ptr<ui::Layer> progress_bar_; | 318 scoped_ptr<ui::Layer> progress_bar_; |
319 | 319 |
320 // TODO(oshima): Find out if we should support window fullscreen. | 320 // TODO(oshima): Find out if we should support window fullscreen. |
321 // It may still useful when a user is in split mode. | 321 // It may still useful when a user is in split mode. |
322 bool fullscreen_; | 322 bool fullscreen_; |
323 | 323 |
324 DISALLOW_COPY_AND_ASSIGN(AthenaWebView); | 324 DISALLOW_COPY_AND_ASSIGN(AthenaWebView); |
325 }; | 325 }; |
326 | 326 |
327 WebActivity::WebActivity(content::BrowserContext* browser_context, | 327 WebActivity::WebActivity(content::BrowserContext* browser_context, |
| 328 const base::string16& title, |
328 const GURL& url) | 329 const GURL& url) |
329 : browser_context_(browser_context), | 330 : browser_context_(browser_context), |
| 331 title_(title), |
330 url_(url), | 332 url_(url), |
331 web_view_(NULL), | 333 web_view_(NULL), |
332 title_color_(kDefaultTitleColor), | 334 title_color_(kDefaultTitleColor), |
333 current_state_(ACTIVITY_UNLOADED) { | 335 current_state_(ACTIVITY_UNLOADED) { |
334 } | 336 } |
335 | 337 |
336 WebActivity::WebActivity(AthenaWebView* web_view) | 338 WebActivity::WebActivity(AthenaWebView* web_view) |
337 : browser_context_(web_view->browser_context()), | 339 : browser_context_(web_view->browser_context()), |
338 url_(web_view->GetWebContents()->GetURL()), | 340 url_(web_view->GetWebContents()->GetURL()), |
339 web_view_(web_view), | 341 web_view_(web_view), |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 DCHECK(web_view_); | 425 DCHECK(web_view_); |
424 web_view_->InstallAccelerators(); | 426 web_view_->InstallAccelerators(); |
425 } | 427 } |
426 | 428 |
427 SkColor WebActivity::GetRepresentativeColor() const { | 429 SkColor WebActivity::GetRepresentativeColor() const { |
428 // TODO(sad): Compute the color from the favicon. | 430 // TODO(sad): Compute the color from the favicon. |
429 return web_view_ ? title_color_ : kDefaultUnavailableColor; | 431 return web_view_ ? title_color_ : kDefaultUnavailableColor; |
430 } | 432 } |
431 | 433 |
432 base::string16 WebActivity::GetTitle() const { | 434 base::string16 WebActivity::GetTitle() const { |
| 435 if (!title_.empty()) |
| 436 return title_; |
433 return web_view_ ? base::UTF8ToUTF16( | 437 return web_view_ ? base::UTF8ToUTF16( |
434 web_view_->GetWebContents()->GetVisibleURL().host()) | 438 web_view_->GetWebContents()->GetVisibleURL().host()) |
435 : base::string16(); | 439 : base::string16(); |
436 } | 440 } |
437 | 441 |
438 bool WebActivity::UsesFrame() const { | 442 bool WebActivity::UsesFrame() const { |
439 return true; | 443 return true; |
440 } | 444 } |
441 | 445 |
442 views::View* WebActivity::GetContentsView() { | 446 views::View* WebActivity::GetContentsView() { |
(...skipping 23 matching lines...) Expand all Loading... |
466 void WebActivity::DidUpdateFaviconURL( | 470 void WebActivity::DidUpdateFaviconURL( |
467 const std::vector<content::FaviconURL>& candidates) { | 471 const std::vector<content::FaviconURL>& candidates) { |
468 ActivityManager::Get()->UpdateActivity(this); | 472 ActivityManager::Get()->UpdateActivity(this); |
469 } | 473 } |
470 | 474 |
471 void WebActivity::DidChangeThemeColor(SkColor theme_color) { | 475 void WebActivity::DidChangeThemeColor(SkColor theme_color) { |
472 title_color_ = theme_color; | 476 title_color_ = theme_color; |
473 } | 477 } |
474 | 478 |
475 } // namespace athena | 479 } // namespace athena |
OLD | NEW |