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

Side by Side Diff: chrome/browser/ui/tabs/tab_strip_model.cc

Issue 2630583002: Add setting to isolate zoom changes by default. (Closed)
Patch Set: ... and tell closure_compiler. Created 3 years, 10 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 | « chrome/browser/ui/BUILD.gn ('k') | chrome/browser/ui/tabs/tab_strip_model_unittest.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 (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 <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
11 11
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/ptr_util.h" 13 #include "base/memory/ptr_util.h"
14 #include "base/metrics/histogram_macros.h" 14 #include "base/metrics/histogram_macros.h"
15 #include "chrome/app/chrome_command_ids.h" 15 #include "chrome/app/chrome_command_ids.h"
16 #include "chrome/browser/browser_shutdown.h" 16 #include "chrome/browser/browser_shutdown.h"
17 #include "chrome/browser/defaults.h" 17 #include "chrome/browser/defaults.h"
18 #include "chrome/browser/extensions/tab_helper.h" 18 #include "chrome/browser/extensions/tab_helper.h"
19 #include "chrome/browser/profiles/profile.h" 19 #include "chrome/browser/profiles/profile.h"
20 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" 20 #include "chrome/browser/ui/tab_contents/core_tab_helper.h"
21 #include "chrome/browser/ui/tab_contents/core_tab_helper_delegate.h" 21 #include "chrome/browser/ui/tab_contents/core_tab_helper_delegate.h"
22 #include "chrome/browser/ui/tabs/tab_strip_model_delegate.h" 22 #include "chrome/browser/ui/tabs/tab_strip_model_delegate.h"
23 #include "chrome/browser/ui/tabs/tab_strip_model_order_controller.h" 23 #include "chrome/browser/ui/tabs/tab_strip_model_order_controller.h"
24 #include "chrome/browser/ui/tabs/tab_utils.h" 24 #include "chrome/browser/ui/tabs/tab_utils.h"
25 #include "chrome/browser/ui/web_contents_sizer.h" 25 #include "chrome/browser/ui/web_contents_sizer.h"
26 #include "chrome/common/url_constants.h" 26 #include "chrome/common/url_constants.h"
27 #include "components/web_modal/web_contents_modal_dialog_manager.h" 27 #include "components/web_modal/web_contents_modal_dialog_manager.h"
28 #include "components/zoom/zoom_controller.h"
28 #include "content/public/browser/render_process_host.h" 29 #include "content/public/browser/render_process_host.h"
29 #include "content/public/browser/user_metrics.h" 30 #include "content/public/browser/user_metrics.h"
30 #include "content/public/browser/web_contents.h" 31 #include "content/public/browser/web_contents.h"
31 #include "content/public/browser/web_contents_observer.h" 32 #include "content/public/browser/web_contents_observer.h"
32 using base::UserMetricsAction; 33 using base::UserMetricsAction;
33 using content::WebContents; 34 using content::WebContents;
34 35
35 namespace { 36 namespace {
36 37
37 // Returns true if the specified transition is one of the types that cause the 38 // Returns true if the specified transition is one of the types that cause the
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 WebContents* new_contents) { 336 WebContents* new_contents) {
336 delegate_->WillAddWebContents(new_contents); 337 delegate_->WillAddWebContents(new_contents);
337 338
338 DCHECK(ContainsIndex(index)); 339 DCHECK(ContainsIndex(index));
339 WebContents* old_contents = GetWebContentsAtImpl(index); 340 WebContents* old_contents = GetWebContentsAtImpl(index);
340 341
341 FixOpenersAndGroupsReferencing(index); 342 FixOpenersAndGroupsReferencing(index);
342 343
343 contents_data_[index]->SetWebContents(new_contents); 344 contents_data_[index]->SetWebContents(new_contents);
344 345
346 // Notify the ZoomController of the replacement of its WebContents so that it
347 // may clone any per-tab zoom information.
348 zoom::ZoomController* zoom_controller =
349 zoom::ZoomController::FromWebContents(old_contents);
350 if (zoom_controller)
351 zoom_controller->WebContentsReplaced(new_contents);
352
345 for (auto& observer : observers_) 353 for (auto& observer : observers_)
346 observer.TabReplacedAt(this, old_contents, new_contents, index); 354 observer.TabReplacedAt(this, old_contents, new_contents, index);
347 355
348 // When the active WebContents is replaced send out a selection notification 356 // When the active WebContents is replaced send out a selection notification
349 // too. We do this as nearly all observers need to treat a replacement of the 357 // too. We do this as nearly all observers need to treat a replacement of the
350 // selected contents as the selection changing. 358 // selected contents as the selection changing.
351 if (active_index() == index) { 359 if (active_index() == index) {
352 for (auto& observer : observers_) 360 for (auto& observer : observers_)
353 observer.ActiveTabChanged(old_contents, new_contents, active_index(), 361 observer.ActiveTabChanged(old_contents, new_contents, active_index(),
354 TabStripModelObserver::CHANGE_REASON_REPLACED); 362 TabStripModelObserver::CHANGE_REASON_REPLACED);
(...skipping 1007 matching lines...) Expand 10 before | Expand all | Expand 10 after
1362 1370
1363 void TabStripModel::FixOpenersAndGroupsReferencing(int index) { 1371 void TabStripModel::FixOpenersAndGroupsReferencing(int index) {
1364 WebContents* old_contents = GetWebContentsAtImpl(index); 1372 WebContents* old_contents = GetWebContentsAtImpl(index);
1365 for (auto& data : contents_data_) { 1373 for (auto& data : contents_data_) {
1366 if (data->group() == old_contents) 1374 if (data->group() == old_contents)
1367 data->set_group(contents_data_[index]->group()); 1375 data->set_group(contents_data_[index]->group());
1368 if (data->opener() == old_contents) 1376 if (data->opener() == old_contents)
1369 data->set_opener(contents_data_[index]->opener()); 1377 data->set_opener(contents_data_[index]->opener());
1370 } 1378 }
1371 } 1379 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/BUILD.gn ('k') | chrome/browser/ui/tabs/tab_strip_model_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698