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

Side by Side Diff: chrome/browser/ui/settings_window_manager.cc

Issue 595213005: Eliminate chrome::IsTrustedWindowWithScheme (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Feedback Created 6 years, 2 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/settings_window_manager.h ('k') | no next file » | 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) 2014 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "chrome/browser/ui/settings_window_manager.h" 5 #include "chrome/browser/ui/settings_window_manager.h"
6 6
7 #include "chrome/browser/profiles/profile.h" 7 #include "chrome/browser/profiles/profile.h"
8 #include "chrome/browser/ui/browser_finder.h" 8 #include "chrome/browser/ui/browser_finder.h"
9 #include "chrome/browser/ui/browser_finder.h" 9 #include "chrome/browser/ui/browser_finder.h"
10 #include "chrome/browser/ui/browser_navigator.h" 10 #include "chrome/browser/ui/browser_navigator.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 } 47 }
48 NavigateParams params(browser, gurl, 48 NavigateParams params(browser, gurl,
49 ui::PAGE_TRANSITION_AUTO_BOOKMARK); 49 ui::PAGE_TRANSITION_AUTO_BOOKMARK);
50 params.window_action = NavigateParams::SHOW_WINDOW; 50 params.window_action = NavigateParams::SHOW_WINDOW;
51 params.user_gesture = true; 51 params.user_gesture = true;
52 chrome::Navigate(&params); 52 chrome::Navigate(&params);
53 return; 53 return;
54 } 54 }
55 55
56 // No existing browser window, create one. 56 // No existing browser window, create one.
57 NavigateParams params(profile, gurl, ui::PAGE_TRANSITION_AUTO_BOOKMARK); 57 navigate_params_.reset(
58 params.disposition = NEW_POPUP; 58 new NavigateParams(profile, gurl, ui::PAGE_TRANSITION_AUTO_BOOKMARK));
59 params.trusted_source = true; 59 navigate_params_->disposition = NEW_POPUP;
60 params.window_action = NavigateParams::SHOW_WINDOW; 60 navigate_params_->trusted_source = true;
61 params.user_gesture = true; 61 navigate_params_->window_action = NavigateParams::SHOW_WINDOW;
62 params.path_behavior = NavigateParams::IGNORE_AND_NAVIGATE; 62 navigate_params_->user_gesture = true;
63 chrome::Navigate(&params); 63 navigate_params_->path_behavior = NavigateParams::IGNORE_AND_NAVIGATE;
64 settings_session_map_[profile] = params.browser->session_id().id(); 64 chrome::Navigate(navigate_params_.get());
65 settings_session_map_[profile] = navigate_params_->browser->session_id().id();
66 // Once we set settings_session_map_, reset |navigate_params_| so that we do
67 // not hold on to a structure with stale pointers.
68 navigate_params_.reset();
65 69
66 FOR_EACH_OBSERVER(SettingsWindowManagerObserver, 70 FOR_EACH_OBSERVER(SettingsWindowManagerObserver,
67 observers_, OnNewSettingsWindow(params.browser)); 71 observers_, OnNewSettingsWindow(navigate_params_->browser));
68 } 72 }
69 73
70 Browser* SettingsWindowManager::FindBrowserForProfile(Profile* profile) { 74 Browser* SettingsWindowManager::FindBrowserForProfile(Profile* profile) {
71 ProfileSessionMap::iterator iter = settings_session_map_.find(profile); 75 ProfileSessionMap::iterator iter = settings_session_map_.find(profile);
72 if (iter != settings_session_map_.end()) 76 if (iter != settings_session_map_.end())
73 return chrome::FindBrowserWithID(iter->second); 77 return chrome::FindBrowserWithID(iter->second);
74 return NULL; 78 return NULL;
75 } 79 }
76 80
77 bool SettingsWindowManager::IsSettingsBrowser(Browser* browser) const { 81 bool SettingsWindowManager::IsSettingsBrowser(Browser* browser) const {
82 // This may get called from chrome::Navigate, so first test to see if this
83 // is the browser we are crrently navigating to.
84 if (navigate_params_ && navigate_params_->browser == browser)
sky 2014/09/25 23:36:52 Dependencies like this are fragile and result in N
85 return true;
78 ProfileSessionMap::const_iterator iter = 86 ProfileSessionMap::const_iterator iter =
79 settings_session_map_.find(browser->profile()); 87 settings_session_map_.find(browser->profile());
80 return (iter != settings_session_map_.end() && 88 return (iter != settings_session_map_.end() &&
81 iter->second == browser->session_id().id()); 89 iter->second == browser->session_id().id());
82 } 90 }
83 91
84 SettingsWindowManager::SettingsWindowManager() { 92 SettingsWindowManager::SettingsWindowManager() {
85 } 93 }
86 94
87 SettingsWindowManager::~SettingsWindowManager() { 95 SettingsWindowManager::~SettingsWindowManager() {
88 } 96 }
89 97
90 } // namespace chrome 98 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/ui/settings_window_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698