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 "content/public/browser/native_web_keyboard_event.h" | 10 #include "content/public/browser/native_web_keyboard_event.h" |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 } | 113 } |
114 | 114 |
115 views::WebView* web_view_; | 115 views::WebView* web_view_; |
116 bool reserved_accelerator_enabled_; | 116 bool reserved_accelerator_enabled_; |
117 scoped_ptr<AcceleratorManager> accelerator_manager_; | 117 scoped_ptr<AcceleratorManager> accelerator_manager_; |
118 views::UnhandledKeyboardEventHandler unhandled_keyboard_event_handler_; | 118 views::UnhandledKeyboardEventHandler unhandled_keyboard_event_handler_; |
119 | 119 |
120 DISALLOW_COPY_AND_ASSIGN(WebActivityController); | 120 DISALLOW_COPY_AND_ASSIGN(WebActivityController); |
121 }; | 121 }; |
122 | 122 |
| 123 const SkColor kDefaultTitleColor = SK_ColorGRAY; |
| 124 const SkColor kDefaultUnavailableColor = SkColorSetRGB(0xbb, 0x77, 0x77); |
| 125 |
123 } // namespace | 126 } // namespace |
124 | 127 |
125 // A web view for athena's web activity. Note that AthenaWebView will create its | 128 // A web view for athena's web activity. Note that AthenaWebView will create its |
126 // own content so that it can eject and reload it. | 129 // own content so that it can eject and reload it. |
127 class AthenaWebView : public views::WebView { | 130 class AthenaWebView : public views::WebView { |
128 public: | 131 public: |
129 AthenaWebView(content::BrowserContext* context) | 132 AthenaWebView(content::BrowserContext* context) |
130 : views::WebView(context), controller_(new WebActivityController(this)), | 133 : views::WebView(context), controller_(new WebActivityController(this)), |
131 fullscreen_(false) { | 134 fullscreen_(false) { |
132 SetEmbedFullscreenWidgetMode(true); | 135 SetEmbedFullscreenWidgetMode(true); |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 bool fullscreen_; | 257 bool fullscreen_; |
255 | 258 |
256 DISALLOW_COPY_AND_ASSIGN(AthenaWebView); | 259 DISALLOW_COPY_AND_ASSIGN(AthenaWebView); |
257 }; | 260 }; |
258 | 261 |
259 WebActivity::WebActivity(content::BrowserContext* browser_context, | 262 WebActivity::WebActivity(content::BrowserContext* browser_context, |
260 const GURL& url) | 263 const GURL& url) |
261 : browser_context_(browser_context), | 264 : browser_context_(browser_context), |
262 url_(url), | 265 url_(url), |
263 web_view_(NULL), | 266 web_view_(NULL), |
| 267 title_color_(kDefaultTitleColor), |
264 current_state_(ACTIVITY_UNLOADED) { | 268 current_state_(ACTIVITY_UNLOADED) { |
265 } | 269 } |
266 | 270 |
267 WebActivity::WebActivity(AthenaWebView* web_view) | 271 WebActivity::WebActivity(AthenaWebView* web_view) |
268 : browser_context_(web_view->browser_context()), | 272 : browser_context_(web_view->browser_context()), |
269 url_(web_view->GetWebContents()->GetURL()), | 273 url_(web_view->GetWebContents()->GetURL()), |
270 web_view_(web_view), | 274 web_view_(web_view), |
271 current_state_(ACTIVITY_UNLOADED) { | 275 current_state_(ACTIVITY_UNLOADED) { |
272 // Transition to state ACTIVITY_INVISIBLE to perform the same setup steps | 276 // Transition to state ACTIVITY_INVISIBLE to perform the same setup steps |
273 // as on new activities (namely adding a WebContentsObserver). | 277 // as on new activities (namely adding a WebContentsObserver). |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 return Activity::ACTIVITY_MEDIA_STATE_NONE; | 346 return Activity::ACTIVITY_MEDIA_STATE_NONE; |
343 } | 347 } |
344 | 348 |
345 void WebActivity::Init() { | 349 void WebActivity::Init() { |
346 DCHECK(web_view_); | 350 DCHECK(web_view_); |
347 web_view_->InstallAccelerators(); | 351 web_view_->InstallAccelerators(); |
348 } | 352 } |
349 | 353 |
350 SkColor WebActivity::GetRepresentativeColor() const { | 354 SkColor WebActivity::GetRepresentativeColor() const { |
351 // TODO(sad): Compute the color from the favicon. | 355 // TODO(sad): Compute the color from the favicon. |
352 return web_view_ ? SK_ColorGRAY : SkColorSetRGB(0xbb, 0x77, 0x77); | 356 return web_view_ ? title_color_ : kDefaultUnavailableColor; |
353 } | 357 } |
354 | 358 |
355 base::string16 WebActivity::GetTitle() const { | 359 base::string16 WebActivity::GetTitle() const { |
356 return web_view_ ? web_view_->GetWebContents()->GetTitle() : base::string16(); | 360 return web_view_ ? web_view_->GetWebContents()->GetTitle() : base::string16(); |
357 } | 361 } |
358 | 362 |
359 bool WebActivity::UsesFrame() const { | 363 bool WebActivity::UsesFrame() const { |
360 return true; | 364 return true; |
361 } | 365 } |
362 | 366 |
(...skipping 19 matching lines...) Expand all Loading... |
382 void WebActivity::TitleWasSet(content::NavigationEntry* entry, | 386 void WebActivity::TitleWasSet(content::NavigationEntry* entry, |
383 bool explicit_set) { | 387 bool explicit_set) { |
384 ActivityManager::Get()->UpdateActivity(this); | 388 ActivityManager::Get()->UpdateActivity(this); |
385 } | 389 } |
386 | 390 |
387 void WebActivity::DidUpdateFaviconURL( | 391 void WebActivity::DidUpdateFaviconURL( |
388 const std::vector<content::FaviconURL>& candidates) { | 392 const std::vector<content::FaviconURL>& candidates) { |
389 ActivityManager::Get()->UpdateActivity(this); | 393 ActivityManager::Get()->UpdateActivity(this); |
390 } | 394 } |
391 | 395 |
| 396 void WebActivity::DidChangeThemeColor(SkColor theme_color) { |
| 397 title_color_ = theme_color; |
| 398 } |
| 399 |
392 } // namespace athena | 400 } // namespace athena |
OLD | NEW |