diff options
author | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-26 06:19:36 +0000 |
---|---|---|
committer | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-26 06:19:36 +0000 |
commit | a7a7735b1c0b8a4b1c9d40ede057e9081ef3c6a1 (patch) | |
tree | d7637c066d54399bc4d8e84d5d259ddf45d7e4a8 | |
parent | b82d09c2891542809790785d4b5dbe563420d5ee (diff) | |
download | chromium_src-a7a7735b1c0b8a4b1c9d40ede057e9081ef3c6a1.zip chromium_src-a7a7735b1c0b8a4b1c9d40ede057e9081ef3c6a1.tar.gz chromium_src-a7a7735b1c0b8a4b1c9d40ede057e9081ef3c6a1.tar.bz2 |
Allow user to choose what kind of container to launch
applications in.
Review URL: http://codereview.chromium.org/1784001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@45570 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/browser.cc | 2 | ||||
-rw-r--r-- | chrome/browser/dom_ui/app_launcher_handler.cc | 24 | ||||
-rw-r--r-- | chrome/browser/dom_ui/shown_sections_handler.h | 3 | ||||
-rw-r--r-- | chrome/browser/resources/new_new_tab.css | 20 | ||||
-rw-r--r-- | chrome/browser/resources/new_new_tab.html | 21 | ||||
-rw-r--r-- | chrome/browser/resources/new_new_tab.js | 29 |
6 files changed, 89 insertions, 10 deletions
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc index 0ee8753..7abf03d 100644 --- a/chrome/browser/browser.cc +++ b/chrome/browser/browser.cc @@ -458,8 +458,6 @@ void Browser::OpenApplicationWindow(Profile* profile, Extension* extension) { // static bool Browser::OpenApplicationTab(Profile* profile, Extension* extension) { - DCHECK_EQ(extension->launch_container(), Extension::LAUNCH_TAB); - Browser* browser = BrowserList::GetLastActiveWithProfile(profile); if (!browser || browser->type() != Browser::TYPE_NORMAL) return false; diff --git a/chrome/browser/dom_ui/app_launcher_handler.cc b/chrome/browser/dom_ui/app_launcher_handler.cc index 846076d..6f48333 100644 --- a/chrome/browser/dom_ui/app_launcher_handler.cc +++ b/chrome/browser/dom_ui/app_launcher_handler.cc @@ -110,11 +110,31 @@ void AppLauncherHandler::HandleLaunchApp(const Value* value) { } std::string extension_id; + std::string launch_container; + const ListValue* list = static_cast<const ListValue*>(value); - if (list->GetSize() == 0 || !list->GetString(0, &extension_id)) { + if (!list->GetString(0, &extension_id) || + !list->GetString(1, &launch_container)) { NOTREACHED(); return; } - Browser::OpenApplication(extensions_service_->profile(), extension_id); + Profile* profile = extensions_service_->profile(); + if (launch_container.empty()) { + Browser::OpenApplication(profile, extension_id); + return; + } + + Extension* extension = + extensions_service_->GetExtensionById(extension_id, false); + DCHECK(extension); + + if (launch_container == "tab") + Browser::OpenApplicationTab(profile, extension); + else if (launch_container == "panel") + Browser::OpenApplicationWindow(profile, extension, GURL(), true); + else if (launch_container == "window") + Browser::OpenApplicationWindow(profile, extension, GURL(), false); + else + NOTREACHED() << "Unexpected launch container: " << launch_container << "."; } diff --git a/chrome/browser/dom_ui/shown_sections_handler.h b/chrome/browser/dom_ui/shown_sections_handler.h index 132ecbf..ba0e8b3 100644 --- a/chrome/browser/dom_ui/shown_sections_handler.h +++ b/chrome/browser/dom_ui/shown_sections_handler.h @@ -17,7 +17,8 @@ enum Section { LIST = 2, RECENT = 4, TIPS = 8, - SYNC = 16 + SYNC = 16, + DEBUG = 32 }; class ShownSectionsHandler : public DOMMessageHandler { diff --git a/chrome/browser/resources/new_new_tab.css b/chrome/browser/resources/new_new_tab.css index bceb33a..16d4839 100644 --- a/chrome/browser/resources/new_new_tab.css +++ b/chrome/browser/resources/new_new_tab.css @@ -753,11 +753,21 @@ html[dir=rtl] #option-menu > [command=hide]:before { } #apps-section { - display: none; padding: 10px 0px; border-top: 0; } +#apps-launch-control { + margin-top: 0.5em; +} + +#apps-launch-control input { + position:relative; + top: 1px; + margin-right: 0.2em; + margin-left: 1em; +} + #apps-section a { -webkit-box-sizing: border-box; -webkit-transition: background-color .15s; @@ -780,6 +790,14 @@ html[dir=rtl] #option-menu > [command=hide]:before { width: 105px; /* 920 / 8 - margin * 2 */ } +#debug h2 { + color: red; +} + +.section.disabled { + display: none!important; +} + .section + :not(.hidden) { border-top: 0; } diff --git a/chrome/browser/resources/new_new_tab.html b/chrome/browser/resources/new_new_tab.html index c052d73..019701e 100644 --- a/chrome/browser/resources/new_new_tab.html +++ b/chrome/browser/resources/new_new_tab.html @@ -70,7 +70,8 @@ var Section = { // LIST is no longer used RECENT: 4, TIPS: 8, - SYNC: 16 + SYNC: 16, + DEBUG: 32 }; var shownSections = templateData['shown_sections']; @@ -200,7 +201,7 @@ function updateSimpleSection(id, section) { <span class="link"><span class="link-color"></span></span> </div> - <div class="section" id="apps-section"></div> + <div class="section disabled" id="apps-section"></div> <div id="most-visited-section" class="section" section="THUMB"> <h2 i18n-content="mostvisited"></h2> @@ -234,10 +235,26 @@ function updateSimpleSection(id, section) { </span> </div> + <div id="debug" class="section disabled" section="DEBUG"> + <h2>Debug</h2> + <div id="apps-launch-control"> + Open apps in:<label + ><input type="radio" name="launch-container-type" value="" + checked="true">Default</label + ><label><input type="radio" name="launch-container-type" value="tab" + >Tab</label + ><label><input type="radio" name="launch-container-type" value="window" + >Window</label + ><label><input type="radio" name="launch-container-type" value="panel" + >Panel</label> + </div> + </div> + <script> (function() { updateSimpleSection('recently-closed', Section.RECENT); updateSimpleSection('most-visited-section', Section.THUMB); + updateSimpleSection('debug', Section.DEBUG); var el = $('most-visited'); for (var i = 1; i < 8; i++) { el.appendChild(el.firstElementChild.cloneNode(true)).id = 't' + i; diff --git a/chrome/browser/resources/new_new_tab.js b/chrome/browser/resources/new_new_tab.js index 9e8b859..0add83b 100644 --- a/chrome/browser/resources/new_new_tab.js +++ b/chrome/browser/resources/new_new_tab.js @@ -76,12 +76,22 @@ function mostVisitedPages(data, firstRun) { function getAppsCallback(data) { var appsSection = $('apps-section'); + var debugSection = $('debug'); appsSection.innerHTML = ''; - appsSection.style.display = data.length ? 'block' : ''; data.forEach(function(app) { appsSection.appendChild(apps.createElement(app)); }); + + // TODO(aa): Figure out what to do with the debug mode when we turn apps on + // for everyone. + if (data.length) { + removeClass(appsSection, 'disabled'); + removeClass(debugSection, 'disabled'); + } else { + addClass(appsSection, 'disabled'); + addClass(debugSection, 'disabled'); + } } var apps = { @@ -89,7 +99,16 @@ var apps = { * @this {!HTMLAnchorElement} */ handleClick_: function() { - chrome.send('launchApp', [this.id]); + var launchType = ''; + var inputElements = document.querySelectorAll( + '#apps-launch-control input'); + for (var i = 0, input; input = inputElements[i]; i++) { + if (input.checked) { + launchType = input.value; + break; + } + } + chrome.send('launchApp', [this.id, launchType]); return false; }, @@ -338,6 +357,9 @@ function showSection(section) { case Section.TIPS: removeClass($('tip-line'), 'hidden'); break; + case Section.DEBUG: + removeClass($('debug'), 'hidden'); + break; } } } @@ -358,6 +380,9 @@ function hideSection(section) { case Section.TIPS: addClass($('tip-line'), 'hidden'); break; + case Section.DEBUG: + addClass($('debug'), 'hidden'); + break; } } } |