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

Side by Side Diff: chrome/browser/chromeos/wm_overview_controller.cc

Issue 6693021: fav icon -> favicon. Pass 5: fav_icon -> favicon (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/chromeos/wm_overview_controller.h" 5 #include "chrome/browser/chromeos/wm_overview_controller.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/linked_ptr.h" 10 #include "base/linked_ptr.h"
11 #include "chrome/browser/browser_process.h" 11 #include "chrome/browser/browser_process.h"
12 #include "chrome/browser/chromeos/wm_ipc.h" 12 #include "chrome/browser/chromeos/wm_ipc.h"
13 #include "chrome/browser/chromeos/wm_overview_fav_icon.h" 13 #include "chrome/browser/chromeos/wm_overview_favicon.h"
14 #include "chrome/browser/chromeos/wm_overview_snapshot.h" 14 #include "chrome/browser/chromeos/wm_overview_snapshot.h"
15 #include "chrome/browser/chromeos/wm_overview_title.h" 15 #include "chrome/browser/chromeos/wm_overview_title.h"
16 #include "chrome/browser/tab_contents/thumbnail_generator.h" 16 #include "chrome/browser/tab_contents/thumbnail_generator.h"
17 #include "chrome/browser/tabs/tab_strip_model.h" 17 #include "chrome/browser/tabs/tab_strip_model.h"
18 #include "chrome/browser/ui/browser.h" 18 #include "chrome/browser/ui/browser.h"
19 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 19 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
20 #include "chrome/browser/ui/views/frame/browser_view.h" 20 #include "chrome/browser/ui/views/frame/browser_view.h"
21 #include "content/browser/renderer_host/render_view_host.h" 21 #include "content/browser/renderer_host/render_view_host.h"
22 #include "content/browser/renderer_host/render_widget_host.h" 22 #include "content/browser/renderer_host/render_widget_host.h"
23 #include "content/browser/renderer_host/render_widget_host_view.h" 23 #include "content/browser/renderer_host/render_widget_host_view.h"
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 // Which renderer host we are working on. 158 // Which renderer host we are working on.
159 RenderWidgetHost* current_renderer_host_; // Not owned 159 RenderWidgetHost* current_renderer_host_; // Not owned
160 160
161 // Widgets containing snapshot images for this browser. Note that 161 // Widgets containing snapshot images for this browser. Note that
162 // these are all subclasses of WidgetGtk, and they are all added to 162 // these are all subclasses of WidgetGtk, and they are all added to
163 // parents, so they will be deleted by the parents when they are 163 // parents, so they will be deleted by the parents when they are
164 // closed. 164 // closed.
165 struct SnapshotNode { 165 struct SnapshotNode {
166 WmOverviewSnapshot* snapshot; // Not owned 166 WmOverviewSnapshot* snapshot; // Not owned
167 WmOverviewTitle* title; // Not owned 167 WmOverviewTitle* title; // Not owned
168 WmOverviewFavIcon* fav_icon; // Not owned 168 WmOverviewFavicon* favicon; // Not owned
169 }; 169 };
170 typedef std::vector<SnapshotNode> SnapshotVector; 170 typedef std::vector<SnapshotNode> SnapshotVector;
171 SnapshotVector snapshots_; 171 SnapshotVector snapshots_;
172 172
173 // Non-zero if we are currently setting the tab from within SelectTab. 173 // Non-zero if we are currently setting the tab from within SelectTab.
174 // This is used to make sure we use the right timestamp when sending 174 // This is used to make sure we use the right timestamp when sending
175 // property changes that originated from the window manager. 175 // property changes that originated from the window manager.
176 uint32 select_tab_timestamp_; 176 uint32 select_tab_timestamp_;
177 177
178 // The tab selected the last time SaveCurrentTab is called. 178 // The tab selected the last time SaveCurrentTab is called.
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 UpdateSelectedIndex(browser_->selected_index()); 231 UpdateSelectedIndex(browser_->selected_index());
232 } 232 }
233 233
234 void BrowserListener::TabChangedAt( 234 void BrowserListener::TabChangedAt(
235 TabContentsWrapper* contents, 235 TabContentsWrapper* contents,
236 int index, 236 int index,
237 TabStripModelObserver::TabChangeType change_type) { 237 TabStripModelObserver::TabChangeType change_type) {
238 if (change_type != TabStripModelObserver::LOADING_ONLY) { 238 if (change_type != TabStripModelObserver::LOADING_ONLY) {
239 snapshots_[index].title->SetTitle(contents->tab_contents()->GetTitle()); 239 snapshots_[index].title->SetTitle(contents->tab_contents()->GetTitle());
240 snapshots_[index].title->SetUrl(contents->tab_contents()->GetURL()); 240 snapshots_[index].title->SetUrl(contents->tab_contents()->GetURL());
241 snapshots_[index].fav_icon->SetFavicon( 241 snapshots_[index].favicon->SetFavicon(
242 contents->tab_contents()->GetFavicon()); 242 contents->tab_contents()->GetFavicon());
243 if (change_type != TabStripModelObserver::TITLE_NOT_LOADING) 243 if (change_type != TabStripModelObserver::TITLE_NOT_LOADING)
244 MarkSnapshotAsDirty(index); 244 MarkSnapshotAsDirty(index);
245 } 245 }
246 } 246 }
247 247
248 void BrowserListener::TabStripEmpty() { 248 void BrowserListener::TabStripEmpty() {
249 snapshots_.clear(); 249 snapshots_.clear();
250 } 250 }
251 251
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 } 309 }
310 } 310 }
311 311
312 void BrowserListener::ShowSnapshots() { 312 void BrowserListener::ShowSnapshots() {
313 for (SnapshotVector::size_type i = 0; i < snapshots_.size(); ++i) { 313 for (SnapshotVector::size_type i = 0; i < snapshots_.size(); ++i) {
314 const SnapshotNode& node = snapshots_[i]; 314 const SnapshotNode& node = snapshots_[i];
315 if (!node.snapshot->IsVisible()) 315 if (!node.snapshot->IsVisible())
316 node.snapshot->Show(); 316 node.snapshot->Show();
317 if (!snapshots_[i].title->IsVisible()) 317 if (!snapshots_[i].title->IsVisible())
318 node.title->Show(); 318 node.title->Show();
319 if (!snapshots_[i].fav_icon->IsVisible()) 319 if (!snapshots_[i].favicon->IsVisible())
320 node.fav_icon->Show(); 320 node.favicon->Show();
321 } 321 }
322 } 322 }
323 323
324 void BrowserListener::SelectTab(int index, uint32 timestamp) { 324 void BrowserListener::SelectTab(int index, uint32 timestamp) {
325 // Ignore requests to switch to non-existent tabs (the window manager gets 325 // Ignore requests to switch to non-existent tabs (the window manager gets
326 // notified asynchronously about the number of tabs in each window, so there's 326 // notified asynchronously about the number of tabs in each window, so there's
327 // no guarantee that the messages that it sends us will make sense). 327 // no guarantee that the messages that it sends us will make sense).
328 if (index < 0 || index >= browser_->tab_count()) 328 if (index < 0 || index >= browser_->tab_count())
329 return; 329 return;
330 330
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 controller_->StartDelayTimer(); 415 controller_->StartDelayTimer();
416 } 416 }
417 } 417 }
418 418
419 void BrowserListener::InsertSnapshot(int index) { 419 void BrowserListener::InsertSnapshot(int index) {
420 SnapshotNode node; 420 SnapshotNode node;
421 node.snapshot = new WmOverviewSnapshot; 421 node.snapshot = new WmOverviewSnapshot;
422 gfx::Size cell_size = CalculateCellSize(); 422 gfx::Size cell_size = CalculateCellSize();
423 node.snapshot->Init(cell_size, browser_, index); 423 node.snapshot->Init(cell_size, browser_, index);
424 424
425 node.fav_icon = new WmOverviewFavIcon; 425 node.favicon = new WmOverviewFavicon;
426 node.fav_icon->Init(node.snapshot); 426 node.favicon->Init(node.snapshot);
427 node.fav_icon->SetFavicon(browser_->GetTabContentsAt(index)->GetFavicon()); 427 node.favicon->SetFavicon(browser_->GetTabContentsAt(index)->GetFavicon());
428 428
429 node.title = new WmOverviewTitle; 429 node.title = new WmOverviewTitle;
430 node.title->Init(gfx::Size(std::max(0, cell_size.width() - 430 node.title->Init(gfx::Size(std::max(0, cell_size.width() -
431 WmOverviewFavIcon::kIconSize - 431 WmOverviewFavicon::kIconSize -
432 kFavIconPadding), 432 kFavIconPadding),
433 kTitleHeight), node.snapshot); 433 kTitleHeight), node.snapshot);
434 node.title->SetTitle(browser_->GetTabContentsAt(index)->GetTitle()); 434 node.title->SetTitle(browser_->GetTabContentsAt(index)->GetTitle());
435 435
436 snapshots_.insert(snapshots_.begin() + index, node); 436 snapshots_.insert(snapshots_.begin() + index, node);
437 node.snapshot->reload_snapshot(); 437 node.snapshot->reload_snapshot();
438 controller_->UpdateSnapshots(); 438 controller_->UpdateSnapshots();
439 } 439 }
440 440
441 // Removes the snapshot at index. 441 // Removes the snapshot at index.
442 void BrowserListener::ClearSnapshot(int index) { 442 void BrowserListener::ClearSnapshot(int index) {
443 snapshots_[index].snapshot->CloseNow(); 443 snapshots_[index].snapshot->CloseNow();
444 snapshots_[index].title->CloseNow(); 444 snapshots_[index].title->CloseNow();
445 snapshots_[index].fav_icon->CloseNow(); 445 snapshots_[index].favicon->CloseNow();
446 snapshots_.erase(snapshots_.begin() + index); 446 snapshots_.erase(snapshots_.begin() + index);
447 } 447 }
448 448
449 void BrowserListener::RenumberSnapshots(int start_index) { 449 void BrowserListener::RenumberSnapshots(int start_index) {
450 for (SnapshotVector::size_type i = start_index; i < snapshots_.size(); ++i) { 450 for (SnapshotVector::size_type i = start_index; i < snapshots_.size(); ++i) {
451 if (snapshots_[i].snapshot->index() != static_cast<int>(i)) 451 if (snapshots_[i].snapshot->index() != static_cast<int>(i))
452 snapshots_[i].snapshot->UpdateIndex(browser_, i); 452 snapshots_[i].snapshot->UpdateIndex(browser_, i);
453 } 453 }
454 } 454 }
455 455
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
738 if (item.get() == NULL) { 738 if (item.get() == NULL) {
739 item = BrowserListenerVector::value_type( 739 item = BrowserListenerVector::value_type(
740 new BrowserListener(*iterator, this)); 740 new BrowserListener(*iterator, this));
741 } 741 }
742 listeners_.push_back(item); 742 listeners_.push_back(item);
743 ++iterator; 743 ++iterator;
744 } 744 }
745 } 745 }
746 746
747 } // namespace chromeos 747 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/bookmarks/bookmark_model.cc ('k') | chrome/browser/chromeos/wm_overview_favicon.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698