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

Side by Side Diff: chrome/browser/extensions/extension_tab_util.cc

Issue 1130373002: Returning Corresponding Error Message when their is error in OpenTab. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing nit. Created 5 years, 7 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 | « no previous file | 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) 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/extensions/extension_tab_util.h" 5 #include "chrome/browser/extensions/extension_tab_util.h"
6 6
7 #include "base/strings/string_number_conversions.h" 7 #include "base/strings/string_number_conversions.h"
8 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
9 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" 9 #include "chrome/browser/extensions/api/tabs/tabs_constants.h"
10 #include "chrome/browser/extensions/chrome_extension_function.h" 10 #include "chrome/browser/extensions/chrome_extension_function.h"
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 return NULL; 136 return NULL;
137 } 137 }
138 138
139 // Ensure the selected browser is tabbed. 139 // Ensure the selected browser is tabbed.
140 if (!browser->is_type_tabbed() && browser->IsAttemptingToCloseBrowser()) 140 if (!browser->is_type_tabbed() && browser->IsAttemptingToCloseBrowser())
141 browser = chrome::FindTabbedBrowser(function->GetProfile(), 141 browser = chrome::FindTabbedBrowser(function->GetProfile(),
142 function->include_incognito(), 142 function->include_incognito(),
143 browser->host_desktop_type()); 143 browser->host_desktop_type());
144 144
145 if (!browser || !browser->window()) { 145 if (!browser || !browser->window()) {
146 // TODO(rpaquay): Error message? 146 if (error)
147 *error = keys::kNoCurrentWindowError;
147 return NULL; 148 return NULL;
148 } 149 }
149 150
150 // TODO(jstritar): Add a constant, chrome.tabs.TAB_ID_ACTIVE, that 151 // TODO(jstritar): Add a constant, chrome.tabs.TAB_ID_ACTIVE, that
151 // represents the active tab. 152 // represents the active tab.
152 WebContents* opener = NULL; 153 WebContents* opener = NULL;
153 if (params.opener_tab_id.get()) { 154 if (params.opener_tab_id.get()) {
154 int opener_id = *params.opener_tab_id; 155 int opener_id = *params.opener_tab_id;
155 156
156 if (!ExtensionTabUtil::GetTabById(opener_id, 157 if (!ExtensionTabUtil::GetTabById(opener_id,
157 function->GetProfile(), 158 function->GetProfile(),
158 function->include_incognito(), 159 function->include_incognito(),
159 NULL, 160 NULL,
160 NULL, 161 NULL,
161 &opener, 162 &opener,
162 NULL)) { 163 NULL)) {
163 // TODO(rpaquay): Error message? 164 if (error) {
165 *error = ErrorUtils::FormatErrorMessage(keys::kTabNotFoundError,
166 base::IntToString(opener_id));
167 }
164 return NULL; 168 return NULL;
165 } 169 }
166 } 170 }
167 171
168 // TODO(rafaelw): handle setting remaining tab properties: 172 // TODO(rafaelw): handle setting remaining tab properties:
169 // -title 173 // -title
170 // -favIconUrl 174 // -favIconUrl
171 175
172 GURL url; 176 GURL url;
173 if (params.url.get()) { 177 if (params.url.get()) {
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 611
608 chrome::NavigateParams params( 612 chrome::NavigateParams params(
609 chrome::GetSingletonTabNavigateParams(browser, url_to_navigate)); 613 chrome::GetSingletonTabNavigateParams(browser, url_to_navigate));
610 params.path_behavior = chrome::NavigateParams::IGNORE_AND_NAVIGATE; 614 params.path_behavior = chrome::NavigateParams::IGNORE_AND_NAVIGATE;
611 params.url = url_to_navigate; 615 params.url = url_to_navigate;
612 chrome::ShowSingletonTabOverwritingNTP(browser, params); 616 chrome::ShowSingletonTabOverwritingNTP(browser, params);
613 return true; 617 return true;
614 } 618 }
615 619
616 } // namespace extensions 620 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698