| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ui/tabs/tab_strip_model.h" | 5 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 : tab_strip_model_(tab_strip_model) { | 142 : tab_strip_model_(tab_strip_model) { |
| 143 tab_strip_model_->AddObserver(this); | 143 tab_strip_model_->AddObserver(this); |
| 144 } | 144 } |
| 145 | 145 |
| 146 ~TabBlockedStateTestBrowser() override { | 146 ~TabBlockedStateTestBrowser() override { |
| 147 tab_strip_model_->RemoveObserver(this); | 147 tab_strip_model_->RemoveObserver(this); |
| 148 } | 148 } |
| 149 | 149 |
| 150 private: | 150 private: |
| 151 // TabStripModelObserver | 151 // TabStripModelObserver |
| 152 void TabInsertedAt(WebContents* contents, | 152 void TabInsertedAt(TabStripModel* tab_strip_model, |
| 153 WebContents* contents, |
| 153 int index, | 154 int index, |
| 154 bool foreground) override { | 155 bool foreground) override { |
| 155 web_modal::WebContentsModalDialogManager* manager = | 156 web_modal::WebContentsModalDialogManager* manager = |
| 156 web_modal::WebContentsModalDialogManager::FromWebContents(contents); | 157 web_modal::WebContentsModalDialogManager::FromWebContents(contents); |
| 157 if (manager) | 158 if (manager) |
| 158 manager->SetDelegate(this); | 159 manager->SetDelegate(this); |
| 159 } | 160 } |
| 160 | 161 |
| 161 // WebContentsModalDialogManagerDelegate | 162 // WebContentsModalDialogManagerDelegate |
| 162 void SetWebContentsBlocked(content::WebContents* contents, | 163 void SetWebContentsBlocked(content::WebContents* contents, |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 return (s.src_contents == state.src_contents && | 341 return (s.src_contents == state.src_contents && |
| 341 s.dst_contents == state.dst_contents && | 342 s.dst_contents == state.dst_contents && |
| 342 s.src_index == state.src_index && | 343 s.src_index == state.src_index && |
| 343 s.dst_index == state.dst_index && | 344 s.dst_index == state.dst_index && |
| 344 s.change_reason == state.change_reason && | 345 s.change_reason == state.change_reason && |
| 345 s.foreground == state.foreground && | 346 s.foreground == state.foreground && |
| 346 s.action == state.action); | 347 s.action == state.action); |
| 347 } | 348 } |
| 348 | 349 |
| 349 // TabStripModelObserver implementation: | 350 // TabStripModelObserver implementation: |
| 350 void TabInsertedAt(WebContents* contents, | 351 void TabInsertedAt(TabStripModel* tab_strip_model, |
| 352 WebContents* contents, |
| 351 int index, | 353 int index, |
| 352 bool foreground) override { | 354 bool foreground) override { |
| 353 empty_ = false; | 355 empty_ = false; |
| 354 State s(contents, index, INSERT); | 356 State s(contents, index, INSERT); |
| 355 s.foreground = foreground; | 357 s.foreground = foreground; |
| 356 states_.push_back(s); | 358 states_.push_back(s); |
| 357 } | 359 } |
| 358 void ActiveTabChanged(WebContents* old_contents, | 360 void ActiveTabChanged(WebContents* old_contents, |
| 359 WebContents* new_contents, | 361 WebContents* new_contents, |
| 360 int index, | 362 int index, |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 394 states_.push_back(State(contents, index, CHANGE)); | 396 states_.push_back(State(contents, index, CHANGE)); |
| 395 } | 397 } |
| 396 void TabReplacedAt(TabStripModel* tab_strip_model, | 398 void TabReplacedAt(TabStripModel* tab_strip_model, |
| 397 WebContents* old_contents, | 399 WebContents* old_contents, |
| 398 WebContents* new_contents, | 400 WebContents* new_contents, |
| 399 int index) override { | 401 int index) override { |
| 400 State s(new_contents, index, REPLACED); | 402 State s(new_contents, index, REPLACED); |
| 401 s.src_contents = old_contents; | 403 s.src_contents = old_contents; |
| 402 states_.push_back(s); | 404 states_.push_back(s); |
| 403 } | 405 } |
| 404 void TabPinnedStateChanged(WebContents* contents, int index) override { | 406 void TabPinnedStateChanged(TabStripModel* tab_strip_model, |
| 407 WebContents* contents, |
| 408 int index) override { |
| 405 states_.push_back(State(contents, index, PINNED)); | 409 states_.push_back(State(contents, index, PINNED)); |
| 406 } | 410 } |
| 407 void TabStripEmpty() override { empty_ = true; } | 411 void TabStripEmpty() override { empty_ = true; } |
| 408 void WillCloseAllTabs() override { | 412 void WillCloseAllTabs() override { |
| 409 states_.push_back(State(NULL, -1, CLOSE_ALL)); | 413 states_.push_back(State(NULL, -1, CLOSE_ALL)); |
| 410 } | 414 } |
| 411 void CloseAllTabsCanceled() override { | 415 void CloseAllTabsCanceled() override { |
| 412 states_.push_back(State(NULL, -1, CLOSE_ALL_CANCELED)); | 416 states_.push_back(State(NULL, -1, CLOSE_ALL_CANCELED)); |
| 413 } | 417 } |
| 414 | 418 |
| (...skipping 2125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2540 strip.AddObserver(&observer); | 2544 strip.AddObserver(&observer); |
| 2541 | 2545 |
| 2542 strip.ActivateTabAt(1, true); | 2546 strip.ActivateTabAt(1, true); |
| 2543 EXPECT_EQ(1, strip.active_index()); | 2547 EXPECT_EQ(1, strip.active_index()); |
| 2544 | 2548 |
| 2545 strip.MoveWebContentsAt(2, 3, true); | 2549 strip.MoveWebContentsAt(2, 3, true); |
| 2546 EXPECT_EQ(3, strip.active_index()); | 2550 EXPECT_EQ(3, strip.active_index()); |
| 2547 | 2551 |
| 2548 strip.CloseAllTabs(); | 2552 strip.CloseAllTabs(); |
| 2549 } | 2553 } |
| OLD | NEW |